Documentation ¶
Overview ¶
Example (GetEventype) ¶
var e Event s := `{ "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "us-east-1", "eventTime": "2022-06-22T14:36:07.988Z", "eventName": "ObjectCreated:CompleteMultipartUpload", "userIdentity": { "principalId": "AWS:AIDA6AOWGDOHF37MOKWLS" }, "requestParameters": { "sourceIPAddress": "81.151.138.139" }, "responseElements": { "x-amz-request-id": "PN134P5DBY0KJG2G", "x-amz-id-2": "bNfJtmP9ASZO++y92UKMgOrnNb2nF2BxG5lpxBj7N+05Iwq7qn+xtitbnifKJR2zQNPUQVN5lyQTTyDEX0ib1Y3t+bs/P9bH" }, "s3": { "s3SchemaVersion": "1.0", "configurationId": "MTY5MDg4MjMtNGVkZS00MjQyLTlhN2MtZDU0N2RiNTRmNzAx", "bucket": { "name": "stagepipeline-rawdata202c7bd0-dmjs9376duys", "ownerIdentity": { "principalId": "AP902Y0PI20DF" }, "arn": "arn:aws:s3:::stagepipeline-rawdata202c7bd0-dmjs9376duys" }, "object": { "key": "130089473-08-03-2022-19-24-00.zip", "size": 41407836, "eTag": "b34552c7ddea5f4fd266f0d1d9fa7116-5", "sequencer": "0062B328C0F22C48E1" } } } ] }` t := e.getEventType([]byte(s)) fmt.Printf("%v\n", t)
Output: 1
Example (UnmarshalJSON) ¶
var e Event s := `{ "Records": [ { "eventVersion": "2.1", "eventSource": "aws:s3", "awsRegion": "us-east-1", "eventTime": "2022-06-22T14:36:07.988Z", "eventName": "ObjectCreated:CompleteMultipartUpload", "userIdentity": { "principalId": "AWS:AIDA6AOWGDOHF37MOKWLS" }, "requestParameters": { "sourceIPAddress": "81.151.138.139" }, "responseElements": { "x-amz-request-id": "PN134P5DBY0KJG2G", "x-amz-id-2": "bNfJtmP9ASZO++y92UKMgOrnNb2nF2BxG5lpxBj7N+05Iwq7qn+xtitbnifKJR2zQNPUQVN5lyQTTyDEX0ib1Y3t+bs/P9bH" }, "s3": { "s3SchemaVersion": "1.0", "configurationId": "MTY5MDg4MjMtNGVkZS00MjQyLTlhN2MtZDU0N2RiNTRmNzAx", "bucket": { "name": "stagepipeline-rawdata202c7bd0-dmjs9376duys", "ownerIdentity": { "principalId": "AP902Y0PI20DF" }, "arn": "arn:aws:s3:::stagepipeline-rawdata202c7bd0-dmjs9376duys" }, "object": { "key": "130089473-08-03-2022-19-24-00.zip", "size": 41407836, "eTag": "b34552c7ddea5f4fd266f0d1d9fa7116-5", "sequencer": "0062B328C0F22C48E1" } } } ] }` e.UnmarshalJSON([]byte(s)) fmt.Printf("%v\n", e.Records[0].EventSource)
Output: aws:s3
Index ¶
- Constants
- func GetS3(sess *session.Session) (s3iface.S3API, error)
- func GetSession() (*session.Session, error)
- func GetSessionWithRegion(region string) (*session.Session, error)
- func PurgeQueue(sess session.Session, url string) error
- func SESSendEmail(emailAddress string, charset string, textBody string, htmlBody string, ...)
- func SNSSendSms(phonenumber string, message string) error
- type Event
- type MockS3Client
- func (m *MockS3Client) CopyObject(input *s3.CopyObjectInput) (*s3.CopyObjectOutput, error)
- func (m *MockS3Client) DeleteObject(input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)
- func (m *MockS3Client) FinishTest() error
- func (m *MockS3Client) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)
- func (m *MockS3Client) ListObjectsV2(input *s3.ListObjectsV2Input) (*s3.ListObjectsV2Output, error)
- func (m *MockS3Client) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
- func (m *MockS3Client) SkipPutChecks(path []string)
- type MockSigner
- type RealURLSigner
- type Record
Examples ¶
Constants ¶
View Source
const ErrNoMoreInputsExpected = "No more inputs expected for "
View Source
const ErrNothingToReturn = "Nothing to return from "
View Source
const ErrReturningError = "Returning error from "
View Source
const ErrWrongInput = "Incorrect input in "
Variables ¶
This section is empty.
Functions ¶
func GetSessionWithRegion ¶
GetSessionWithRegion - Can specify am S3 region, returns an AWS session
func SESSendEmail ¶
func SESSendEmail(emailAddress string, charset string, textBody string, htmlBody string, subject string, sender string, cc []string, bcc []string)
SESSendEmail - Send an email via SES
func SNSSendSms ¶
SNSSendSms Send an SMS via SNS
Types ¶
type Event ¶
type Event struct {
Records []Record
}
func (*Event) UnmarshalJSON ¶
UnmarshalJSON - Decode the JSON to the correct Event type
type MockS3Client ¶
type MockS3Client struct { s3iface.S3API // Expected requests ExpListObjectsV2Input []s3.ListObjectsV2Input ExpGetObjectInput []s3.GetObjectInput ExpPutObjectInput []s3.PutObjectInput ExpDeleteObjectInput []s3.DeleteObjectInput ExpCopyObjectInput []s3.CopyObjectInput // Responses replayed as each request comes in QueuedListObjectsV2Output []*s3.ListObjectsV2Output QueuedGetObjectOutput []*s3.GetObjectOutput QueuedPutObjectOutput []*s3.PutObjectOutput QueuedDeleteObjectOutput []*s3.DeleteObjectOutput QueuedCopyObjectOutput []*s3.CopyObjectOutput AllowGetInAnyOrder bool AllowDeleteInAnyOrder bool SkipPutCheckNames []string // contains filtered or unexported fields }
MockS3Client - mock S3 client for unit tests. Don't forget to call FinishTest() at the end of your test to check that all calls to S3 were made, and there were no unexpected calls!
func (*MockS3Client) CopyObject ¶
func (m *MockS3Client) CopyObject(input *s3.CopyObjectInput) (*s3.CopyObjectOutput, error)
func (*MockS3Client) DeleteObject ¶
func (m *MockS3Client) DeleteObject(input *s3.DeleteObjectInput) (*s3.DeleteObjectOutput, error)
func (*MockS3Client) FinishTest ¶
func (m *MockS3Client) FinishTest() error
NOTE: This function MUST be called at the end of a unit test/example test. Use defer when declaring MockS3Client!
func (*MockS3Client) GetObject ¶
func (m *MockS3Client) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error)
func (*MockS3Client) ListObjectsV2 ¶
func (m *MockS3Client) ListObjectsV2(input *s3.ListObjectsV2Input) (*s3.ListObjectsV2Output, error)
func (*MockS3Client) PutObject ¶
func (m *MockS3Client) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error)
func (*MockS3Client) SkipPutChecks ¶
func (m *MockS3Client) SkipPutChecks(path []string)
type MockSigner ¶
type MockSigner struct {
Urls []string
}
type RealURLSigner ¶
type RealURLSigner struct { }
RealURLSigner - The runtime URL signer (as opposed to the mock)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.