-
Notifications
You must be signed in to change notification settings - Fork 7
/
s3events.go
52 lines (44 loc) · 1.93 KB
/
s3events.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package s3storage
import (
"encoding/json"
)
// S3Event describes events received from S3 notification service.
// They are, kind of, documented here: https://docs.aws.amazon.com/AmazonS3/latest/dev/notification-content-structure.html
type S3Event struct {
Records []S3EventRecord `json:"Records,omitempty"`
}
func (p *S3Event) Unmarshal(data []byte) error {
return json.Unmarshal(data, p)
}
type S3EventRecord struct {
EventVersion string `json:"eventVersion,omitempty"`
EventSource string `json:"eventSource,omitempty"`
AwsRegion string `json:"awsRegion,omitempty"`
EventTime string `json:"eventTime,omitempty"`
EventName string `json:"eventName,omitempty"`
UserIdentity S3EventRecordIdentity `json:"userIdentity,omitempty"`
RequestParameters map[string]string `json:"requestParameters,omitempty"`
ResponseElements map[string]string `json:"responseElements,omitempty"`
S3 S3EventRecordData `json:"s3,omitempty"`
}
type S3EventRecordIdentity struct {
PrincipalId string `json:"principalId,omitempty"`
}
type S3EventRecordData struct {
S3SchemaVersion string `json:"s3SchemaVersion,omitempty"`
ConfigurationId string `json:"configurationId,omitempty"`
Bucket S3EventRecordDataBucket `json:"bucket,omitempty"`
Object S3EventRecordDataObject `json:"object,omitempty"`
}
type S3EventRecordDataBucket struct {
Name string `json:"name,omitempty"`
OwnerIdentity S3EventRecordIdentity `json:"ownerIdentity,omitempty"`
Arn string `json:"arn,omitempty"`
}
type S3EventRecordDataObject struct {
Key string `json:"key,omitempty"`
Size int `json:"size,omitempty"`
ETag string `json:"eTag,omitempty"`
VersionID string `json:"versionId,omitempty"`
Sequencer string `json:"sequencer,omitempty"`
}