notification

package
v7.0.59 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 29, 2023 License: Apache-2.0 Imports: 5 Imported by: 47

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidArnPrefix is returned when ARN string format does not start with 'arn'
	ErrInvalidArnPrefix = errors.New("invalid ARN format, must start with 'arn:'")
	// ErrInvalidArnFormat is returned when ARN string format is not valid
	ErrInvalidArnFormat = errors.New("invalid ARN format, must be 'arn:<partition>:<service>:<region>:<accountID>:<resource>'")
)
View Source
var ErrNoConfigMatch = errors.New("no notification configuration matched")

ErrNoConfigMatch is returned when a notification configuration (sqs,sns,lambda) is not found when trying to delete

Functions

func EqualEventTypeList

func EqualEventTypeList(a, b []EventType) bool

EqualEventTypeList tells whether a and b contain the same events

func EqualFilterRuleList

func EqualFilterRuleList(a, b []FilterRule) bool

EqualFilterRuleList tells whether a and b contain the same filters

Types

type Arn

type Arn struct {
	Partition string
	Service   string
	Region    string
	AccountID string
	Resource  string
}

Arn - holds ARN information that will be sent to the web service, ARN desciption can be found in http://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html

func NewArn

func NewArn(partition, service, region, accountID, resource string) Arn

NewArn creates new ARN based on the given partition, service, region, account id and resource

func NewArnFromString added in v7.0.44

func NewArnFromString(arn string) (Arn, error)

NewArnFromString parses string representation of ARN into Arn object. Returns an error if the string format is incorrect.

func (Arn) String

func (arn Arn) String() string

String returns the string format of the ARN

type Config

type Config struct {
	ID     string      `xml:"Id,omitempty"`
	Arn    Arn         `xml:"-"`
	Events []EventType `xml:"Event"`
	Filter *Filter     `xml:"Filter,omitempty"`
}

Config - represents one single notification configuration such as topic, queue or lambda configuration.

func NewConfig

func NewConfig(arn Arn) Config

NewConfig creates one notification config and sets the given ARN

func (*Config) AddEvents

func (t *Config) AddEvents(events ...EventType)

AddEvents adds one event to the current notification config

func (*Config) AddFilterPrefix

func (t *Config) AddFilterPrefix(prefix string)

AddFilterPrefix sets the prefix configuration to the current notification config

func (*Config) AddFilterSuffix

func (t *Config) AddFilterSuffix(suffix string)

AddFilterSuffix sets the suffix configuration to the current notification config

func (*Config) Equal

func (t *Config) Equal(events []EventType, prefix, suffix string) bool

Equal returns whether this `Config` is equal to another defined by the passed parameters

type Configuration

type Configuration struct {
	XMLName       xml.Name       `xml:"NotificationConfiguration"`
	LambdaConfigs []LambdaConfig `xml:"CloudFunctionConfiguration"`
	TopicConfigs  []TopicConfig  `xml:"TopicConfiguration"`
	QueueConfigs  []QueueConfig  `xml:"QueueConfiguration"`
}

Configuration - the struct that represents the whole XML to be sent to the web service

func (*Configuration) AddLambda

func (b *Configuration) AddLambda(lambdaConfig Config) bool

AddLambda adds a given lambda config to the general bucket notification config

func (*Configuration) AddQueue

func (b *Configuration) AddQueue(queueConfig Config) bool

AddQueue adds a given queue config to the general bucket notification config

func (*Configuration) AddTopic

func (b *Configuration) AddTopic(topicConfig Config) bool

AddTopic adds a given topic config to the general bucket notification config

func (*Configuration) RemoveLambdaByArn

func (b *Configuration) RemoveLambdaByArn(arn Arn)

RemoveLambdaByArn removes all lambda configurations that match the exact specified ARN

func (*Configuration) RemoveLambdaByArnEventsPrefixSuffix

func (b *Configuration) RemoveLambdaByArnEventsPrefixSuffix(arn Arn, events []EventType, prefix, suffix string) error

RemoveLambdaByArnEventsPrefixSuffix removes a topic configuration that match the exact specified ARN, events, prefix and suffix

func (*Configuration) RemoveQueueByArn

func (b *Configuration) RemoveQueueByArn(arn Arn)

RemoveQueueByArn removes all queue configurations that match the exact specified ARN

func (*Configuration) RemoveQueueByArnEventsPrefixSuffix

func (b *Configuration) RemoveQueueByArnEventsPrefixSuffix(arn Arn, events []EventType, prefix, suffix string) error

RemoveQueueByArnEventsPrefixSuffix removes a queue configuration that match the exact specified ARN, events, prefix and suffix

func (*Configuration) RemoveTopicByArn

func (b *Configuration) RemoveTopicByArn(arn Arn)

RemoveTopicByArn removes all topic configurations that match the exact specified ARN

func (*Configuration) RemoveTopicByArnEventsPrefixSuffix

func (b *Configuration) RemoveTopicByArnEventsPrefixSuffix(arn Arn, events []EventType, prefix, suffix string) error

RemoveTopicByArnEventsPrefixSuffix removes a topic configuration that match the exact specified ARN, events, prefix and suffix

type Event

type Event struct {
	EventVersion      string            `json:"eventVersion"`
	EventSource       string            `json:"eventSource"`
	AwsRegion         string            `json:"awsRegion"`
	EventTime         string            `json:"eventTime"`
	EventName         string            `json:"eventName"`
	UserIdentity      identity          `json:"userIdentity"`
	RequestParameters map[string]string `json:"requestParameters"`
	ResponseElements  map[string]string `json:"responseElements"`
	S3                eventMeta         `json:"s3"`
	Source            sourceInfo        `json:"source"`
}

Event represents an Amazon an S3 bucket notification event.

type EventType

type EventType string

EventType is a S3 notification event associated to the bucket notification configuration

const (
	ObjectCreatedAll                                   EventType = "s3:ObjectCreated:*"
	ObjectCreatedPut                                   EventType = "s3:ObjectCreated:Put"
	ObjectCreatedPost                                  EventType = "s3:ObjectCreated:Post"
	ObjectCreatedCopy                                  EventType = "s3:ObjectCreated:Copy"
	ObjectCreatedCompleteMultipartUpload               EventType = "s3:ObjectCreated:CompleteMultipartUpload"
	ObjectAccessedGet                                  EventType = "s3:ObjectAccessed:Get"
	ObjectAccessedHead                                 EventType = "s3:ObjectAccessed:Head"
	ObjectAccessedAll                                  EventType = "s3:ObjectAccessed:*"
	ObjectRemovedAll                                   EventType = "s3:ObjectRemoved:*"
	ObjectRemovedDelete                                EventType = "s3:ObjectRemoved:Delete"
	ObjectRemovedDeleteMarkerCreated                   EventType = "s3:ObjectRemoved:DeleteMarkerCreated"
	ObjectReducedRedundancyLostObject                  EventType = "s3:ReducedRedundancyLostObject"
	ObjectTransitionAll                                EventType = "s3:ObjectTransition:*"
	ObjectTransitionFailed                             EventType = "s3:ObjectTransition:Failed"
	ObjectTransitionComplete                           EventType = "s3:ObjectTransition:Complete"
	ObjectTransitionPost                               EventType = "s3:ObjectRestore:Post"
	ObjectTransitionCompleted                          EventType = "s3:ObjectRestore:Completed"
	ObjectReplicationAll                               EventType = "s3:Replication:*"
	ObjectReplicationOperationCompletedReplication     EventType = "s3:Replication:OperationCompletedReplication"
	ObjectReplicationOperationFailedReplication        EventType = "s3:Replication:OperationFailedReplication"
	ObjectReplicationOperationMissedThreshold          EventType = "s3:Replication:OperationMissedThreshold"
	ObjectReplicationOperationNotTracked               EventType = "s3:Replication:OperationNotTracked"
	ObjectReplicationOperationReplicatedAfterThreshold EventType = "s3:Replication:OperationReplicatedAfterThreshold"
	BucketCreatedAll                                   EventType = "s3:BucketCreated:*"
	BucketRemovedAll                                   EventType = "s3:BucketRemoved:*"
)

The role of all event types are described in :

http://docs.aws.amazon.com/AmazonS3/latest/dev/NotificationHowTo.html#notification-how-to-event-types-and-destinations

type Filter

type Filter struct {
	S3Key S3Key `xml:"S3Key,omitempty"`
}

Filter - a tag in the notification xml structure which carries suffix/prefix filters

type FilterRule

type FilterRule struct {
	Name  string `xml:"Name"`
	Value string `xml:"Value"`
}

FilterRule - child of S3Key, a tag in the notification xml which carries suffix/prefix filters

type Info

type Info struct {
	Records []Event
	Err     error
}

Info - represents the collection of notification events, additionally also reports errors if any while listening on bucket notifications.

type LambdaConfig

type LambdaConfig struct {
	Config
	Lambda string `xml:"CloudFunction"`
}

LambdaConfig carries one single cloudfunction notification configuration

type QueueConfig

type QueueConfig struct {
	Config
	Queue string `xml:"Queue"`
}

QueueConfig carries one single queue notification configuration

type S3Key

type S3Key struct {
	FilterRules []FilterRule `xml:"FilterRule,omitempty"`
}

S3Key - child of Filter, a tag in the notification xml which carries suffix/prefix filters

type TopicConfig

type TopicConfig struct {
	Config
	Topic string `xml:"Topic"`
}

TopicConfig carries one single topic notification configuration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL