diff --git a/Makefile b/Makefile index e924b99aa1d..e2f881ec0d9 100644 --- a/Makefile +++ b/Makefile @@ -26,9 +26,9 @@ all: generate unit ################### # Code Generation # ################### -generate: cleanup-models gen-test gen-endpoints gen-services gen-tools +generate: cleanup-models gen-endpoints gen-services gen-tools -gen-test: gen-protocol-test +#gen-test: gen-protocol-test #gen-test: gen-protocol-test gen-codegen-test #gen-codegen-test: diff --git a/aws/defaults/handlers_test.go b/aws/defaults/handlers_test.go index 61d3baf16cb..7176dbb62ee 100644 --- a/aws/defaults/handlers_test.go +++ b/aws/defaults/handlers_test.go @@ -19,6 +19,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/internal/sdk" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestValidateEndpointHandler(t *testing.T) { @@ -350,7 +351,7 @@ func TestBuildContentLength_ZeroBody(t *testing.T) { svc := s3.New(cfg) svc.ForcePathStyle = true - req := svc.GetObjectRequest(&s3.GetObjectInput{ + req := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String("bucketname"), Key: aws.String("keyname"), }) @@ -368,7 +369,7 @@ func TestBuildContentLength_NegativeBody(t *testing.T) { svc := s3.New(cfg) svc.ForcePathStyle = true - req := svc.GetObjectRequest(&s3.GetObjectInput{ + req := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String("bucketname"), Key: aws.String("keyname"), }) @@ -388,7 +389,7 @@ func TestBuildContentLength_WithBody(t *testing.T) { svc := s3.New(cfg) svc.ForcePathStyle = true - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucketname"), Key: aws.String("keyname"), Body: bytes.NewReader(make([]byte, 1024)), @@ -411,7 +412,7 @@ func TestSendHandler_HEADNoBody(t *testing.T) { svc := s3.New(cfg) svc.ForcePathStyle = true - req := svc.HeadObjectRequest(&s3.HeadObjectInput{ + req := svc.HeadObjectRequest(&types.HeadObjectInput{ Bucket: aws.String("bucketname"), Key: aws.String("keyname"), }) diff --git a/aws/defaults/param_validator_test.go b/aws/defaults/param_validator_test.go index 7cf25ba4470..7df423e8f63 100644 --- a/aws/defaults/param_validator_test.go +++ b/aws/defaults/param_validator_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/kinesis" + "github.com/aws/aws-sdk-go-v2/service/kinesis/types" ) var testSvc = func() *aws.Client { @@ -260,11 +261,11 @@ func TestValidateFieldMinParameter(t *testing.T) { } func BenchmarkValidateAny(b *testing.B) { - input := &kinesis.PutRecordsInput{ + input := &types.PutRecordsInput{ StreamName: aws.String("stream"), } for i := 0; i < 100; i++ { - record := kinesis.PutRecordsRequestEntry{ + record := types.PutRecordsRequestEntry{ Data: make([]byte, 10000), PartitionKey: aws.String("partition"), } diff --git a/aws/example_test.go b/aws/example_test.go index 2b86e881878..dc42ab99748 100644 --- a/aws/example_test.go +++ b/aws/example_test.go @@ -8,7 +8,9 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/aws-sdk-go-v2/service/sqs" + types2 "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) func ExampleEndpointResolverFunc() { @@ -33,7 +35,7 @@ func ExampleEndpointResolverFunc() { // endpoint resolver wrapping the default endpoint resolver. s3Svc := s3.New(cfg) // Operation calls will be made to the custom endpoint. - objReq := s3Svc.GetObjectRequest(&s3.GetObjectInput{ + objReq := s3Svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String("myBucket"), Key: aws.String("myObjectKey"), }) @@ -49,7 +51,7 @@ func ExampleEndpointResolverFunc() { sqsSvc := sqs.New(cfg) // Operation calls will be made to the default endpoint for SQS for the // region configured. - msgReq := sqsSvc.ReceiveMessageRequest(&sqs.ReceiveMessageInput{ + msgReq := sqsSvc.ReceiveMessageRequest(&types2.ReceiveMessageInput{ QueueUrl: aws.String("my-queue-url"), }) msgResp, err := msgReq.Send(context.Background()) diff --git a/aws/signer/v4/functional_test.go b/aws/signer/v4/functional_test.go index 0a490487386..bdac0967ae3 100644 --- a/aws/signer/v4/functional_test.go +++ b/aws/signer/v4/functional_test.go @@ -11,9 +11,11 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/endpoints" - "github.com/aws/aws-sdk-go-v2/aws/signer/v4" + v4 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var standaloneSignCases = []struct { @@ -37,11 +39,11 @@ func TestPresignHandler(t *testing.T) { cfg.EndpointResolver = endpoints.NewDefaultResolver() svc := s3.New(cfg) - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), ContentDisposition: aws.String("a+b c$d"), - ACL: s3.ObjectCannedACLPublicRead, + ACL: enums.ObjectCannedACLPublicRead, }) req.Time = time.Unix(0, 0) urlstr, err := req.Presign(5 * time.Minute) @@ -90,11 +92,11 @@ func TestPresignRequest(t *testing.T) { cfg.EndpointResolver = endpoints.NewDefaultResolver() svc := s3.New(cfg) - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), ContentDisposition: aws.String("a+b c$d"), - ACL: s3.ObjectCannedACLPublicRead, + ACL: enums.ObjectCannedACLPublicRead, }) req.Time = time.Unix(0, 0) urlstr, headers, err := req.PresignRequest(5 * time.Minute) diff --git a/aws/stscreds/provider.go b/aws/stscreds/provider.go index ef1b7e71daf..e88a3d827ba 100644 --- a/aws/stscreds/provider.go +++ b/aws/stscreds/provider.go @@ -89,6 +89,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/aws-sdk-go-v2/service/sts/types" ) // StdinTokenProvider will prompt on stdout and read from stdin for a string value. @@ -115,7 +116,7 @@ const ProviderName = "AssumeRoleProvider" // AssumeRoler represents the minimal subset of the STS client API used by this provider. type AssumeRoler interface { - AssumeRoleRequest(input *sts.AssumeRoleInput) sts.AssumeRoleRequest + AssumeRoleRequest(input *types.AssumeRoleInput) sts.AssumeRoleRequest } // DefaultDuration is the default amount of time in minutes that the credentials @@ -220,7 +221,7 @@ func (p *AssumeRoleProvider) retrieveFn() (aws.Credentials, error) { // Expire as often as AWS permits. p.Duration = DefaultDuration } - input := &sts.AssumeRoleInput{ + input := &types.AssumeRoleInput{ DurationSeconds: aws.Int64(int64(p.Duration / time.Second)), RoleArn: aws.String(p.RoleARN), RoleSessionName: aws.String(p.RoleSessionName), diff --git a/aws/stscreds/provider_test.go b/aws/stscreds/provider_test.go index e6b64aea597..255406d3a52 100644 --- a/aws/stscreds/provider_test.go +++ b/aws/stscreds/provider_test.go @@ -8,13 +8,14 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/aws-sdk-go-v2/service/sts/types" ) type stubSTS struct { - TestInput func(*sts.AssumeRoleInput) + TestInput func(*types.AssumeRoleInput) } -func (s *stubSTS) AssumeRoleRequest(input *sts.AssumeRoleInput) sts.AssumeRoleRequest { +func (s *stubSTS) AssumeRoleRequest(input *types.AssumeRoleInput) sts.AssumeRoleRequest { if s.TestInput != nil { s.TestInput(input) } @@ -32,8 +33,8 @@ func (s *stubSTS) AssumeRoleRequest(input *sts.AssumeRoleInput) sts.AssumeRoleRe h.Send.PushBack(func(r *aws.Request) { r.HTTPResponse = &http.Response{StatusCode: 200} - r.Data = &sts.AssumeRoleOutput{ - Credentials: &sts.Credentials{ + r.Data = &types.AssumeRoleOutput{ + Credentials: &types.Credentials{ // Just reflect the role arn to the provider. AccessKeyId: input.RoleArn, SecretAccessKey: aws.String("assumedSecretAccessKey"), @@ -75,7 +76,7 @@ func TestAssumeRoleProvider(t *testing.T) { func TestAssumeRoleProvider_WithTokenCode(t *testing.T) { stub := &stubSTS{ - TestInput: func(in *sts.AssumeRoleInput) { + TestInput: func(in *types.AssumeRoleInput) { if e, a := "0123456789", *in.SerialNumber; e != a { t.Errorf("expect %v, got %v", e, a) } @@ -106,7 +107,7 @@ func TestAssumeRoleProvider_WithTokenCode(t *testing.T) { func TestAssumeRoleProvider_WithTokenProvider(t *testing.T) { stub := &stubSTS{ - TestInput: func(in *sts.AssumeRoleInput) { + TestInput: func(in *types.AssumeRoleInput) { if e, a := "0123456789", *in.SerialNumber; e != a { t.Errorf("expect %v, got %v", e, a) } @@ -139,7 +140,7 @@ func TestAssumeRoleProvider_WithTokenProvider(t *testing.T) { func TestAssumeRoleProvider_WithTokenProviderError(t *testing.T) { stub := &stubSTS{ - TestInput: func(in *sts.AssumeRoleInput) { + TestInput: func(in *types.AssumeRoleInput) { t.Fatalf("API request should not of been called") }, } @@ -167,7 +168,7 @@ func TestAssumeRoleProvider_WithTokenProviderError(t *testing.T) { func TestAssumeRoleProvider_MFAWithNoToken(t *testing.T) { stub := &stubSTS{ - TestInput: func(in *sts.AssumeRoleInput) { + TestInput: func(in *types.AssumeRoleInput) { t.Fatalf("API request should not of been called") }, } diff --git a/example/aws/endpoints/customEndpoint/customEndpoint.go b/example/aws/endpoints/customEndpoint/customEndpoint.go index a2abd448955..c94747a613d 100644 --- a/example/aws/endpoints/customEndpoint/customEndpoint.go +++ b/example/aws/endpoints/customEndpoint/customEndpoint.go @@ -9,8 +9,11 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/dynamodb" + dynamodb_types "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" "github.com/aws/aws-sdk-go-v2/service/s3" + s3_types "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/aws-sdk-go-v2/service/sqs" + sqs_types "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) func main() { @@ -38,7 +41,7 @@ func main() { // endpoint resolver wrapping the default endpoint resolver. s3Svc := s3.New(cfg) // Operation calls will be made to the custom endpoint. - getReq := s3Svc.GetObjectRequest(&s3.GetObjectInput{ + getReq := s3Svc.GetObjectRequest(&s3_types.GetObjectInput{ Bucket: aws.String("myBucket"), Key: aws.String("myObjectKey"), }) @@ -50,7 +53,7 @@ func main() { sqsSvc := sqs.New(cfg) // Operation calls will be made to the default endpoint for SQS for the // region configured. - msgReq := sqsSvc.ReceiveMessageRequest(&sqs.ReceiveMessageInput{ + msgReq := sqsSvc.ReceiveMessageRequest(&sqs_types.ReceiveMessageInput{ QueueUrl: aws.String("my-queue-url"), }) msgReq.Send(context.Background()) @@ -72,7 +75,7 @@ func main() { ddbSvc := dynamodb.New(cfgCp) // Operation calls will be made to the custom endpoint set in the // ddCustResolverFn. - listReq := ddbSvc.ListTablesRequest(&dynamodb.ListTablesInput{}) + listReq := ddbSvc.ListTablesRequest(&dynamodb_types.ListTablesInput{}) listReq.Send(context.Background()) // Setting Config's Endpoint will override the EndpointResolver. Forcing @@ -82,6 +85,6 @@ func main() { cfgCp.EndpointResolver = aws.ResolveWithEndpointURL("http://localhost:8088") ddbSvcLocal := dynamodb.New(cfgCp) - listReq = ddbSvcLocal.ListTablesRequest(&dynamodb.ListTablesInput{}) + listReq = ddbSvcLocal.ListTablesRequest(&dynamodb_types.ListTablesInput{}) listReq.Send(context.Background()) } diff --git a/example/aws/request/handleServiceErrorCodes/handleServiceErrorCodes.go b/example/aws/request/handleServiceErrorCodes/handleServiceErrorCodes.go index 80f149bfebc..46ddc360f35 100644 --- a/example/aws/request/handleServiceErrorCodes/handleServiceErrorCodes.go +++ b/example/aws/request/handleServiceErrorCodes/handleServiceErrorCodes.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -39,7 +40,7 @@ func main() { } svc := s3.New(cfg) - req := svc.GetObjectRequest(&s3.GetObjectInput{ + req := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String(os.Args[1]), Key: aws.String(os.Args[2]), }) diff --git a/example/aws/request/withContext/withContext.go b/example/aws/request/withContext/withContext.go index 32b62b33468..8cf483efb15 100644 --- a/example/aws/request/withContext/withContext.go +++ b/example/aws/request/withContext/withContext.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // Uploads a file to S3 given a bucket and object key. Also takes a duration @@ -55,7 +56,7 @@ func main() { // Uploads the object to S3. The Context will interrupt the request if the // timeout expires. - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String(bucket), Key: aws.String(key), Body: os.Stdin, diff --git a/example/service/dynamodb/expression/scan.go b/example/service/dynamodb/expression/scan.go index c98d77325b6..f3260660c49 100644 --- a/example/service/dynamodb/expression/scan.go +++ b/example/service/dynamodb/expression/scan.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/expression" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -49,7 +50,7 @@ func main() { } // Build the query input parameters - params := &dynamodb.ScanInput{ + params := &types.ScanInput{ ExpressionAttributeNames: expr.Names(), ExpressionAttributeValues: expr.Values(), FilterExpression: expr.Filter(), @@ -84,7 +85,7 @@ func (c *Config) Load() error { if len(c.Table) == 0 { flag.PrintDefaults() - return fmt.Errorf("table name is required.") + return fmt.Errorf("table name is required") } return nil diff --git a/example/service/dynamodb/scanItems/scanItems.go b/example/service/dynamodb/scanItems/scanItems.go index 0b3d61ad4b9..298000be57f 100644 --- a/example/service/dynamodb/scanItems/scanItems.go +++ b/example/service/dynamodb/scanItems/scanItems.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -41,7 +42,7 @@ func main() { svc := dynamodb.New(awscfg) // Build the query input parameters - params := &dynamodb.ScanInput{ + params := &types.ScanInput{ TableName: aws.String(cfg.Table), } if cfg.Limit > 0 { @@ -55,7 +56,7 @@ func main() { exitErrorf("failed to make Query API call, %v", err) } - items := []Item{} + var items []Item // Unmarshal the Items field in the result value to the Item Go type. err = dynamodbattribute.UnmarshalListOfMaps(result.Items, &items) @@ -94,7 +95,7 @@ func (c *Config) Load() error { if len(c.Table) == 0 { flag.PrintDefaults() - return fmt.Errorf("table name is required.") + return fmt.Errorf("table name is required") } return nil diff --git a/example/service/dynamodb/unitTest/unitTest.go b/example/service/dynamodb/unitTest/unitTest.go index 87e97bbc53d..94da48b29e7 100644 --- a/example/service/dynamodb/unitTest/unitTest.go +++ b/example/service/dynamodb/unitTest/unitTest.go @@ -8,9 +8,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbiface" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // ItemGetter can be assigned a DynamoDB connector like: @@ -23,8 +23,8 @@ type ItemGetter struct { // Get a value from a DynamoDB table containing entries like: // {"id": "my primary key", "value": "valuable value"} func (ig *ItemGetter) Get(id string) (value string) { - var input = &dynamodb.GetItemInput{ - Key: map[string]dynamodb.AttributeValue{ + var input = &types.GetItemInput{ + Key: map[string]types.AttributeValue{ "id": { S: aws.String(id), }, diff --git a/example/service/dynamodb/unitTest/unitTest_test.go b/example/service/dynamodb/unitTest/unitTest_test.go index 21405c671b3..a0010ad0c43 100644 --- a/example/service/dynamodb/unitTest/unitTest_test.go +++ b/example/service/dynamodb/unitTest/unitTest_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbiface" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // A fakeDynamoDB instance. During testing, instatiate ItemGetter, then simply @@ -22,19 +23,19 @@ type fakeDynamoDB struct { } // Mock GetItem such that the output returned carries values identical to input. -func (fd *fakeDynamoDB) GetItemRequest(input *dynamodb.GetItemInput) dynamodb.GetItemRequest { - output := &dynamodb.GetItemOutput{ - Item: map[string]dynamodb.AttributeValue{}, +func (fd *fakeDynamoDB) GetItemRequest(input *types.GetItemInput) dynamodb.GetItemRequest { + output := &types.GetItemOutput{ + Item: map[string]types.AttributeValue{}, } for key, value := range fd.payload { - output.Item[key] = dynamodb.AttributeValue{ + output.Item[key] = types.AttributeValue{ S: aws.String(value), } } req := dynamodb.GetItemRequest{ Request: &aws.Request{ - Data: output, - Error: fd.err, + Data: output, + Error: fd.err, HTTPRequest: &http.Request{}, }, } diff --git a/example/service/ec2/filterInstances/filter_ec2_by_tag.go b/example/service/ec2/filterInstances/filter_ec2_by_tag.go index 6e06b444b9a..350a5732db8 100644 --- a/example/service/ec2/filterInstances/filter_ec2_by_tag.go +++ b/example/service/ec2/filterInstances/filter_ec2_by_tag.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) // This example will list instances with a filter @@ -30,8 +31,8 @@ func main() { svc := ec2.New(cfg) fmt.Printf("listing instances with tag %v in: %v\n", nameFilter, awsRegion) - params := &ec2.DescribeInstancesInput{ - Filters: []ec2.Filter{ + params := &types.DescribeInstancesInput{ + Filters: []types.Filter{ { Name: aws.String("tag:Name"), Values: []string{ diff --git a/example/service/ec2/instancesbyRegion/instancesByRegion.go b/example/service/ec2/instancesbyRegion/instancesByRegion.go index 3abe0822a90..11b8ced7d67 100644 --- a/example/service/ec2/instancesbyRegion/instancesByRegion.go +++ b/example/service/ec2/instancesbyRegion/instancesByRegion.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -52,8 +53,8 @@ func main() { cfg.Region = region ec2Svc := ec2.New(cfg) - params := &ec2.DescribeInstancesInput{ - Filters: []ec2.Filter{ + params := &types.DescribeInstancesInput{ + Filters: []types.Filter{ { Name: aws.String("instance-state-name"), Values: states, @@ -90,7 +91,7 @@ func fetchRegion() ([]string, error) { } svc := ec2.New(cfg) - req := svc.DescribeRegionsRequest(&ec2.DescribeRegionsInput{}) + req := svc.DescribeRegionsRequest(&types.DescribeRegionsInput{}) awsRegions, err := req.Send(context.Background()) if err != nil { return nil, err diff --git a/example/service/mediastoredata/streamingNonSeekableReader/main.go b/example/service/mediastoredata/streamingNonSeekableReader/main.go index 23c7bfa7f83..cb2af1eb965 100644 --- a/example/service/mediastoredata/streamingNonSeekableReader/main.go +++ b/example/service/mediastoredata/streamingNonSeekableReader/main.go @@ -12,7 +12,9 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/mediastore" + "github.com/aws/aws-sdk-go-v2/service/mediastore/types" "github.com/aws/aws-sdk-go-v2/service/mediastoredata" + mediastoredata_types "github.com/aws/aws-sdk-go-v2/service/mediastoredata/types" ) func main() { @@ -37,7 +39,7 @@ func main() { // Make the PutObject API call with the nonseekable reader, causing the SDK // to send the request body payload a chunked transfer encoding. - dataSvc.PutObjectRequest(&mediastoredata.PutObjectInput{ + dataSvc.PutObjectRequest(&mediastoredata_types.PutObjectInput{ Path: &objectPath, Body: body, }) @@ -66,7 +68,7 @@ func getMediaStoreDataClient(containerName string, config aws.Config) (*mediasto func containerEndpoint(name string, config aws.Config) (*string, error) { for i := 0; i < 3; i++ { ctrlSvc := mediastore.New(config) - descContainerRequest := ctrlSvc.DescribeContainerRequest(&mediastore.DescribeContainerInput{ + descContainerRequest := ctrlSvc.DescribeContainerRequest(&types.DescribeContainerInput{ ContainerName: &name, }) diff --git a/example/service/s3/concatObjects/concatObjects.go b/example/service/s3/concatObjects/concatObjects.go index 117d3dfabc1..5d8236409f6 100644 --- a/example/service/s3/concatObjects/concatObjects.go +++ b/example/service/s3/concatObjects/concatObjects.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) type client struct { @@ -22,7 +23,7 @@ type client struct { // concatenate will contenate key1's object to key2's object under the key testKey func (c *client) concatenate(key1, key2, key3 string, uploadID *string) (*string, *string, error) { // The first part to be uploaded which is represented as part number 1 - req := c.s3Client.UploadPartCopyRequest(&s3.UploadPartCopyInput{ + req := c.s3Client.UploadPartCopyRequest(&types.UploadPartCopyInput{ Bucket: c.bucket, CopySource: aws.String(url.QueryEscape(*c.bucket + "/" + key1)), PartNumber: aws.Int64(1), @@ -36,7 +37,7 @@ func (c *client) concatenate(key1, key2, key3 string, uploadID *string) (*string // The second part that is going to be appended to the newly created testKey // object. - req = c.s3Client.UploadPartCopyRequest(&s3.UploadPartCopyInput{ + req = c.s3Client.UploadPartCopyRequest(&types.UploadPartCopyInput{ Bucket: c.bucket, CopySource: aws.String(url.QueryEscape(*c.bucket + "/" + key2)), PartNumber: aws.Int64(2), @@ -76,7 +77,7 @@ func main() { c := client{svc, &bucket} // We let the service know that we want to do a multipart upload - createReq := c.s3Client.CreateMultipartUploadRequest(&s3.CreateMultipartUploadInput{ + createReq := c.s3Client.CreateMultipartUploadRequest(&types.CreateMultipartUploadInput{ Bucket: &bucket, Key: &key3, }) @@ -92,12 +93,12 @@ func main() { } // We finally complete the multipart upload. - compReq := c.s3Client.CompleteMultipartUploadRequest(&s3.CompleteMultipartUploadInput{ + compReq := c.s3Client.CompleteMultipartUploadRequest(&types.CompleteMultipartUploadInput{ Bucket: &bucket, Key: &key3, UploadId: output.UploadId, - MultipartUpload: &s3.CompletedMultipartUpload{ - Parts: []s3.CompletedPart{ + MultipartUpload: &types.CompletedMultipartUpload{ + Parts: []types.CompletedPart{ { ETag: foo, PartNumber: aws.Int64(1), diff --git a/example/service/s3/listObjects/listObjects.go b/example/service/s3/listObjects/listObjects.go index 67d07b6fb02..dd456127c9a 100644 --- a/example/service/s3/listObjects/listObjects.go +++ b/example/service/s3/listObjects/listObjects.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -32,7 +33,7 @@ func main() { svc := s3.New(cfg) - req := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &os.Args[1]}) + req := svc.ListObjectsRequest(&types.ListObjectsInput{Bucket: &os.Args[1]}) p := s3.NewListObjectsPaginator(req) for p.Next(context.TODO()) { page := p.CurrentPage() diff --git a/example/service/s3/listObjectsConcurrently/listObjectsConcurrently.go b/example/service/s3/listObjectsConcurrently/listObjectsConcurrently.go index a19a3d371fa..6c1a80a0f11 100644 --- a/example/service/s3/listObjectsConcurrently/listObjectsConcurrently.go +++ b/example/service/s3/listObjectsConcurrently/listObjectsConcurrently.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -57,7 +58,7 @@ func main() { // Receive from the bucket channel printing the information for each bucket to the console // when the bucketCh channel is drained. - buckets := []Bucket{} + var buckets []Bucket for b := range bucketCh { buckets = append(buckets, b) } @@ -162,7 +163,7 @@ type Bucket struct { } func (b *Bucket) encryptedObjects() []Object { - encObjs := []Object{} + var encObjs []Object for _, obj := range b.Objects { if obj.Encrypted { encObjs = append(encObjs, obj) @@ -172,7 +173,7 @@ func (b *Bucket) encryptedObjects() []Object { } func listBuckets(svc *s3.Client) ([]Bucket, error) { - listReq := svc.ListBucketsRequest(&s3.ListBucketsInput{}) + listReq := svc.ListBucketsRequest(&types.ListBucketsInput{}) res, err := listReq.Send(context.Background()) if err != nil { return nil, err @@ -185,7 +186,7 @@ func listBuckets(svc *s3.Client) ([]Bucket, error) { CreationDate: *b.CreationDate, } - getReq := svc.GetBucketLocationRequest(&s3.GetBucketLocationInput{ + getReq := svc.GetBucketLocationRequest(&types.GetBucketLocationInput{ Bucket: b.Name, }) locRes, err := getReq.Send(context.Background()) @@ -205,7 +206,7 @@ func listBuckets(svc *s3.Client) ([]Bucket, error) { } func listBucketObjects(svc *s3.Client, bucket string) ([]Object, []ErrObject, error) { - listReq := svc.ListObjectsRequest(&s3.ListObjectsInput{ + listReq := svc.ListObjectsRequest(&types.ListObjectsInput{ Bucket: &bucket, }) listRes, err := listReq.Send(context.Background()) @@ -216,7 +217,7 @@ func listBucketObjects(svc *s3.Client, bucket string) ([]Object, []ErrObject, er objs := make([]Object, 0, len(listRes.Contents)) errObjs := []ErrObject{} for _, listObj := range listRes.Contents { - objReq := svc.HeadObjectRequest(&s3.HeadObjectInput{ + objReq := svc.HeadObjectRequest(&types.HeadObjectInput{ Bucket: &bucket, Key: listObj.Key, }) diff --git a/example/service/s3/mockPaginator/mockPaginator.go b/example/service/s3/mockPaginator/mockPaginator.go index 0055ee0bca6..7e04dc27c53 100644 --- a/example/service/s3/mockPaginator/mockPaginator.go +++ b/example/service/s3/mockPaginator/mockPaginator.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func main() { @@ -30,11 +31,11 @@ func main() { } func getKeys(svc s3iface.ClientAPI, bucket string) []string { - req := svc.ListObjectsRequest(&s3.ListObjectsInput{ + req := svc.ListObjectsRequest(&types.ListObjectsInput{ Bucket: &bucket, }) p := s3.NewListObjectsPaginator(req) - keys := []string{} + var keys []string for p.Next(context.Background()) { page := p.CurrentPage() for _, obj := range page.Contents { diff --git a/example/service/s3/mockPaginator/mockPaginator_test.go b/example/service/s3/mockPaginator/mockPaginator_test.go index f7331d34eb3..aa46cebadf4 100644 --- a/example/service/s3/mockPaginator/mockPaginator_test.go +++ b/example/service/s3/mockPaginator/mockPaginator_test.go @@ -8,17 +8,18 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) type mockS3Client struct { *s3.Client index int - objects []s3.ListObjectsOutput + objects []types.ListObjectsOutput } -func (c *mockS3Client) ListObjectsRequest(input *s3.ListObjectsInput) s3.ListObjectsRequest { +func (c *mockS3Client) ListObjectsRequest(input *types.ListObjectsInput) s3.ListObjectsRequest { req := c.Client.ListObjectsRequest(input) - req.Copy = func(v *s3.ListObjectsInput) s3.ListObjectsRequest { + req.Copy = func(v *types.ListObjectsInput) s3.ListObjectsRequest { r := c.Client.ListObjectsRequest(v) r.Handlers.Clear() r.Handlers.Send.PushBack(func(r *aws.Request) { @@ -34,9 +35,9 @@ func (c *mockS3Client) ListObjectsRequest(input *s3.ListObjectsInput) s3.ListObj func TestListObjectsPagination(t *testing.T) { svc := &mockS3Client{} - objects := []s3.ListObjectsOutput{ + objects := []types.ListObjectsOutput{ { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("1"), }, @@ -45,7 +46,7 @@ func TestListObjectsPagination(t *testing.T) { IsTruncated: aws.Bool(true), }, { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("2"), }, @@ -54,7 +55,7 @@ func TestListObjectsPagination(t *testing.T) { IsTruncated: aws.Bool(true), }, { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("3"), }, @@ -62,7 +63,7 @@ func TestListObjectsPagination(t *testing.T) { IsTruncated: aws.Bool(false), }, { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("2"), }, diff --git a/example/service/s3/presignURL/server/server.go b/example/service/s3/presignURL/server/server.go index ffec4966cb9..3057dcd39fd 100644 --- a/example/service/s3/presignURL/server/server.go +++ b/example/service/s3/presignURL/server/server.go @@ -20,6 +20,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // server.go is an example of a service that vends lists for requests for presigned @@ -132,7 +133,7 @@ func listenAndServe(addr, bucket string, svc s3iface.ClientAPI) error { case "PUT": // For creating PutObject presigned URLs fmt.Println("Received request to presign PutObject for,", key) - sdkReq := svc.PutObjectRequest(&s3.PutObjectInput{ + sdkReq := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String(bucket), Key: aws.String(key), @@ -143,7 +144,7 @@ func listenAndServe(addr, bucket string, svc s3iface.ClientAPI) error { case "GET": // For creating GetObject presigned URLs fmt.Println("Received request to presign GetObject for,", key) - sdkReq := svc.GetObjectRequest(&s3.GetObjectInput{ + sdkReq := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String(bucket), Key: aws.String(key), }) diff --git a/example/service/s3/putObjectAcl/putObjectAcl.go b/example/service/s3/putObjectAcl/putObjectAcl.go index 98aff280e4b..47ab7294250 100644 --- a/example/service/s3/putObjectAcl/putObjectAcl.go +++ b/example/service/s3/putObjectAcl/putObjectAcl.go @@ -10,6 +10,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // Put an ACL on an S3 object @@ -39,8 +41,8 @@ func main() { flag.Parse() // Based off the type, fields must be excluded. - switch s3.Type(*granteeTypePtr) { - case s3.TypeCanonicalUser: + switch enums.Type(*granteeTypePtr) { + case enums.TypeCanonicalUser: emailPtr, uriPtr = nil, nil if *displayNamePtr == "" { displayNamePtr = nil @@ -49,9 +51,9 @@ func main() { if *userPtr == "" { userPtr = nil } - case s3.TypeAmazonCustomerByEmail: + case enums.TypeAmazonCustomerByEmail: uriPtr, userPtr = nil, nil - case s3.TypeGroup: + case enums.TypeGroup: emailPtr, userPtr = nil, nil } @@ -65,24 +67,24 @@ func main() { svc := s3.New(cfg) - req := svc.PutObjectAclRequest(&s3.PutObjectAclInput{ + req := svc.PutObjectAclRequest(&types.PutObjectAclInput{ Bucket: bucketPtr, Key: keyPtr, - AccessControlPolicy: &s3.AccessControlPolicy{ - Owner: &s3.Owner{ + AccessControlPolicy: &types.AccessControlPolicy{ + Owner: &types.Owner{ DisplayName: ownerNamePtr, ID: ownerIDPtr, }, - Grants: []s3.Grant{ + Grants: []types.Grant{ { - Grantee: &s3.Grantee{ - Type: s3.Type(*granteeTypePtr), + Grantee: &types.Grantee{ + Type: enums.Type(*granteeTypePtr), DisplayName: displayNamePtr, URI: uriPtr, EmailAddress: emailPtr, ID: userPtr, }, - Permission: s3.PermissionFullControl, + Permission: enums.PermissionFullControl, }, }, }, diff --git a/example/service/sagemaker/createTrainingJob/createTrainingJobs.go b/example/service/sagemaker/createTrainingJob/createTrainingJobs.go index d6af1af230b..bad3936f73b 100644 --- a/example/service/sagemaker/createTrainingJob/createTrainingJobs.go +++ b/example/service/sagemaker/createTrainingJob/createTrainingJobs.go @@ -9,6 +9,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/sagemaker" + "github.com/aws/aws-sdk-go-v2/service/sagemaker/enums" + "github.com/aws/aws-sdk-go-v2/service/sagemaker/types" ) func exitErrorf(msg string, args ...interface{}) { @@ -33,13 +35,13 @@ func main() { S3OutputPath := "s3:// 0 { diff --git a/example/service/sqs/mockingClientsForTests/ifaceExample_test.go b/example/service/sqs/mockingClientsForTests/ifaceExample_test.go index 6102156541b..bd775107bf8 100644 --- a/example/service/sqs/mockingClientsForTests/ifaceExample_test.go +++ b/example/service/sqs/mockingClientsForTests/ifaceExample_test.go @@ -10,14 +10,15 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/sqs" "github.com/aws/aws-sdk-go-v2/service/sqs/sqsiface" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) type mockedReceiveMsgs struct { sqsiface.ClientAPI - Resp sqs.ReceiveMessageOutput + Resp types.ReceiveMessageOutput } -func (m mockedReceiveMsgs) ReceiveMessageRequest(in *sqs.ReceiveMessageInput) sqs.ReceiveMessageRequest { +func (m mockedReceiveMsgs) ReceiveMessageRequest(in *types.ReceiveMessageInput) sqs.ReceiveMessageRequest { // Only need to return mocked response output return sqs.ReceiveMessageRequest{ Request: &aws.Request{ @@ -29,12 +30,12 @@ func (m mockedReceiveMsgs) ReceiveMessageRequest(in *sqs.ReceiveMessageInput) sq func TestQueueGetMessage(t *testing.T) { cases := []struct { - Resp sqs.ReceiveMessageOutput + Resp types.ReceiveMessageOutput Expected []Message }{ { // Case 1, expect parsed responses - Resp: sqs.ReceiveMessageOutput{ - Messages: []sqs.Message{ + Resp: types.ReceiveMessageOutput{ + Messages: []types.Message{ {Body: aws.String(`{"from":"user_1","to":"room_1","msg":"Hello!"}`)}, {Body: aws.String(`{"from":"user_2","to":"room_1","msg":"Hi user_1 :)"}`)}, }, @@ -45,7 +46,7 @@ func TestQueueGetMessage(t *testing.T) { }, }, { // Case 2, not messages returned - Resp: sqs.ReceiveMessageOutput{}, + Resp: types.ReceiveMessageOutput{}, Expected: []Message{}, }, } diff --git a/internal/awstesting/cmd/bucket_cleanup/main.go b/internal/awstesting/cmd/bucket_cleanup/main.go index af0fcd2ccfe..af24c24d253 100644 --- a/internal/awstesting/cmd/bucket_cleanup/main.go +++ b/internal/awstesting/cmd/bucket_cleanup/main.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // Searches the buckets of an account that match the prefix, and deletes @@ -26,7 +27,7 @@ func main() { } svc := s3.New(cfg) - req := svc.ListBucketsRequest(&s3.ListBucketsInput{}) + req := svc.ListBucketsRequest(&types.ListBucketsInput{}) buckets, err := req.Send(context.Background()) if err != nil { panic(fmt.Sprintf("failed to list buckets, %v", err)) @@ -68,25 +69,25 @@ func main() { func deleteBucket(svc *s3.Client, bucket string) error { bucketName := &bucket - listReq := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: bucketName}) + listReq := svc.ListObjectsRequest(&types.ListObjectsInput{Bucket: bucketName}) objs, err := listReq.Send(context.Background()) if err != nil { return fmt.Errorf("failed to list bucket %q objects, %v", *bucketName, err) } for _, o := range objs.Contents { - delReq := svc.DeleteObjectRequest(&s3.DeleteObjectInput{Bucket: bucketName, Key: o.Key}) + delReq := svc.DeleteObjectRequest(&types.DeleteObjectInput{Bucket: bucketName, Key: o.Key}) delReq.Send(context.Background()) } - listMulReq := svc.ListMultipartUploadsRequest(&s3.ListMultipartUploadsInput{Bucket: bucketName}) + listMulReq := svc.ListMultipartUploadsRequest(&types.ListMultipartUploadsInput{Bucket: bucketName}) uploads, err := listMulReq.Send(context.Background()) if err != nil { return fmt.Errorf("failed to list bucket %q multipart objects, %v", *bucketName, err) } for _, u := range uploads.Uploads { - abortReq := svc.AbortMultipartUploadRequest(&s3.AbortMultipartUploadInput{ + abortReq := svc.AbortMultipartUploadRequest(&types.AbortMultipartUploadInput{ Bucket: bucketName, Key: u.Key, UploadId: u.UploadId, @@ -94,7 +95,7 @@ func deleteBucket(svc *s3.Client, bucket string) error { abortReq.Send(context.Background()) } - _, err = svc.DeleteBucketRequest(&s3.DeleteBucketInput{Bucket: bucketName}).Send(context.Background()) + _, err = svc.DeleteBucketRequest(&types.DeleteBucketInput{Bucket: bucketName}).Send(context.Background()) if err != nil { return fmt.Errorf("failed to delete bucket %q, %v", *bucketName, err) } diff --git a/internal/awstesting/integration/performance/s3DownloadManager/main.go b/internal/awstesting/integration/performance/s3DownloadManager/main.go index 84446b92c32..af03cd8f81c 100644 --- a/internal/awstesting/integration/performance/s3DownloadManager/main.go +++ b/internal/awstesting/integration/performance/s3DownloadManager/main.go @@ -17,6 +17,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/internal/sdkio" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" ) @@ -41,7 +42,7 @@ func main() { log.Println("starting download...") start := time.Now() - _, err = downloader.Download(&awstesting.DiscardAt{}, &s3.GetObjectInput{ + _, err = downloader.Download(&awstesting.DiscardAt{}, &types.GetObjectInput{ Bucket: &config.Bucket, Key: &key, }) @@ -120,7 +121,7 @@ func teardownDownloadTest(bucket, key string) error { } svc := s3.New(cfg) - resp := svc.DeleteObjectRequest(&s3.DeleteObjectInput{Bucket: &bucket, Key: &key}) + resp := svc.DeleteObjectRequest(&types.DeleteObjectInput{Bucket: &bucket, Key: &key}) _, err = resp.Send(context.Background()) return err } @@ -182,7 +183,7 @@ func printAttempts(op string, trace *RequestTrace, verbose bool) { func downloadRequestTracer(traces chan<- *RequestTrace) aws.Option { tracerOption := func(r *aws.Request) { id := "op" - if v, ok := r.Params.(*s3.GetObjectInput); ok { + if v, ok := r.Params.(*types.GetObjectInput); ok { if v.Range != nil { id = *v.Range } diff --git a/internal/awstesting/integration/performance/s3UploadManager/main.go b/internal/awstesting/integration/performance/s3UploadManager/main.go index eebd0e391e8..b5938993511 100644 --- a/internal/awstesting/integration/performance/s3UploadManager/main.go +++ b/internal/awstesting/integration/performance/s3UploadManager/main.go @@ -4,7 +4,6 @@ package main import ( "flag" - "github.com/aws/aws-sdk-go-v2/aws/external" "log" "os" "path/filepath" @@ -12,9 +11,11 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var config Config @@ -138,7 +139,7 @@ func printAttempts(op string, trace *RequestTrace, verbose bool) { func uploadRequestTracer(traces chan<- *RequestTrace) aws.Option { tracerOption := func(r *aws.Request) { id := "op" - if v, ok := r.Params.(*s3.UploadPartInput); ok { + if v, ok := r.Params.(*types.UploadPartInput); ok { id = strconv.FormatInt(*v.PartNumber, 10) } tracer := NewRequestTrace(r.Context(), r.Operation.Name, id) diff --git a/internal/awstesting/integration/s3integ/shared.go b/internal/awstesting/integration/s3integ/shared.go index bc345767c2b..7cb35c9c734 100644 --- a/internal/awstesting/integration/s3integ/shared.go +++ b/internal/awstesting/integration/s3integ/shared.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // BucketPrefix is the root prefix of integration test buckets. @@ -22,13 +23,13 @@ func GenerateBucketName() string { // SetupTest returns a test bucket created for the integration tests. func SetupTest(ctx context.Context, svc *s3.Client, bucketName string) (err error) { fmt.Println("Setup: Creating test bucket,", bucketName) - _, err = svc.CreateBucketRequest(&s3.CreateBucketInput{Bucket: &bucketName}).Send(ctx) + _, err = svc.CreateBucketRequest(&types.CreateBucketInput{Bucket: &bucketName}).Send(ctx) if err != nil { return fmt.Errorf("failed to create bucket %s, %v", bucketName, err) } fmt.Println("Setup: Waiting for bucket to exist,", bucketName) - err = svc.WaitUntilBucketExists(ctx, &s3.HeadBucketInput{Bucket: &bucketName}) + err = svc.WaitUntilBucketExists(ctx, &types.HeadBucketInput{Bucket: &bucketName}) if err != nil { return fmt.Errorf("failed waiting for bucket %s to be created, %v", bucketName, err) @@ -40,17 +41,17 @@ func SetupTest(ctx context.Context, svc *s3.Client, bucketName string) (err erro // CleanupTest deletes the contents of a S3 bucket, before deleting the bucket // it self. func CleanupTest(ctx context.Context, svc *s3.Client, bucketName string) error { - errs := []error{} + var errs []error fmt.Println("TearDown: Deleting objects from test bucket,", bucketName) listReq := svc.ListObjectsRequest( - &s3.ListObjectsInput{Bucket: &bucketName}, + &types.ListObjectsInput{Bucket: &bucketName}, ) listObjPager := s3.NewListObjectsPaginator(listReq) for listObjPager.Next(ctx) { for _, o := range listObjPager.CurrentPage().Contents { - _, err := svc.DeleteObjectRequest(&s3.DeleteObjectInput{ + _, err := svc.DeleteObjectRequest(&types.DeleteObjectInput{ Bucket: &bucketName, Key: o.Key, }).Send(ctx) @@ -66,13 +67,13 @@ func CleanupTest(ctx context.Context, svc *s3.Client, bucketName string) error { fmt.Println("TearDown: Deleting partial uploads from test bucket,", bucketName) listMPReq := svc.ListMultipartUploadsRequest( - &s3.ListMultipartUploadsInput{Bucket: &bucketName}, + &types.ListMultipartUploadsInput{Bucket: &bucketName}, ) listMPPager := s3.NewListMultipartUploadsPaginator(listMPReq) for listMPPager.Next(ctx) { for _, u := range listMPPager.CurrentPage().Uploads { - svc.AbortMultipartUploadRequest(&s3.AbortMultipartUploadInput{ + svc.AbortMultipartUploadRequest(&types.AbortMultipartUploadInput{ Bucket: &bucketName, Key: u.Key, UploadId: u.UploadId, @@ -89,7 +90,7 @@ func CleanupTest(ctx context.Context, svc *s3.Client, bucketName string) error { } fmt.Println("TearDown: Deleting test bucket,", bucketName) - if _, err := svc.DeleteBucketRequest(&s3.DeleteBucketInput{ + if _, err := svc.DeleteBucketRequest(&types.DeleteBucketInput{ Bucket: &bucketName, }).Send(ctx); err != nil { return fmt.Errorf("failed to delete test bucket, %s", bucketName) diff --git a/models/protocol_tests/generate.go b/models/protocol_tests/generate.go index d648fcdd01a..b55463633de 100644 --- a/models/protocol_tests/generate.go +++ b/models/protocol_tests/generate.go @@ -592,6 +592,8 @@ func getType(t string) uint { func main() { fmt.Println("Generating test suite", os.Args[1:]) out := generateTestSuite(os.Args[1]) + + // Todo: fix test suites if len(os.Args) == 3 { f, err := os.Create(os.Args[2]) defer f.Close() diff --git a/private/model/api/api.go b/private/model/api/api.go index 431b2b62e8f..2536a7d1918 100644 --- a/private/model/api/api.go +++ b/private/model/api/api.go @@ -6,6 +6,7 @@ package api import ( "bytes" "fmt" + "log" "path" "regexp" "sort" @@ -16,6 +17,8 @@ import ( // SDKImportRoot is the root import path of the SDK. const SDKImportRoot = "github.com/aws/aws-sdk-go-v2" +const ServiceTypesPkgName = "types" +const ServiceEnumsPkgName = "enums" // An API defines a service API's definition. and logic to serialize the definition. type API struct { @@ -198,7 +201,7 @@ func (a *API) ShapeList() []*Shape { // ShapeListErrors returns a list of the errors defined by the API model func (a *API) ShapeListErrors() []*Shape { - list := []*Shape{} + var list []*Shape for _, n := range a.ShapeNames() { // Ignore error shapes in list if s := a.Shapes[n]; s.IsError { @@ -209,7 +212,7 @@ func (a *API) ShapeListErrors() []*Shape { } func (a *API) ShapeEnumList() []*Shape { - list := []*Shape{} + var list []*Shape for _, n := range a.ShapeNames() { // Ignore error shapes in list if s := a.Shapes[n]; s.IsEnum() { @@ -302,7 +305,7 @@ func (a *API) APIGoCode() string { a.AddSDKImport("private/protocol") } if !a.NoGenMarshalers || !a.NoGenUnmarshalers { - a.AddSDKImport("private/protocol") + a.imports[path.Join(SDKImportRoot, "private/protocol")] = true } var buf bytes.Buffer @@ -319,23 +322,33 @@ func (a *API) APIGoCode() string { // string. func (a *API) APIOperationGoCode(op *Operation) string { a.resetImports() - a.AddSDKImport("aws") - a.AddSDKImport("internal/awsutil") a.AddImport("context") + a.AddSDKImport("aws") + a.AddSDKImport("service", a.PackageName(), ServiceTypesPkgName) if op.OutputRef.Shape.Placeholder { a.AddSDKImport("private/protocol", a.ProtocolPackage()) a.AddSDKImport("private/protocol") } - if !a.NoGenMarshalers || !a.NoGenUnmarshalers { - a.AddSDKImport("private/protocol") - } // Need to generate code before imports are generated. code := op.GoCode() return a.importsGoCode() + code } +// APIOperationTypesGoCode renders the Operation types in Go code. Returning it as a +// string. +func (a *API) APIOperationTypeGoCode(op *Operation) string { + a.resetImports() + a.AddSDKImport("internal/awsutil") + + if !a.NoGenMarshalers || !a.NoGenUnmarshalers { + a.AddSDKImport("private/protocol") + } + code := op.IOGoCode() + return a.importsGoCode() + code +} + // APIEnumsGoCode renders the API's enumerations in Go code. Returning them as // a string. func (a *API) APIEnumsGoCode() string { @@ -365,8 +378,6 @@ var tplAPIShapes = template.Must(template.New("api").Parse(` // them as a string. func (a *API) APIParamShapesGoCode() string { a.resetImports() - a.AddSDKImport("aws") - a.AddSDKImport("internal/awsutil") if (!a.NoGenMarshalers || !a.NoGenUnmarshalers) && (a.hasNonIOShapes()) { a.AddSDKImport("private/protocol") @@ -378,13 +389,7 @@ func (a *API) APIParamShapesGoCode() string { panic(err) } - // TODO this is hacky, imports should only be added when needed. - importStubs := ` - var _ aws.Config - var _ = awsutil.Prettify - ` - - code := a.importsGoCode() + importStubs + strings.TrimSpace(buf.String()) + code := a.importsGoCode() + strings.TrimSpace(buf.String()) return code } @@ -496,6 +501,26 @@ func (a *API) ServiceID() string { return a.serviceID } +func (a *API) ProtocolCanonicalPackageName() string { + switch a.Metadata.Protocol { + case "rest-xml": + return "aws_restxml" + case "rest-json": + return "aws_restjson" + case "ec2": + return "aws_ec2query" + case "query": + return "aws_query" + case "xml": + return "aws_xml" + case "json": + return "aws_jsonrpc" + default: + log.Fatalf("unknown protocol name %v, in package %v", a.Metadata.Protocol, a.PackageName()) + } + return "" +} + var tplServiceDoc = template.Must(template.New("service docs").Funcs(template.FuncMap{ "GetCrosslinkURL": GetCrosslinkURL, }). @@ -706,30 +731,21 @@ func (a *API) ServiceGoCode() string { // ExampleGoCode renders service example code. Returning it as a string. func (a *API) ExampleGoCode() string { - exs := []string{} - imports := map[string]bool{} + var exs []string for _, o := range a.OperationList() { o.imports = map[string]bool{} exs = append(exs, o.Example()) for k, v := range o.imports { - imports[k] = v + if v { + a.AddImport(k) + } } } - code := fmt.Sprintf("import (\n%q\n%q\n%q\n\n%q\n%q\n", - "bytes", - "fmt", - "time", - SDKImportRoot+"/aws", - a.ImportPath(), - ) - for k := range imports { - code += fmt.Sprintf("%q\n", k) - } - code += ")\n\n" - code += "var _ time.Duration\nvar _ bytes.Buffer\n\n" - code += strings.Join(exs, "\n\n") - return code + a.AddImport("fmt") + a.AddSDKImport("aws") + + return a.importsGoCode() } // A tplInterface defines the template for the service interface type. @@ -803,6 +819,7 @@ func (a *API) InterfaceGoCode() string { a.AddSDKImport("aws") } a.AddImport(a.ImportPath()) + a.AddSDKImport("service", a.PackageName(), ServiceTypesPkgName) var buf bytes.Buffer err := tplInterface.Execute(&buf, a) @@ -837,7 +854,7 @@ func resolveShapeValidations(s *Shape, ancestry ...*Shape) { } } - children := []string{} + var children []string for _, name := range s.MemberNames() { ref := s.MemberRefs[name] diff --git a/private/model/api/customization_passes.go b/private/model/api/customization_passes.go index 7cb793395e9..96970027557 100644 --- a/private/model/api/customization_passes.go +++ b/private/model/api/customization_passes.go @@ -4,9 +4,7 @@ package api import ( "fmt" - "io/ioutil" "os" - "path/filepath" "strings" ) @@ -17,20 +15,8 @@ type service struct { serviceVersion string } -var mergeServices = map[string]service{ - "dynamodbstreams": { - dstName: "dynamodb", - srcName: "streams.dynamodb", - }, - "wafregional": { - dstName: "waf", - srcName: "waf-regional", - serviceVersion: "2015-08-24", - }, -} - func (a *API) EnableSelectGeneratedMarshalers() { - // Selectivily enable generated marshalers as available + // Selectively enable generated marshalers as available a.NoGenMarshalers = true a.NoGenUnmarshalers = true @@ -67,10 +53,6 @@ func (a *API) customizationPasses() { ), } - for k := range mergeServices { - svcCustomizations[k] = mergeServicesCustomizations - } - if fn := svcCustomizations[a.PackageName()]; fn != nil { fn(a) } @@ -170,38 +152,6 @@ func cloudfrontCustomizations(a *API) { } } -// mergeServicesCustomizations references any duplicate shapes from DynamoDB -func mergeServicesCustomizations(a *API) { - info := mergeServices[a.PackageName()] - - p := strings.Replace(a.path, info.srcName, info.dstName, -1) - - if info.serviceVersion != "" { - index := strings.LastIndex(p, "/") - files, _ := ioutil.ReadDir(p[:index]) - if len(files) > 1 { - panic("New version was introduced") - } - p = p[:index] + "/" + info.serviceVersion - } - - file := filepath.Join(p, "api-2.json") - - serviceAPI := API{} - serviceAPI.Attach(file) - serviceAPI.Setup() - - for n := range a.Shapes { - if _, ok := serviceAPI.Shapes[n]; ok { - // Input and output shapes must remain unique. - if s := a.Shapes[n]; s.UsedAsInput || s.UsedAsOutput { - continue - } - a.Shapes[n].resolvePkg = "github.com/aws/aws-sdk-go-v2/service/" + info.dstName - } - } -} - // rdsCustomizations are customization for the service/rds. This adds non-modeled fields used for presigning. func rdsCustomizations(a *API) { inputs := []string{ diff --git a/private/model/api/example.go b/private/model/api/example.go index 0b41bc02519..3806804f064 100644 --- a/private/model/api/example.go +++ b/private/model/api/example.go @@ -134,7 +134,7 @@ func (ex Example) GoCode() string { func generateExampleInput(ex Example) string { if ex.Operation.HasInput() { return fmt.Sprintf("&%s{\n%s\n}\n", - ex.Builder.GoType(&ex.Operation.InputRef, true), + ex.Operation.InputRef.Shape.GoTypeWithPkgNameElem(), ex.Builder.BuildShape(&ex.Operation.InputRef, ex.Input, false, false), ) } @@ -227,17 +227,8 @@ func (a *API) AttachExamples(filename string) { p.setup() } -var examplesBuilderCustomizations = map[string]examplesBuilder{ - "wafregional": wafregionalExamplesBuilder{}, -} - func (p *ExamplesDefinition) setup() { - var builder examplesBuilder - ok := false - if builder, ok = examplesBuilderCustomizations[p.API.PackageName()]; !ok { - builder = defaultExamplesBuilder{} - } - + builder := defaultExamplesBuilder{} keys := p.Examples.Names() for _, n := range keys { examples := p.Examples[n] @@ -260,12 +251,8 @@ func (p *ExamplesDefinition) setup() { p.API.Examples = p.Examples } -var exampleHeader = template.Must(template.New("exampleHeader").Parse(` -import ( - {{ .Builder.Imports .API }} -) - -var _ time.Duration +var exampleHeader = template.Must(template.New("exampleHeader"). + Parse(`var _ time.Duration var _ strings.Reader var _ aws.Config @@ -288,11 +275,19 @@ type exHeader struct { // examples.json file. func (a *API) ExamplesGoCode() string { var buf bytes.Buffer - var builder examplesBuilder - ok := false - if builder, ok = examplesBuilderCustomizations[a.PackageName()]; !ok { - builder = defaultExamplesBuilder{} - } + builder := defaultExamplesBuilder{} + + a.resetImports() + a.AddImport("fmt") + a.AddImport("context") + a.AddImport("strings") + a.AddImport("time") + + a.AddSDKImport("aws") + a.AddSDKImport("aws/awserr") + a.AddSDKImport("aws/external") + a.AddSDKImport("service", a.PackageName()) + a.AddSDKImport("service", a.PackageName(), "types") if err := exampleHeader.ExecuteTemplate(&buf, "exampleHeader", &exHeader{builder, a}); err != nil { panic(err) @@ -304,7 +299,7 @@ func (a *API) ExamplesGoCode() string { } buf.WriteString(code) - return buf.String() + return a.importsGoCode() + buf.String() } // TODO: In the operation docuentation where we list errors, this needs to be done diff --git a/private/model/api/example_test.go b/private/model/api/example_test.go index 6ade182329d..cb269f79444 100644 --- a/private/model/api/example_test.go +++ b/private/model/api/example_test.go @@ -123,10 +123,9 @@ func TestExampleGeneration(t *testing.T) { def.API = a def.setup() - expected := ` -import ( - "fmt" + expected := `import ( "context" + "fmt" "strings" "time" @@ -134,7 +133,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/fooservice" - + "github.com/aws/aws-sdk-go-v2/service/fooservice/types" ) var _ time.Duration @@ -159,7 +158,7 @@ func ExampleClient_FooRequest_shared00() { } svc := fooservice.New(cfg) - input := &fooservice.FooInput{ + input := &types.FooInput{ BarShape: aws.String("Hello world"), } diff --git a/private/model/api/examples_builder.go b/private/model/api/examples_builder.go index b98ef736642..5e83f10c4c7 100644 --- a/private/model/api/examples_builder.go +++ b/private/model/api/examples_builder.go @@ -2,34 +2,13 @@ package api -import ( - "bytes" -) - type examplesBuilder interface { BuildShape(*ShapeRef, map[string]interface{}, bool, bool) string BuildList(string, string, *ShapeRef, []interface{}) string BuildComplex(string, string, *ShapeRef, map[string]interface{}, bool) string GoType(*ShapeRef, bool) string - Imports(*API) string } type defaultExamplesBuilder struct { ShapeValueBuilder } - -func (builder defaultExamplesBuilder) Imports(a *API) string { - buf := bytes.NewBuffer(nil) - buf.WriteString(`"fmt" - "context" - "strings" - "time" - - "` + SDKImportRoot + `/aws" - "` + SDKImportRoot + `/aws/awserr" - "` + SDKImportRoot + `/aws/external" - "` + a.ImportPath() + `" - `) - - return buf.String() -} diff --git a/private/model/api/examples_builder_customizations.go b/private/model/api/examples_builder_customizations.go deleted file mode 100644 index b78dd186cb5..00000000000 --- a/private/model/api/examples_builder_customizations.go +++ /dev/null @@ -1,28 +0,0 @@ -// +build codegen - -package api - -import ( - "bytes" -) - -type wafregionalExamplesBuilder struct { - defaultExamplesBuilder -} - -func (builder wafregionalExamplesBuilder) Imports(a *API) string { - buf := bytes.NewBuffer(nil) - buf.WriteString(`"fmt" - "context" - "strings" - "time" - - "` + SDKImportRoot + `/aws" - "` + SDKImportRoot + `/aws/awserr" - "` + SDKImportRoot + `/aws/external" - "` + SDKImportRoot + `/service/waf" - "` + a.ImportPath() + `" - `) - - return buf.String() -} diff --git a/private/model/api/load.go b/private/model/api/load.go index 356bbe5abde..341358aa174 100644 --- a/private/model/api/load.go +++ b/private/model/api/load.go @@ -93,7 +93,7 @@ func attachModelFiles(modelPath string, modelFiles ...modelLoader) error { // Or with specific model file: // models/apis/service/version/api-2.json func ExpandModelGlobPath(globs ...string) ([]string, error) { - modelPaths := []string{} + var modelPaths []string for _, g := range globs { filepaths, err := filepath.Glob(g) @@ -161,6 +161,7 @@ func (a *API) AttachString(str string) { } } +// setup completes all customizations and passes. // Setup initializes the API. func (a *API) Setup() { a.setMetadataEndpointsKey() @@ -172,6 +173,7 @@ func (a *API) Setup() { } a.fixStutterNames() + a.validateShapeNames() a.renameExportable() a.applyShapeNameAliases() a.createInputOutputShapes() @@ -184,6 +186,7 @@ func (a *API) Setup() { a.customizationPasses() a.injectUnboundedOutputStreaming() + // possible duplicate if !a.NoRemoveUnusedShapes { a.removeUnusedShapes() } diff --git a/private/model/api/operation.go b/private/model/api/operation.go index 2cbf0ac28c7..0112fe38098 100644 --- a/private/model/api/operation.go +++ b/private/model/api/operation.go @@ -92,14 +92,6 @@ var operationTmpl = template.Must(template.New("operation").Funcs(template.FuncM {{ $respType := printf "%sResponse" .ExportedName -}} {{ $pagerType := printf "%sPaginator" .ExportedName -}} -{{ if .HasInput -}} - {{ .InputRef.Shape.GoCode }} -{{- end }} - -{{ if .HasOutput -}} - {{ .OutputRef.Shape.GoCode }} -{{- end }} - const op{{ .ExportedName }} = "{{ .Name }}" // {{ $reqType }} returns a request value for making API operation for @@ -120,7 +112,7 @@ const op{{ .ExportedName }} = "{{ .Name }}" // // Please also see {{ $crosslinkURL }} {{ end -}} -func (c *{{ .API.StructName }}) {{ $reqType }}(input {{ .InputRef.GoType }}) ({{ $reqType }}) { +func (c *{{ .API.StructName }}) {{ $reqType }}(input {{ .InputRef.GoTypeWithPkgName }}) ({{ $reqType }}) { {{ if (or .Deprecated (or .InputRef.Deprecated .OutputRef.Deprecated)) -}} if c.Client.Config.Logger != nil { c.Client.Config.Logger.Log("This operation, {{ .ExportedName }}, has been deprecated") @@ -142,10 +134,11 @@ func (c *{{ .API.StructName }}) {{ $reqType }}(input {{ .InputRef.GoType }}) ({{ } if input == nil { - input = &{{ .InputRef.GoTypeElem }}{} + input = &{{ .InputRef.GoTypeWithPkgNameElem }}{} } - - req := c.newRequest(op, input, &{{ .OutputRef.GoTypeElem }}{}) + + {{ $operationMarshalerName := printf "%sMarshaler" $.ExportedName -}} + req := c.newRequest(op, input, &{{ .OutputRef.GoTypeWithPkgNameElem }}{}) {{ if eq .OutputRef.Shape.Placeholder true -}} req.Handlers.Unmarshal.Remove({{ .API.ProtocolPackage }}.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) @@ -163,8 +156,8 @@ func (c *{{ .API.StructName }}) {{ $reqType }}(input {{ .InputRef.GoType }}) ({{ // {{ .ExportedName }} API operation. type {{ $reqType}} struct { *aws.Request - Input {{ .InputRef.GoType }} - Copy func({{ .InputRef.GoType }}) {{ $reqType }} + Input {{ .InputRef.GoTypeWithPkgName }} + Copy func({{ .InputRef.GoTypeWithPkgName }}) {{ $reqType }} } // Send marshals and sends the {{ .ExportedName }} API request. @@ -177,7 +170,7 @@ func (r {{ $reqType }}) Send(ctx context.Context) (*{{ $respType }}, error) { resp := &{{ $respType }}{ {{ if .HasOutput -}} - {{ .OutputRef.GoTypeElem }}: r.Request.Data.({{ .OutputRef.GoType }}), + {{ .OutputRef.GoTypeElem }}: r.Request.Data.({{ .OutputRef.GoTypeWithPkgName }}), {{- end }} response: &aws.Response{Request: r.Request}, } @@ -209,7 +202,7 @@ func (r {{ $reqType }}) Send(ctx context.Context) (*{{ $respType }}, error) { return {{ $pagerType }}{ Pager: aws.Pager { NewRequest: func(ctx context.Context) (*aws.Request, error) { - var inCpy {{ .InputRef.GoType }} + var inCpy {{ .InputRef.GoTypeWithPkgName }} if req.Input != nil { tmp := *req.Input inCpy = &tmp @@ -229,8 +222,8 @@ func (r {{ $reqType }}) Send(ctx context.Context) (*{{ $respType }}, error) { aws.Pager } - func (p *{{ $pagerType}}) CurrentPage() {{ .OutputRef.GoType }} { - return p.Pager.CurrentPage().({{ .OutputRef.GoType }}) + func (p *{{ $pagerType}}) CurrentPage() {{ .OutputRef.GoTypeWithPkgName }} { + return p.Pager.CurrentPage().({{ .OutputRef.GoTypeWithPkgName }}) } {{ end }} @@ -238,7 +231,7 @@ func (r {{ $reqType }}) Send(ctx context.Context) (*{{ $respType }}, error) { // {{ .ExportedName }} API operation. type {{ $respType }} struct { {{ if .HasOutput -}} - {{ .OutputRef.GoType }} + {{ .OutputRef.GoTypeWithPkgName }} {{- end }} response *aws.Response @@ -251,6 +244,17 @@ func (r * {{ $respType }}) SDKResponseMetdata() *aws.Response { } `)) +var operationIOTypeTmpl = template.Must(template.New("operationIOType").Parse( + ` +{{ if .HasInput -}} + {{ .InputRef.Shape.GoCode }} +{{- end }} + +{{ if .HasOutput -}} + {{ .OutputRef.Shape.GoCode }} +{{- end }} +`)) + // GoCode returns a string of rendered GoCode for this Operation func (o *Operation) GoCode() string { if o.Endpoint != nil && len(o.Endpoint.HostPrefix) != 0 { @@ -266,6 +270,18 @@ func (o *Operation) GoCode() string { return strings.TrimSpace(buf.String()) } +// IOGoCode returns a string of rendered GoCode for this Operations Input, Output type +func (o *Operation) IOGoCode() string { + + var buf bytes.Buffer + err := operationIOTypeTmpl.Execute(&buf, o) + if err != nil { + panic(err) + } + + return strings.TrimSpace(buf.String()) +} + // tplInfSig defines the template for rendering an Operation's signature within an Interface definition. var tplInfSig = template.Must(template.New("opsig").Parse(`{{ .ExportedName }}Request({{ .InputRef.GoTypeWithPkgName }}) {{ .API.PackageName }}.{{ .ExportedName }}Request `)) diff --git a/private/model/api/passes.go b/private/model/api/passes.go index cbc3a8d196e..6860bef42ac 100644 --- a/private/model/api/passes.go +++ b/private/model/api/passes.go @@ -4,8 +4,10 @@ package api import ( "fmt" + "log" "regexp" "strings" + "unicode" ) // updateTopLevelShapeReferences moves resultWrapper, locationName, and @@ -158,6 +160,38 @@ func (a *API) fixStutterNames() { } } +func (a *API) validateShapeNames() { + for _, s := range a.Shapes { + // name should start with an alphabet, that is ascii character 65 to 90, and 97 to 122; + // else skip that character + name := s.ShapeName + for len(name) > 1 { + if (s.Type == "structure" || s.IsEnum()) && !unicode.IsLetter(rune(name[0])) { + // Remove the leading underscores from the name of the shape, if shape is enum or structure + if name[0] == '_' { + name = name[1:] + } else { + // Throw an error if shape name starts with non alphabetic character and + // above condition is unsatisfied. + log.Fatalf("Shape starting with non alphabetical character found: %v", s.ShapeName) + } + } else { + break + } + } + + if s.ShapeName != name { + debugLogger.Logf("Renamed shape %v to %v for package %v \n", s.ShapeName, name, a.PackageName()) + if a.Shapes[name] != nil { + // throw an error if shape with a new shape name already exists + log.Fatalf("Tried to rename shape %v to %v, but the new name results in shape name collision", + s.ShapeName, name) + } + s.Rename(name) + } + } +} + func (a *API) applyShapeNameAliases() { service, ok := shapeNameAliases[a.ServiceID()] if !ok { diff --git a/private/model/api/s3manager_input.go b/private/model/api/s3manager_input.go index dec3386f752..0a24d258293 100644 --- a/private/model/api/s3manager_input.go +++ b/private/model/api/s3manager_input.go @@ -21,7 +21,7 @@ func S3ManagerUploadInputGoCode(a *API) string { a.resetImports() a.AddImport("io") a.AddImport("time") - a.AddSDKImport("service/s3") + a.AddSDKImport("service", "s3", ServiceEnumsPkgName) var w bytes.Buffer if err := s3managerUploadInputTmpl.Execute(&w, s); err != nil { panic(fmt.Sprintf("failed to execute %s template, %v", diff --git a/private/model/api/shape.go b/private/model/api/shape.go index 3489d99bc55..739bafe99bc 100644 --- a/private/model/api/shape.go +++ b/private/model/api/shape.go @@ -287,6 +287,12 @@ func (s *Shape) GoStructType(name string, ref *ShapeRef) string { } } + // check if enum needs to be imported + if ref.Shape.IsEnum() || (ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.IsEnum()) || + (ref.Shape.ValueRef.Shape != nil && ref.Shape.ValueRef.Shape.IsEnum()) { + s.API.AddSDKImport("service", s.API.PackageName(), ServiceEnumsPkgName) + return ref.GoTypeWithPkgName() + } return ref.GoType() } @@ -305,7 +311,7 @@ func (ref *ShapeRef) GoType() string { } // GoTypeWithPkgName returns a shape's type as a string with the package name in -// . format. Package naming only applies to structures. +// . format. func (ref *ShapeRef) GoTypeWithPkgName() string { if ref.Shape == nil { panic(fmt.Errorf("missing shape definition on reference for %#v", ref)) @@ -314,14 +320,27 @@ func (ref *ShapeRef) GoTypeWithPkgName() string { return ref.Shape.GoTypeWithPkgName() } +// GoTypeWithPkgNameElem returns a value based shape's type with package name . +func (ref *ShapeRef) GoTypeWithPkgNameElem() string { + if ref.Shape == nil { + panic(fmt.Errorf("missing shape definition on reference for %#v", ref)) + } + + return ref.Shape.GoTypeWithPkgNameElem() +} + // Get's the package name of the specific shape func getPkgName(s *Shape) string { pkg := s.resolvePkg if pkg != "" { s.API.imports[pkg] = true pkg = path.Base(pkg) - } else { + } else if s.IsError { pkg = s.API.PackageName() + } else if s.IsEnum() { + pkg = ServiceEnumsPkgName + } else { + pkg = ServiceTypesPkgName } return pkg @@ -330,25 +349,18 @@ func getPkgName(s *Shape) string { // Returns a string version of the Shape's type. // If withPkgName is true, the package name will be added as a prefix func goType(s *Shape, withPkgName, pointer bool) string { - if s.IsEnum() { - name := s.EnumType() - if withPkgName { - pkg := getPkgName(s) - name = fmt.Sprintf("%s.%s", pkg, name) - } - return name - } - prefix := "" if pointer { prefix = "*" } + var pkgName string + pkgName = getPkgName(s) + switch s.Type { case "structure": if withPkgName || s.resolvePkg != "" { - pkg := getPkgName(s) - return fmt.Sprintf("%s%s.%s", prefix, pkg, s.ShapeName) + return fmt.Sprintf("%s%s.%s", prefix, pkgName, s.ShapeName) } return prefix + s.ShapeName case "map": @@ -360,6 +372,13 @@ func goType(s *Shape, withPkgName, pointer bool) string { case "boolean": return prefix + "bool" case "string", "character": + if s.IsEnum() { + s.API.AddSDKImport("service", s.API.PackageName(), ServiceEnumsPkgName) + if withPkgName { + return fmt.Sprintf("%s.%s", pkgName, s.EnumType()) + } + return s.EnumType() + } return prefix + "string" case "blob": return "[]byte" @@ -552,6 +571,10 @@ func (s {{ .ShapeName }}) String() string { // GoCodeStringers renders the Stringers for API input/output shapes func (s *Shape) GoCodeStringers() string { w := bytes.Buffer{} + + // Add import for awsutil + s.API.AddSDKImport("internal/awsutil") + if err := goCodeStringerTmpl.Execute(&w, s); err != nil { panic(fmt.Sprintln("Unexpected error executing GoCodeStringers template", err)) } @@ -674,7 +697,7 @@ type {{ .ShapeName }} struct { {{ $elem := index $.MemberRefs $name -}} {{ if $elem.GenerateGetter -}} -func (s *{{ $builderShapeName }}) get{{ $name }}() (v {{ $.GoStructValueType $name $elem }}) { +func (s *{{ $builderShapeName }}) Get{{ $name }}() (v {{ $.GoStructValueType $name $elem }}) { {{ if $elem.UseIndirection -}} if s.{{ $name }} == nil { return v diff --git a/private/model/api/shape_validation.go b/private/model/api/shape_validation.go index 6c2ecc4e273..ad981b89e9d 100644 --- a/private/model/api/shape_validation.go +++ b/private/model/api/shape_validation.go @@ -163,6 +163,9 @@ func (vs ShapeValidations) GoCode(shape *Shape) string { "Shape": shape, "Validations": vs, }) + + // Add sdk import for aws pkg + shape.API.AddSDKImport("aws") return buf.String() } diff --git a/private/model/api/shape_value_builder.go b/private/model/api/shape_value_builder.go index 561fdc674a9..1c19644386f 100644 --- a/private/model/api/shape_value_builder.go +++ b/private/model/api/shape_value_builder.go @@ -29,7 +29,7 @@ func (b ShapeValueBuilder) BuildShape(ref *ShapeRef, shapes map[string]interface } shape := shapes[name] - // If the shape isn't a map, we want to export the value, since every field + // If the shapeBuildShape isn't a map, we want to export the value, since every field // defined in our shapes are exported. if len(name) > 0 && !isMap && strings.ToLower(name[0:1]) == name[0:1] { name = strings.Title(name) @@ -71,22 +71,22 @@ func (b ShapeValueBuilder) BuildList(name, memName string, ref *ShapeRef, v []in if ref.Shape.MemberRefs[name] != nil { isEnum = ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.IsEnum() - t = b.GoType(&ref.Shape.MemberRefs[name].Shape.MemberRef, true) + t = b.GoTypeWithPkgName(&ref.Shape.MemberRefs[name].Shape.MemberRef, true) dataType = ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type passRef = ref.Shape.MemberRefs[name] if dataType == "map" { - t = fmt.Sprintf("map[string]%s", b.GoType(&ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef, true)) + t = fmt.Sprintf("map[string]%s", b.GoTypeWithPkgName(&ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef, true)) passRef = &ref.Shape.MemberRefs[name].Shape.MemberRef.Shape.ValueRef isMap = true } } else if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil { isEnum = ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef.Shape.IsEnum() - t = b.GoType(&ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef, true) + t = b.GoTypeWithPkgName(&ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef, true) dataType = ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef.Shape.Type passRef = &ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.MemberRef } else { isEnum = ref.Shape.MemberRef.Shape.IsEnum() - t = b.GoType(&ref.Shape.MemberRef, true) + t = b.GoTypeWithPkgName(&ref.Shape.MemberRef, true) dataType = ref.Shape.MemberRef.Shape.Type passRef = &ref.Shape.MemberRef } @@ -141,14 +141,14 @@ func (b ShapeValueBuilder) BuildScalar(name, memName string, ref *ShapeRef, shap if ref.Shape.MemberRef.Shape != nil && ref.Shape.MemberRef.Shape.MemberRefs[name] != nil { if ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.IsEnum() { refTemp := ref.Shape.MemberRef.Shape.MemberRefs[name] - return fmt.Sprintf("%s: %s, \n", memName, getEnumName(refTemp, b.GoType(refTemp, true), shape.(string))) + return fmt.Sprintf("%s: %s, \n", memName, getEnumName(refTemp, b.GoTypeWithPkgName(refTemp, true), shape.(string))) } return correctType(memName, ref.Shape.MemberRef.Shape.MemberRefs[name].Shape.Type, shape, parentCollection) } if ref.Shape.Type != "structure" && ref.Shape.Type != "map" { if ref.Shape.IsEnum() { - return fmt.Sprintf("%s: %s, \n", memName, getEnumName(ref, b.GoType(ref, true), shape.(string))) + return fmt.Sprintf("%s: %s, \n", memName, getEnumName(ref, b.GoTypeWithPkgName(ref, true), shape.(string))) } return correctType(memName, ref.Shape.Type, shape, parentCollection) } @@ -173,7 +173,7 @@ func (b ShapeValueBuilder) BuildScalar(name, memName string, ref *ShapeRef, shap t := ref.Shape.MemberRefs[name].Shape.Type if ref.Shape.MemberRefs[name].Shape.IsEnum() { - return fmt.Sprintf("%s: %s,\n", memName, getEnumName(ref.Shape.MemberRefs[name], b.GoType(ref.Shape.MemberRefs[name], false), shape.(string))) + return fmt.Sprintf("%s: %s,\n", memName, getEnumName(ref.Shape.MemberRefs[name], b.GoTypeWithPkgName(ref.Shape.MemberRefs[name], false), shape.(string))) } switch t { @@ -227,12 +227,12 @@ func (b ShapeValueBuilder) BuildComplex(name, memName string, ref *ShapeRef, v m return fmt.Sprintf(`%s: %s%s{ %s }, - `, memName, mem, b.GoType(passRef, true), b.BuildShape(passRef, v, false, false)) + `, memName, mem, b.GoTypeWithPkgName(passRef, true), b.BuildShape(passRef, v, false, false)) case "map": return fmt.Sprintf(`%s: %s{ %s }, - `, name, b.GoType(ref.Shape.MemberRefs[name], true), b.BuildShape(&ref.Shape.MemberRefs[name].Shape.ValueRef, v, true, true)) + `, name, b.GoTypeWithPkgName(ref.Shape.MemberRefs[name], true), b.BuildShape(&ref.Shape.MemberRefs[name].Shape.ValueRef, v, true, true)) } return "" @@ -244,6 +244,19 @@ func (b ShapeValueBuilder) GoType(ref *ShapeRef, elem bool) string { ref = &ref.Shape.MemberRef } + if elem { + return ref.Shape.GoTypeElem() + } + + return ref.GoType() +} + +// GoType returns the string of the shape's Go type identifier. +func (b ShapeValueBuilder) GoTypeWithPkgName(ref *ShapeRef, elem bool) string { + if ref.Shape.Type == "list" { + ref = &ref.Shape.MemberRef + } + if elem { return ref.Shape.GoTypeWithPkgNameElem() } @@ -252,12 +265,11 @@ func (b ShapeValueBuilder) GoType(ref *ShapeRef, elem bool) string { } func getEnumName(ref *ShapeRef, t, name string) string { - pkg := getPkgName(ref.Shape) + ref.API.AddSDKImport("service", ref.API.PackageName(), ServiceEnumsPkgName) for i, enum := range ref.Shape.Enum { if name == enum { - return fmt.Sprintf("%s.%s", pkg, ref.Shape.EnumConsts[i]) + return fmt.Sprintf("%s.%s", ServiceEnumsPkgName, ref.Shape.EnumConsts[i]) } } - return fmt.Sprintf("%s(%q)", t, name) } diff --git a/private/model/api/smoke.go b/private/model/api/smoke.go index e09afad6ad8..3141d091586 100644 --- a/private/model/api/smoke.go +++ b/private/model/api/smoke.go @@ -29,7 +29,7 @@ type SmokeTestCase struct { func (c SmokeTestCase) BuildInputShape(ref *ShapeRef) string { var b ShapeValueBuilder return fmt.Sprintf("&%s{\n%s\n}", - b.GoType(ref, true), + b.GoTypeWithPkgName(ref, true), b.BuildShape(ref, c.Input, false, false), ) } @@ -59,10 +59,12 @@ func (a *API) APISmokeTestsGoCode() string { a.AddImport("context") a.AddImport("testing") a.AddImport("time") + a.AddSDKImport("aws") a.AddSDKImport("aws/awserr") a.AddSDKImport("internal/awstesting/integration") a.AddImport(a.ImportPath()) + a.AddSDKImport("service", a.PackageName(), ServiceTypesPkgName) if len(a.SmokeTests.TestCases) != 0 { a.AddSDKImport("aws/defaults") } diff --git a/private/model/api/waiters.go b/private/model/api/waiters.go index ba02f8fe357..d34f120c225 100644 --- a/private/model/api/waiters.go +++ b/private/model/api/waiters.go @@ -45,16 +45,17 @@ type Waiter struct { // this API. func (a *API) WaitersGoCode() string { var buf bytes.Buffer - fmt.Fprintf(&buf, "import (\n%q\n%q\n\n%q\n)", - "time", - "context", - SDKImportRoot+"/aws", - ) + + a.resetImports() + a.AddSDKImport("service", a.PackageName(), "types") + a.AddSDKImport("aws") + a.AddImport("time") + a.AddImport("context") for _, w := range a.Waiters { buf.WriteString(w.GoCode()) } - return buf.String() + return a.importsGoCode() + buf.String() } // used for unmarshaling from the waiter JSON file @@ -121,7 +122,7 @@ var waiterTmpls = template.Must(template.New("waiterTmpls").Funcs( // sub-contexts for http.Requests. See https://golang.org/pkg/context/ // for more information on using Contexts. func (c *{{ .Operation.API.StructName }}) WaitUntil{{ .Name }}(` + - `ctx context.Context, input {{ .Operation.InputRef.GoType }}, opts ...aws.WaiterOption) error { + `ctx context.Context, input {{ .Operation.InputRef.GoTypeWithPkgName }}, opts ...aws.WaiterOption) error { w := aws.Waiter{ Name: "WaitUntil{{ .Name }}", MaxAttempts: {{ .MaxAttempts }}, @@ -137,7 +138,7 @@ func (c *{{ .Operation.API.StructName }}) WaitUntil{{ .Name }}(` + }, Logger: c.Config.Logger, NewRequest: func(opts []aws.Option) (*aws.Request, error) { - var inCpy {{ .Operation.InputRef.GoType }} + var inCpy {{ .Operation.InputRef.GoTypeWithPkgName }} if input != nil { tmp := *input inCpy = &tmp diff --git a/private/model/cli/gen-api/main.go b/private/model/cli/gen-api/main.go index 32f32db9b42..ce84735c8dd 100644 --- a/private/model/cli/gen-api/main.go +++ b/private/model/cli/gen-api/main.go @@ -73,8 +73,11 @@ func main() { fmt.Fprintln(os.Stderr, "failed to glob file pattern", err) os.Exit(1) } + // Return the latest service version; excludes the service version modelPaths, _ = api.TrimModelServiceVersions(modelPaths) + // Load all the api's for the model path of service + // This include paginators, waiters, service-docs etc. apis, err := api.LoadAPIs(modelPaths, svcImportPath) if err != nil { fmt.Fprintln(os.Stderr, "failed to load API models", err) @@ -111,6 +114,8 @@ func main() { // Create the output path for the model. pkgDir := filepath.Join(svcPath, a.PackageName()) os.MkdirAll(filepath.Join(pkgDir, a.InterfacePackageName()), 0775) + os.MkdirAll(filepath.Join(pkgDir, api.ServiceTypesPkgName), 0775) + os.Mkdir(filepath.Join(pkgDir, api.ServiceEnumsPkgName), 0775) if _, ok := servicePaths[pkgDir]; ok { fmt.Fprintf(os.Stderr, @@ -140,10 +145,12 @@ type generateInfo struct { PackageDir string } +// excludeServices exclude the services from being generated. var excludeServices = map[string]struct{}{ "importexport": {}, } +// write service files using the loaded api struct. func writeServiceFiles(g *generateInfo, pkgDir string) { defer func() { if r := recover(); r != nil { @@ -244,6 +251,7 @@ func writeInterfaceFile(g *generateInfo) error { ) } +// writeWaitersFile writes the service waiter file func writeWaitersFile(g *generateInfo) error { if len(g.API.Waiters) == 0 { return nil @@ -259,34 +267,44 @@ func writeWaitersFile(g *generateInfo) error { // writeAPIFile writes out the service API file. func writeAPIFile(g *generateInfo) error { + for opName, op := range g.API.Operations { - err := writeGoFile( + if err := writeGoFile( filepath.Join(g.PackageDir, "api_op_"+op.ExportedName+".go"), codeLayout, "", g.API.PackageName(), g.API.APIOperationGoCode(op), - ) - - if err != nil { + ); err != nil { return fmt.Errorf("failed to write %s operation file, %v", opName, err) } + + // add in input and output to api_op_types.go + if err := writeGoFile( + filepath.Join(g.PackageDir, api.ServiceTypesPkgName, "api_op_"+op.ExportedName+".go"), + codeLayout, + "", + api.ServiceTypesPkgName, + g.API.APIOperationTypeGoCode(op), + ); err != nil { + return fmt.Errorf("failed to write %s operation types file, %v", opName, err) + } } - if err := writeGoFile(filepath.Join(g.PackageDir, "api_enums.go"), + if err := writeGoFile(filepath.Join(g.PackageDir, api.ServiceTypesPkgName, "api_types.go"), codeLayout, "", - g.API.PackageName(), - g.API.APIEnumsGoCode(), + api.ServiceTypesPkgName, + g.API.APIParamShapesGoCode(), ); err != nil { return err } - if err := writeGoFile(filepath.Join(g.PackageDir, "api_types.go"), + if err := writeGoFile(filepath.Join(g.PackageDir, api.ServiceEnumsPkgName, "api_enums.go"), codeLayout, "", - g.API.PackageName(), - g.API.APIParamShapesGoCode(), + api.ServiceEnumsPkgName, + g.API.APIEnumsGoCode(), ); err != nil { return err } diff --git a/private/protocol/json/jsonutil/unmarshal_bench_test.go b/private/protocol/json/jsonutil/unmarshal_bench_test.go index 4c3f2c2ba5d..9b56d9e756b 100644 --- a/private/protocol/json/jsonutil/unmarshal_bench_test.go +++ b/private/protocol/json/jsonutil/unmarshal_bench_test.go @@ -3,12 +3,13 @@ package jsonutil_test import ( "bytes" "encoding/json" - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/private/protocol/json/jsonutil" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" "io/ioutil" "net/http" "testing" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol/json/jsonutil" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) var ( @@ -50,7 +51,7 @@ func BenchmarkStdlibJSON_Unmarshal_Simple(b *testing.B) { func BenchmarkStdlibJSON_Unmarshal_Complex(b *testing.B) { b.ResetTimer() for i := 0; i < b.N; i++ { - json.Unmarshal(complexJSON, &dynamodb.DescribeTableOutput{}) + json.Unmarshal(complexJSON, &types.DescribeTableOutput{}) } } @@ -62,6 +63,6 @@ func getJSONResponseSimple() *aws.Request { func getJSONResponseComplex() *aws.Request { buf := bytes.NewReader(complexJSON) - req := aws.Request{Data: &dynamodb.DescribeTableOutput{}, HTTPResponse: &http.Response{Body: ioutil.NopCloser(buf)}} + req := aws.Request{Data: &types.DescribeTableOutput{}, HTTPResponse: &http.Response{Body: ioutil.NopCloser(buf)}} return &req } diff --git a/private/protocol/path_replace.go b/private/protocol/path_replace.go index ae64a17dbf8..02a9c85af7d 100644 --- a/private/protocol/path_replace.go +++ b/private/protocol/path_replace.go @@ -43,12 +43,12 @@ func (r *PathReplace) Encode() (path string, rawPath string) { // ReplaceElement replaces a single element in the path string. func (r *PathReplace) ReplaceElement(key, val string) (err error) { - r.path, r.fieldBuf, err = replacePathElement(r.path, r.fieldBuf, key, val, false) - r.rawPath, r.fieldBuf, err = replacePathElement(r.rawPath, r.fieldBuf, key, val, true) + r.path, r.fieldBuf, err = ReplacePathElement(r.path, r.fieldBuf, key, val, false) + r.rawPath, r.fieldBuf, err = ReplacePathElement(r.rawPath, r.fieldBuf, key, val, true) return err } -func replacePathElement(path, fieldBuf []byte, key, val string, escape bool) ([]byte, []byte, error) { +func ReplacePathElement(path, fieldBuf []byte, key, val string, escape bool) ([]byte, []byte, error) { fieldBuf = bufCap(fieldBuf, len(key)+3) // { [+] } fieldBuf = append(fieldBuf, uriTokenStart) fieldBuf = append(fieldBuf, key...) diff --git a/private/protocol/rest/v2/encode.go b/private/protocol/rest/v2/encode.go new file mode 100644 index 00000000000..0f73f04399f --- /dev/null +++ b/private/protocol/rest/v2/encode.go @@ -0,0 +1,75 @@ +package rest + +import ( + "net/http" + "net/url" + "strings" +) + +// An Encoder provides encoding of REST URI path, query, and header components +// of an HTTP request. Can also encode a stream as the payload. +// +// Does not support SetFields. +type Encoder struct { + req *http.Request + + path, rawPath, pathBuffer []byte + + query url.Values + header http.Header +} + +// NewEncoder creates a new encoder from the passed in request. All query and +// header values will be added on top of the request's existing values. Overwriting +// duplicate values. +func NewEncoder(req *http.Request) *Encoder { + e := &Encoder{ + req: req, + + path: []byte(req.URL.Path), + rawPath: []byte(req.URL.Path), + query: req.URL.Query(), + header: req.Header, + } + + return e +} + +// Encode will return the request and body if one was set. If the body +// payload was not set the io.ReadSeeker will be nil. +// +// returns any error if one occured while encoding the API's parameters. +func (e *Encoder) Encode() *http.Request { + e.req.URL.Path, e.req.URL.RawPath = string(e.path), string(e.rawPath) + e.req.URL.RawQuery = e.query.Encode() + e.req.Header = e.header + + return e.req +} + +func (e *Encoder) AddHeader(key string) *HeaderValue { + return newHeaderValue(e.header, key, true) +} + +func (e *Encoder) SetHeader(key string) *HeaderValue { + return newHeaderValue(e.header, key, false) +} + +func (e *Encoder) Headers(prefix string) *Headers { + return &Headers{ + header: e.header, + prefix: strings.TrimSpace(prefix), + } +} + +func (e *Encoder) SetURI(key string) *URIValue { + return newURIValue(&e.path, &e.rawPath, &e.pathBuffer, key) +} + +func (e *Encoder) SetQuery(key string) *QueryValue { + return newQueryValue(e.query, key, false) +} + +func (e *Encoder) AddQuery(key string) *QueryValue { + return newQueryValue(e.query, key, true) +} diff --git a/private/protocol/rest/v2/encode_test.go b/private/protocol/rest/v2/encode_test.go new file mode 100644 index 00000000000..e77990831aa --- /dev/null +++ b/private/protocol/rest/v2/encode_test.go @@ -0,0 +1,54 @@ +package rest + +import ( + "net/http" + "net/url" + "reflect" + "testing" +) + +func TestEncoder(t *testing.T) { + actual := http.Request{ + Header: http.Header{ + "custom-user-header": {"someValue"}, + }, + URL: &url.URL{ + Path: "/some/{pathKey}/path", + RawQuery: "someExistingKeys=foobar", + }, + } + + expected := http.Request{ + Header: map[string][]string{ + "custom-user-header": {"someValue"}, + "X-Amzn-Header-Foo": {"someValue"}, + "X-Amzn-Meta-Foo": {"someValue"}, + }, + URL: &url.URL{ + Path: "/some/someValue/path", + RawPath: "/some/someValue/path", + RawQuery: "someExistingKeys=foobar&someKey=someValue&someKey=otherValue", + }, + } + + encoder := NewEncoder(&actual) + + // Headers + encoder.AddHeader("x-amzn-header-foo").String("someValue") + encoder.Headers("x-amzn-meta-").AddHeader("foo").String("someValue") + + // Query + encoder.SetQuery("someKey").String("someValue") + encoder.AddQuery("someKey").String("otherValue") + + // URI + if err := encoder.AddURI("pathKey").String("someValue"); err != nil { + t.Errorf("expected no err, but got %v", err) + } + + actual = *encoder.Encode() + + if !reflect.DeepEqual(expected, actual) { + t.Errorf("expected %v, but got %v", expected, actual) + } +} diff --git a/private/protocol/rest/v2/header.go b/private/protocol/rest/v2/header.go new file mode 100644 index 00000000000..ba5275b68c0 --- /dev/null +++ b/private/protocol/rest/v2/header.go @@ -0,0 +1,86 @@ +package rest + +import ( + "encoding/base64" + "net/http" + "strconv" + "strings" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" +) + +type Headers struct { + header http.Header + prefix string +} + +func (h *Headers) AddHeader(key string) *HeaderValue { + return h.newHeaderValue(key, true) +} + +func (h *Headers) SetHeader(key string) *HeaderValue { + return h.newHeaderValue(key, false) +} + +func (h *Headers) newHeaderValue(key string, append bool) *HeaderValue { + return newHeaderValue(h.header, h.prefix+strings.TrimSpace(key), append) +} + +type HeaderValue struct { + header http.Header + key string + append bool +} + +func newHeaderValue(header http.Header, key string, append bool) *HeaderValue { + return &HeaderValue{header: header, key: strings.TrimSpace(key), append: append} +} + +func (h *HeaderValue) modifyHeader(value string) { + if h.append { + h.header.Add(h.key, value) + } else { + h.header.Set(h.key, value) + } +} + +func (h *HeaderValue) String(v string) { + h.modifyHeader(v) +} + +func (h *HeaderValue) Integer(v int64) { + h.modifyHeader(strconv.FormatInt(v, 10)) +} + +func (h *HeaderValue) Boolean(v bool) { + h.modifyHeader(strconv.FormatBool(v)) +} + +func (h *HeaderValue) Float(v float64) { + h.modifyHeader(strconv.FormatFloat(v, 'f', -1, 64)) +} + +func (h *HeaderValue) Time(t time.Time, format string) (err error) { + value, err := protocol.FormatTime(format, t) + if err != nil { + return err + } + h.modifyHeader(value) + return nil +} + +func (h *HeaderValue) ByteSlice(v []byte) { + encodeToString := base64.StdEncoding.EncodeToString(v) + h.modifyHeader(encodeToString) +} + +func (h *HeaderValue) JSONValue(v aws.JSONValue) error { + encodedValue, err := protocol.EncodeJSONValue(v, protocol.Base64Escape) + if err != nil { + return err + } + h.modifyHeader(encodedValue) + return nil +} diff --git a/private/protocol/rest/v2/header_test.go b/private/protocol/rest/v2/header_test.go new file mode 100644 index 00000000000..bb5ea31f509 --- /dev/null +++ b/private/protocol/rest/v2/header_test.go @@ -0,0 +1,213 @@ +package rest + +import ( + "fmt" + "net/http" + "reflect" + "testing" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" +) + +func TestHeaderValue(t *testing.T) { + const keyName = "test-key" + const expectedKeyName = "Test-Key" + + cases := map[string]struct { + header http.Header + args []interface{} + append bool + expected http.Header + }{ + "set string": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{"string value"}, + expected: map[string][]string{ + expectedKeyName: {"string value"}, + }, + }, + "set float64": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{3.14159}, + expected: map[string][]string{ + expectedKeyName: {"3.14159"}, + }, + }, + "set bool": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{true}, + expected: map[string][]string{ + expectedKeyName: {"true"}, + }, + }, + "set json": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{aws.JSONValue{"jsonKey": "jsonValue"}}, + expected: map[string][]string{ + expectedKeyName: {"eyJqc29uS2V5IjoianNvblZhbHVlIn0="}, + }, + }, + "set time": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{time.Unix(0, 0), protocol.ISO8601TimeFormatName}, + expected: map[string][]string{ + expectedKeyName: {"1970-01-01T00:00:00Z"}, + }, + }, + "set byte slice": { + header: http.Header{expectedKeyName: []string{"foobar"}}, + args: []interface{}{[]byte("baz")}, + expected: map[string][]string{ + expectedKeyName: {"YmF6"}, + }, + }, + "add string": { + header: http.Header{expectedKeyName: []string{"other string"}}, + args: []interface{}{"string value"}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"other string", "string value"}, + }, + }, + "add float64": { + header: http.Header{expectedKeyName: []string{"1.61803"}}, + args: []interface{}{3.14159}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"1.61803", "3.14159"}, + }, + }, + "add bool": { + header: http.Header{expectedKeyName: []string{"false"}}, + args: []interface{}{true}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"false", "true"}, + }, + }, + "add json": { + header: http.Header{expectedKeyName: []string{`eyJzb21lS2V5Ijoic29tZVZhbHVlIn0=`}}, + args: []interface{}{aws.JSONValue{"jsonKey": "jsonValue"}}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"eyJzb21lS2V5Ijoic29tZVZhbHVlIn0=", "eyJqc29uS2V5IjoianNvblZhbHVlIn0="}, + }, + }, + "add time": { + header: http.Header{expectedKeyName: []string{"1991-09-17T00:00:00Z"}}, + args: []interface{}{time.Unix(0, 0), protocol.ISO8601TimeFormatName}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"1991-09-17T00:00:00Z", "1970-01-01T00:00:00Z"}, + }, + }, + "add byte slice": { + header: http.Header{expectedKeyName: []string{"YmFy"}}, + args: []interface{}{[]byte("baz")}, + append: true, + expected: map[string][]string{ + expectedKeyName: {"YmFy", "YmF6"}, + }, + }, + } + + for name, tt := range cases { + t.Run(name, func(t *testing.T) { + if tt.header == nil { + tt.header = http.Header{} + } + + hv := newHeaderValue(tt.header, keyName, tt.append) + + if err := setHeader(hv, tt.args); err != nil { + t.Fatalf("expected no error, got %v", err) + } + + if e, a := tt.expected, hv.header; !reflect.DeepEqual(e, a) { + t.Errorf("expected %v, got %v", e, a) + } + }) + } +} + +func TestHeaders(t *testing.T) { + const prefix = "x-amzn-meta-" + cases := map[string]struct { + headers http.Header + values map[string]string + append bool + expected http.Header + }{ + "set": { + headers: http.Header{ + "X-Amzn-Meta-Foo": {"bazValue"}, + }, + values: map[string]string{ + "foo": "fooValue", + " bar ": "barValue", + }, + expected: http.Header{ + "X-Amzn-Meta-Foo": {"fooValue"}, + "X-Amzn-Meta-Bar": {"barValue"}, + }, + }, + "add": { + headers: http.Header{ + "X-Amzn-Meta-Foo": {"bazValue"}, + }, + values: map[string]string{ + "foo": "fooValue", + " bar ": "barValue", + }, + append: true, + expected: http.Header{ + "X-Amzn-Meta-Foo": {"bazValue", "fooValue"}, + "X-Amzn-Meta-Bar": {"barValue"}, + }, + }, + } + + for name, tt := range cases { + t.Run(name, func(t *testing.T) { + headers := Headers{header: tt.headers, prefix: prefix} + + var f func(key string) *HeaderValue + if tt.append { + f = headers.AddHeader + } else { + f = headers.SetHeader + } + + for key, value := range tt.values { + f(key).String(value) + } + + if e, a := tt.expected, tt.headers; !reflect.DeepEqual(e, a) { + t.Errorf("expected %v, but got %v", e, a) + } + }) + } +} + +func setHeader(hv *HeaderValue, args []interface{}) error { + value := args[0] + + switch value.(type) { + case string: + return reflectCall(reflect.ValueOf(hv.String), args) + case float64: + return reflectCall(reflect.ValueOf(hv.Float), args) + case bool: + return reflectCall(reflect.ValueOf(hv.Boolean), args) + case aws.JSONValue: + return reflectCall(reflect.ValueOf(hv.JSONValue), args) + case time.Time: + return reflectCall(reflect.ValueOf(hv.Time), args) + case []byte: + return reflectCall(reflect.ValueOf(hv.ByteSlice), args) + default: + return fmt.Errorf("unhandled header value type") + } +} diff --git a/private/protocol/rest/v2/query.go b/private/protocol/rest/v2/query.go new file mode 100644 index 00000000000..121ddab5ab8 --- /dev/null +++ b/private/protocol/rest/v2/query.go @@ -0,0 +1,71 @@ +package rest + +import ( + "encoding/base64" + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" + "net/url" + "strconv" + "time" +) + +type QueryValue struct { + query url.Values + key string + append bool +} + +func newQueryValue(query url.Values, key string, append bool) *QueryValue { + return &QueryValue{ + query: query, + key: key, + append: append, + } +} + +func (qv *QueryValue) updateKey(value string) { + if qv.append { + qv.query.Add(qv.key, value) + } else { + qv.query.Set(qv.key, value) + } +} + +func (qv *QueryValue) String(v string) { + qv.updateKey(v) +} + +func (qv *QueryValue) Integer(v int64) { + qv.updateKey(strconv.FormatInt(v, 10)) +} + +func (qv *QueryValue) Boolean(v bool) { + qv.updateKey(strconv.FormatBool(v)) +} + +func (qv *QueryValue) Float(v float64) { + qv.updateKey(strconv.FormatFloat(v, 'f', -1, 64)) +} + +func (qv *QueryValue) Time(v time.Time, format string) error { + value, err := protocol.FormatTime(format, v) + if err != nil { + return err + } + qv.updateKey(value) + return nil +} + +func (qv *QueryValue) ByteSlice(v []byte) { + encodeToString := base64.StdEncoding.EncodeToString(v) + qv.updateKey(encodeToString) +} + +func (qv *QueryValue) JSONValue(v aws.JSONValue) error { + encodeJSONValue, err := protocol.EncodeJSONValue(v, protocol.NoEscape) + if err != nil { + return err + } + qv.updateKey(encodeJSONValue) + return nil +} diff --git a/private/protocol/rest/v2/query_test.go b/private/protocol/rest/v2/query_test.go new file mode 100644 index 00000000000..1b03ac0da71 --- /dev/null +++ b/private/protocol/rest/v2/query_test.go @@ -0,0 +1,153 @@ +package rest + +import ( + "fmt" + "net/url" + "reflect" + "testing" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" +) + +func TestQueryValue(t *testing.T) { + const queryKey = "someKey" + + cases := map[string]struct { + values url.Values + args []interface{} + append bool + expected url.Values + }{ + "set string": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{"string value"}, + expected: map[string][]string{ + queryKey: {"string value"}, + }, + }, + "set float64": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{3.14159}, + expected: map[string][]string{ + queryKey: {"3.14159"}, + }, + }, + "set bool": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{true}, + expected: map[string][]string{ + queryKey: {"true"}, + }, + }, + "set json": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{aws.JSONValue{"jsonKey": "jsonValue"}}, + expected: map[string][]string{ + queryKey: {`{"jsonKey":"jsonValue"}`}, + }, + }, + "set time": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{time.Unix(0, 0), protocol.ISO8601TimeFormatName}, + expected: map[string][]string{ + queryKey: {"1970-01-01T00:00:00Z"}, + }, + }, + "set byte slice": { + values: url.Values{queryKey: []string{"foobar"}}, + args: []interface{}{[]byte("baz")}, + expected: map[string][]string{ + queryKey: {"YmF6"}, + }, + }, + "add string": { + values: url.Values{queryKey: []string{"other string"}}, + args: []interface{}{"string value"}, + append: true, + expected: map[string][]string{ + queryKey: {"other string", "string value"}, + }, + }, + "add float64": { + values: url.Values{queryKey: []string{"1.61803"}}, + args: []interface{}{3.14159}, + append: true, + expected: map[string][]string{ + queryKey: {"1.61803", "3.14159"}, + }, + }, + "add bool": { + values: url.Values{queryKey: []string{"false"}}, + args: []interface{}{true}, + append: true, + expected: map[string][]string{ + queryKey: {"false", "true"}, + }, + }, + "add json": { + values: url.Values{queryKey: []string{`{"someKey":"someValue"}`}}, + args: []interface{}{aws.JSONValue{"jsonKey": "jsonValue"}}, + append: true, + expected: map[string][]string{ + queryKey: {`{"someKey":"someValue"}`, `{"jsonKey":"jsonValue"}`}, + }, + }, + "add time": { + values: url.Values{queryKey: []string{"1991-09-17T00:00:00Z"}}, + args: []interface{}{time.Unix(0, 0), protocol.ISO8601TimeFormatName}, + append: true, + expected: map[string][]string{ + queryKey: {"1991-09-17T00:00:00Z", "1970-01-01T00:00:00Z"}, + }, + }, + "add byte slice": { + values: url.Values{queryKey: []string{"YmFy"}}, + args: []interface{}{[]byte("baz")}, + append: true, + expected: map[string][]string{ + queryKey: {"YmFy", "YmF6"}, + }, + }, + } + + for name, tt := range cases { + t.Run(name, func(t *testing.T) { + if tt.values == nil { + tt.values = url.Values{} + } + + qv := newQueryValue(tt.values, queryKey, tt.append) + + if err := setQueryValue(qv, tt.args); err != nil { + t.Fatalf("expected no error, got %v", err) + } + + if e, a := tt.expected, qv.query; !reflect.DeepEqual(e, a) { + t.Errorf("expected %v, got %v", e, a) + } + }) + } +} + +func setQueryValue(qv *QueryValue, args []interface{}) error { + value := args[0] + + switch value.(type) { + case string: + return reflectCall(reflect.ValueOf(qv.String), args) + case float64: + return reflectCall(reflect.ValueOf(qv.Float), args) + case bool: + return reflectCall(reflect.ValueOf(qv.Boolean), args) + case aws.JSONValue: + return reflectCall(reflect.ValueOf(qv.JSONValue), args) + case time.Time: + return reflectCall(reflect.ValueOf(qv.Time), args) + case []byte: + return reflectCall(reflect.ValueOf(qv.ByteSlice), args) + default: + return fmt.Errorf("unhandled query value type") + } +} diff --git a/private/protocol/rest/v2/uri.go b/private/protocol/rest/v2/uri.go new file mode 100644 index 00000000000..b49431c3c46 --- /dev/null +++ b/private/protocol/rest/v2/uri.go @@ -0,0 +1,63 @@ +package rest + +import ( + "strconv" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" +) + +type URIValue struct { + path, rawPath, buffer *[]byte + + key string +} + +func newURIValue(path *[]byte, rawPath *[]byte, buffer *[]byte, key string) *URIValue { + return &URIValue{path: path, rawPath: rawPath, buffer: buffer, key: key} +} + +func (u *URIValue) modifyURI(value string) (err error) { + *u.path, *u.buffer, err = protocol.ReplacePathElement(*u.path, *u.buffer, u.key, value, false) + *u.rawPath, *u.buffer, err = protocol.ReplacePathElement(*u.rawPath, *u.buffer, u.key, value, true) + return err +} + +func (u *URIValue) String(v string) error { + return u.modifyURI(v) +} + +func (u *URIValue) Integer(v int64) error { + return u.modifyURI(strconv.FormatInt(v, 10)) +} + +func (u *URIValue) Boolean(v bool) error { + return u.modifyURI(strconv.FormatBool(v)) +} + +func (u *URIValue) Float(v float64) error { + return u.modifyURI(strconv.FormatFloat(v, 'f', -1, 64)) +} + +func (u *URIValue) Time(v time.Time, format string) error { + value, err := protocol.FormatTime(format, v) + if err != nil { + return err + } + + return u.modifyURI(value) +} + +func (u *URIValue) ByteSlice(v []byte) error { + return u.modifyURI(string(v)) +} + +func (u *URIValue) JSONValue(v aws.JSONValue) error { + encodeJSONValue, err := protocol.EncodeJSONValue(v, protocol.NoEscape) + if err != nil { + return err + } + + return u.modifyURI(encodeJSONValue) +} diff --git a/private/protocol/rest/v2/uri_test.go b/private/protocol/rest/v2/uri_test.go new file mode 100644 index 00000000000..0429a7b3012 --- /dev/null +++ b/private/protocol/rest/v2/uri_test.go @@ -0,0 +1,119 @@ +package rest + +import ( + "fmt" + "reflect" + "testing" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" +) + +func TestURIValue(t *testing.T) { + const uriKey = "someKey" + const path = "/some/{someKey}/{path+}" + + type expected struct { + path string + raw string + } + + cases := map[string]struct { + path string + args []interface{} + expected expected + }{ + "string": { + path: path, + args: []interface{}{"someValue"}, + expected: expected{ + path: "/some/someValue/{path+}", + raw: "/some/someValue/{path+}", + }, + }, + "float64": { + path: path, + args: []interface{}{3.14159}, + expected: expected{ + path: "/some/3.14159/{path+}", + raw: "/some/3.14159/{path+}", + }, + }, + "bool": { + path: path, + args: []interface{}{true}, + expected: expected{ + path: "/some/true/{path+}", + raw: "/some/true/{path+}", + }, + }, + "json": { + path: path, + args: []interface{}{aws.JSONValue{"jsonKey": "jsonValue"}}, + expected: expected{ + path: `/some/{"jsonKey":"jsonValue"}/{path+}`, + raw: "/some/%7B%22jsonKey%22%3A%22jsonValue%22%7D/{path+}", + }, + }, + "time": { + path: path, + args: []interface{}{time.Unix(0, 0), protocol.ISO8601TimeFormatName}, + expected: expected{ + path: "/some/1970-01-01T00:00:00Z/{path+}", + raw: "/some/1970-01-01T00%3A00%3A00Z/{path+}", + }, + }, + "byte slice": { + path: path, + args: []interface{}{[]byte("baz")}, + expected: expected{ + path: "/some/baz/{path+}", + raw: "/some/baz/{path+}", + }, + }, + } + + buffer := make([]byte, 1024) + + for name, tt := range cases { + t.Run(name, func(t *testing.T) { + pBytes, rBytes := []byte(tt.path), []byte(tt.path) + + uv := newURIValue(&pBytes, &rBytes, &buffer, uriKey) + + if err := setURI(uv, tt.args); err != nil { + t.Fatalf("expected no error, %v", err) + } + + if e, a := tt.expected.path, string(pBytes); e != a { + t.Errorf("expected %v, got %v", e, a) + } + + if e, a := tt.expected.raw, string(rBytes); e != a { + t.Errorf("expected %v, got %v", e, a) + } + }) + } +} + +func setURI(uv *URIValue, args []interface{}) error { + value := args[0] + + switch value.(type) { + case string: + return reflectCall(reflect.ValueOf(uv.String), args) + case float64: + return reflectCall(reflect.ValueOf(uv.Float), args) + case bool: + return reflectCall(reflect.ValueOf(uv.Boolean), args) + case aws.JSONValue: + return reflectCall(reflect.ValueOf(uv.JSONValue), args) + case time.Time: + return reflectCall(reflect.ValueOf(uv.Time), args) + case []byte: + return reflectCall(reflect.ValueOf(uv.ByteSlice), args) + default: + return fmt.Errorf("unhandled value type") + } +} diff --git a/private/protocol/rest/v2/utils_test.go b/private/protocol/rest/v2/utils_test.go new file mode 100644 index 00000000000..b0ebed727a7 --- /dev/null +++ b/private/protocol/rest/v2/utils_test.go @@ -0,0 +1,36 @@ +package rest + +import ( + "fmt" + "reflect" +) + +func reflectCall(funcValue reflect.Value, args []interface{}) error { + argValues := make([]reflect.Value, len(args)) + + for i, v := range args { + value := reflect.ValueOf(v) + argValues[i] = value + } + + retValues := funcValue.Call(argValues) + if len(retValues) > 0 { + errValue := retValues[0] + + if typeName := errValue.Type().Name(); typeName != "error" { + panic(fmt.Sprintf("expected first return argument to be error but got %v", typeName)) + } + + if errValue.IsNil() { + return nil + } + + if err, ok := errValue.Interface().(error); ok { + return err + } else { + panic(fmt.Sprintf("expected %v to return error type, but got %v", funcValue.Type().String(), retValues[0].Type().String())) + } + } + + return nil +} diff --git a/private/protocol/restjson/build_bench_test.go b/private/protocol/restjson/build_bench_test.go index a8ee22d6534..32b68e8fc62 100644 --- a/private/protocol/restjson/build_bench_test.go +++ b/private/protocol/restjson/build_bench_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/private/protocol/restjson" "github.com/aws/aws-sdk-go-v2/service/elastictranscoder" + "github.com/aws/aws-sdk-go-v2/service/elastictranscoder/types" ) var ( @@ -85,27 +86,27 @@ func benchRESTJSONRequest(b *testing.B, reqFn func() *aws.Request) { } } -func elastictranscoderListJobsByPipeline() *elastictranscoder.ListJobsByPipelineInput { - return &elastictranscoder.ListJobsByPipelineInput{ +func elastictranscoderListJobsByPipeline() *types.ListJobsByPipelineInput { + return &types.ListJobsByPipelineInput{ PipelineId: aws.String("Id"), // Required Ascending: aws.String("Ascending"), PageToken: aws.String("Id"), } } -func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { - return &elastictranscoder.CreateJobInput{ - Input: &elastictranscoder.JobInput{ // Required +func elastictranscoderCreateJobInput() *types.CreateJobInput { + return &types.CreateJobInput{ + Input: &types.JobInput{ // Required AspectRatio: aws.String("AspectRatio"), Container: aws.String("JobContainer"), - DetectedProperties: &elastictranscoder.DetectedProperties{ + DetectedProperties: &types.DetectedProperties{ DurationMillis: aws.Int64(1), FileSize: aws.Int64(1), FrameRate: aws.String("FloatString"), Height: aws.Int64(1), Width: aws.Int64(1), }, - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -117,12 +118,12 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { Resolution: aws.String("Resolution"), }, PipelineId: aws.String("Id"), // Required - Output: &elastictranscoder.CreateJobOutputResult{ - AlbumArt: &elastictranscoder.JobAlbumArt{ - Artwork: []elastictranscoder.Artwork{ + Output: &types.CreateJobOutputResult{ + AlbumArt: &types.JobAlbumArt{ + Artwork: []types.Artwork{ { // Required AlbumArtFormat: aws.String("JpgOrPng"), - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -138,10 +139,10 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, MergePolicy: aws.String("MergePolicy"), }, - Captions: &elastictranscoder.Captions{ - CaptionFormats: []elastictranscoder.CaptionFormat{ + Captions: &types.Captions{ + CaptionFormats: []types.CaptionFormat{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -152,9 +153,9 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, // More values... }, - CaptionSources: []elastictranscoder.CaptionSource{ + CaptionSources: []types.CaptionSource{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -169,16 +170,16 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, MergePolicy: aws.String("CaptionMergePolicy"), }, - Composition: []elastictranscoder.Clip{ + Composition: []types.Clip{ { // Required - TimeSpan: &elastictranscoder.TimeSpan{ + TimeSpan: &types.TimeSpan{ Duration: aws.String("Time"), StartTime: aws.String("Time"), }, }, // More values... }, - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -188,16 +189,16 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { PresetId: aws.String("Id"), Rotate: aws.String("Rotate"), SegmentDuration: aws.String("FloatString"), - ThumbnailEncryption: &elastictranscoder.Encryption{ + ThumbnailEncryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), Mode: aws.String("EncryptionMode"), }, ThumbnailPattern: aws.String("ThumbnailPattern"), - Watermarks: []elastictranscoder.JobWatermark{ + Watermarks: []types.JobWatermark{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -210,13 +211,13 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, }, OutputKeyPrefix: aws.String("Key"), - Outputs: []elastictranscoder.CreateJobOutputResult{ + Outputs: []types.CreateJobOutputResult{ { // Required - AlbumArt: &elastictranscoder.JobAlbumArt{ - Artwork: []elastictranscoder.Artwork{ + AlbumArt: &types.JobAlbumArt{ + Artwork: []types.Artwork{ { // Required AlbumArtFormat: aws.String("JpgOrPng"), - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -232,10 +233,10 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, MergePolicy: aws.String("MergePolicy"), }, - Captions: &elastictranscoder.Captions{ - CaptionFormats: []elastictranscoder.CaptionFormat{ + Captions: &types.Captions{ + CaptionFormats: []types.CaptionFormat{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -246,9 +247,9 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, // More values... }, - CaptionSources: []elastictranscoder.CaptionSource{ + CaptionSources: []types.CaptionSource{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -263,16 +264,16 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, MergePolicy: aws.String("CaptionMergePolicy"), }, - Composition: []elastictranscoder.Clip{ + Composition: []types.Clip{ { // Required - TimeSpan: &elastictranscoder.TimeSpan{ + TimeSpan: &types.TimeSpan{ Duration: aws.String("Time"), StartTime: aws.String("Time"), }, }, // More values... }, - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -282,16 +283,16 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { PresetId: aws.String("Id"), Rotate: aws.String("Rotate"), SegmentDuration: aws.String("FloatString"), - ThumbnailEncryption: &elastictranscoder.Encryption{ + ThumbnailEncryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), Mode: aws.String("EncryptionMode"), }, ThumbnailPattern: aws.String("ThumbnailPattern"), - Watermarks: []elastictranscoder.JobWatermark{ + Watermarks: []types.JobWatermark{ { // Required - Encryption: &elastictranscoder.Encryption{ + Encryption: &types.Encryption{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -305,10 +306,10 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { }, // More values... }, - Playlists: []elastictranscoder.CreateJobPlaylist{ + Playlists: []types.CreateJobPlaylist{ { // Required Format: aws.String("PlaylistFormat"), - HlsContentProtection: &elastictranscoder.HlsContentProtection{ + HlsContentProtection: &types.HlsContentProtection{ InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("Base64EncodedString"), KeyMd5: aws.String("Base64EncodedString"), @@ -321,7 +322,7 @@ func elastictranscoderCreateJobInput() *elastictranscoder.CreateJobInput { "Key", // Required // More values... }, - PlayReadyDrm: &elastictranscoder.PlayReadyDrm{ + PlayReadyDrm: &types.PlayReadyDrm{ Format: aws.String("PlayReadyDrmFormatString"), InitializationVector: aws.String("ZeroTo255String"), Key: aws.String("NonEmptyBase64EncodedString"), diff --git a/private/protocol/restxml/build_bench_test.go b/private/protocol/restxml/build_bench_test.go index 97dfbdcf8bc..2bc72f1fc2f 100644 --- a/private/protocol/restxml/build_bench_test.go +++ b/private/protocol/restxml/build_bench_test.go @@ -14,7 +14,11 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/private/protocol/restxml" "github.com/aws/aws-sdk-go-v2/service/cloudfront" + cfEnums "github.com/aws/aws-sdk-go-v2/service/cloudfront/enums" + cfTypes "github.com/aws/aws-sdk-go-v2/service/cloudfront/types" "github.com/aws/aws-sdk-go-v2/service/s3" + s3Enums "github.com/aws/aws-sdk-go-v2/service/s3/enums" + s3Types "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var ( @@ -141,16 +145,16 @@ func benchRESTXMLRequest(b *testing.B, reqFn func() *aws.Request) { } } -func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { - return &cloudfront.CreateDistributionInput{ - DistributionConfig: &cloudfront.DistributionConfig{ // Required +func cloudfrontCreateDistributionInput() *cfTypes.CreateDistributionInput { + return &cfTypes.CreateDistributionInput{ + DistributionConfig: &cfTypes.DistributionConfig{ // Required CallerReference: aws.String("string"), // Required Comment: aws.String("string"), // Required - DefaultCacheBehavior: &cloudfront.DefaultCacheBehavior{ // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: cloudfront.ItemSelection("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ + DefaultCacheBehavior: &cfTypes.DefaultCacheBehavior{ // Required + ForwardedValues: &cfTypes.ForwardedValues{ // Required + Cookies: &cfTypes.CookiePreference{ // Required + Forward: cfEnums.ItemSelection("ItemSelection"), // Required + WhitelistedNames: &cfTypes.CookieNames{ Quantity: aws.Int64(1), // Required Items: []string{ "string", // Required @@ -159,7 +163,7 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { }, }, QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ + Headers: &cfTypes.Headers{ Quantity: aws.Int64(1), // Required Items: []string{ "string", // Required @@ -169,7 +173,7 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { }, MinTTL: aws.Int64(1), // Required TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required + TrustedSigners: &cfTypes.TrustedSigners{ // Required Enabled: aws.Bool(true), // Required Quantity: aws.Int64(1), // Required Items: []string{ @@ -177,16 +181,16 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { // More values... }, }, - ViewerProtocolPolicy: cloudfront.ViewerProtocolPolicy("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []cloudfront.Method{ // Required - cloudfront.Method("string"), // Required + ViewerProtocolPolicy: cfEnums.ViewerProtocolPolicy("ViewerProtocolPolicy"), // Required + AllowedMethods: &cfTypes.AllowedMethods{ + Items: []cfEnums.Method{ // Required + cfEnums.Method("string"), // Required // More values... }, Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []cloudfront.Method{ // Required - cloudfront.Method("string"), // Required + CachedMethods: &cfTypes.CachedMethods{ + Items: []cfEnums.Method{ // Required + cfEnums.Method("string"), // Required // More values... }, Quantity: aws.Int64(1), // Required @@ -197,40 +201,40 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { SmoothStreaming: aws.Bool(true), }, Enabled: aws.Bool(true), // Required - Origins: &cloudfront.Origins{ // Required + Origins: &cfTypes.Origins{ // Required Quantity: aws.Int64(1), // Required - Items: []cloudfront.Origin{ + Items: []cfTypes.Origin{ { // Required DomainName: aws.String("string"), // Required Id: aws.String("string"), // Required - CustomOriginConfig: &cloudfront.CustomOriginConfig{ - HTTPPort: aws.Int64(1), // Required - HTTPSPort: aws.Int64(1), // Required - OriginProtocolPolicy: cloudfront.OriginProtocolPolicy("OriginProtocolPolicy"), // Required + CustomOriginConfig: &cfTypes.CustomOriginConfig{ + HTTPPort: aws.Int64(1), // Required + HTTPSPort: aws.Int64(1), // Required + OriginProtocolPolicy: cfEnums.OriginProtocolPolicy("OriginProtocolPolicy"), // Required }, OriginPath: aws.String("string"), - S3OriginConfig: &cloudfront.S3OriginConfig{ + S3OriginConfig: &cfTypes.S3OriginConfig{ OriginAccessIdentity: aws.String("string"), // Required }, }, // More values... }, }, - Aliases: &cloudfront.Aliases{ + Aliases: &cfTypes.Aliases{ Quantity: aws.Int64(1), // Required Items: []string{ "string", // Required // More values... }, }, - CacheBehaviors: &cloudfront.CacheBehaviors{ + CacheBehaviors: &cfTypes.CacheBehaviors{ Quantity: aws.Int64(1), // Required - Items: []cloudfront.CacheBehavior{ + Items: []cfTypes.CacheBehavior{ { // Required - ForwardedValues: &cloudfront.ForwardedValues{ // Required - Cookies: &cloudfront.CookiePreference{ // Required - Forward: cloudfront.ItemSelection("ItemSelection"), // Required - WhitelistedNames: &cloudfront.CookieNames{ + ForwardedValues: &cfTypes.ForwardedValues{ // Required + Cookies: &cfTypes.CookiePreference{ // Required + Forward: cfEnums.ItemSelection("ItemSelection"), // Required + WhitelistedNames: &cfTypes.CookieNames{ Quantity: aws.Int64(1), // Required Items: []string{ "string", // Required @@ -239,7 +243,7 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { }, }, QueryString: aws.Bool(true), // Required - Headers: &cloudfront.Headers{ + Headers: &cfTypes.Headers{ Quantity: aws.Int64(1), // Required Items: []string{ "string", // Required @@ -250,7 +254,7 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { MinTTL: aws.Int64(1), // Required PathPattern: aws.String("string"), // Required TargetOriginId: aws.String("string"), // Required - TrustedSigners: &cloudfront.TrustedSigners{ // Required + TrustedSigners: &cfTypes.TrustedSigners{ // Required Enabled: aws.Bool(true), // Required Quantity: aws.Int64(1), // Required Items: []string{ @@ -258,16 +262,16 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { // More values... }, }, - ViewerProtocolPolicy: cloudfront.ViewerProtocolPolicy("ViewerProtocolPolicy"), // Required - AllowedMethods: &cloudfront.AllowedMethods{ - Items: []cloudfront.Method{ // Required - cloudfront.Method("string"), // Required + ViewerProtocolPolicy: cfEnums.ViewerProtocolPolicy("ViewerProtocolPolicy"), // Required + AllowedMethods: &cfTypes.AllowedMethods{ + Items: []cfEnums.Method{ // Required + cfEnums.Method("string"), // Required // More values... }, Quantity: aws.Int64(1), // Required - CachedMethods: &cloudfront.CachedMethods{ - Items: []cloudfront.Method{ // Required - cloudfront.Method("string"), // Required + CachedMethods: &cfTypes.CachedMethods{ + Items: []cfEnums.Method{ // Required + cfEnums.Method("string"), // Required // More values... }, Quantity: aws.Int64(1), // Required @@ -280,9 +284,9 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { // More values... }, }, - CustomErrorResponses: &cloudfront.CustomErrorResponses{ + CustomErrorResponses: &cfTypes.CustomErrorResponses{ Quantity: aws.Int64(1), // Required - Items: []cloudfront.CustomErrorResponse{ + Items: []cfTypes.CustomErrorResponse{ { // Required ErrorCode: aws.Int64(1), // Required ErrorCachingMinTTL: aws.Int64(1), @@ -293,42 +297,42 @@ func cloudfrontCreateDistributionInput() *cloudfront.CreateDistributionInput { }, }, DefaultRootObject: aws.String("string"), - Logging: &cloudfront.LoggingConfig{ + Logging: &cfTypes.LoggingConfig{ Bucket: aws.String("string"), // Required Enabled: aws.Bool(true), // Required IncludeCookies: aws.Bool(true), // Required Prefix: aws.String("string"), // Required }, - PriceClass: cloudfront.PriceClass("PriceClass"), - Restrictions: &cloudfront.Restrictions{ - GeoRestriction: &cloudfront.GeoRestriction{ // Required - Quantity: aws.Int64(1), // Required - RestrictionType: cloudfront.GeoRestrictionType("GeoRestrictionType"), // Required + PriceClass: cfEnums.PriceClass("PriceClass"), + Restrictions: &cfTypes.Restrictions{ + GeoRestriction: &cfTypes.GeoRestriction{ // Required + Quantity: aws.Int64(1), // Required + RestrictionType: cfEnums.GeoRestrictionType("GeoRestrictionType"), // Required Items: []string{ "string", // Required // More values... }, }, }, - ViewerCertificate: &cloudfront.ViewerCertificate{ + ViewerCertificate: &cfTypes.ViewerCertificate{ CloudFrontDefaultCertificate: aws.Bool(true), IAMCertificateId: aws.String("string"), - MinimumProtocolVersion: cloudfront.MinimumProtocolVersion("MinimumProtocolVersion"), - SSLSupportMethod: cloudfront.SSLSupportMethod("SSLSupportMethod"), + MinimumProtocolVersion: cfEnums.MinimumProtocolVersion("MinimumProtocolVersion"), + SSLSupportMethod: cfEnums.SSLSupportMethod("SSLSupportMethod"), }, }, } } -func cloudfrontDeleteDistributionInput() *cloudfront.DeleteDistributionInput { - return &cloudfront.DeleteDistributionInput{ +func cloudfrontDeleteDistributionInput() *cfTypes.DeleteDistributionInput { + return &cfTypes.DeleteDistributionInput{ Id: aws.String("string"), // Required IfMatch: aws.String("string"), } } -func s3HeadObjectInput() *s3.HeadObjectInput { - return &s3.HeadObjectInput{ +func s3HeadObjectInput() *s3Types.HeadObjectInput { + return &s3Types.HeadObjectInput{ Bucket: aws.String("somebucketname"), Key: aws.String("keyname"), VersionId: aws.String("someVersion"), @@ -336,24 +340,24 @@ func s3HeadObjectInput() *s3.HeadObjectInput { } } -func s3PutObjectAclInput() *s3.PutObjectAclInput { - return &s3.PutObjectAclInput{ +func s3PutObjectAclInput() *s3Types.PutObjectAclInput { + return &s3Types.PutObjectAclInput{ Bucket: aws.String("somebucketname"), Key: aws.String("keyname"), - AccessControlPolicy: &s3.AccessControlPolicy{ - Grants: []s3.Grant{ + AccessControlPolicy: &s3Types.AccessControlPolicy{ + Grants: []s3Types.Grant{ { - Grantee: &s3.Grantee{ + Grantee: &s3Types.Grantee{ DisplayName: aws.String("someName"), EmailAddress: aws.String("someAddr"), ID: aws.String("someID"), - Type: s3.TypeCanonicalUser, + Type: s3Enums.TypeCanonicalUser, URI: aws.String("someURI"), }, - Permission: s3.PermissionWrite, + Permission: s3Enums.PermissionWrite, }, }, - Owner: &s3.Owner{ + Owner: &s3Types.Owner{ DisplayName: aws.String("howdy"), ID: aws.String("someID"), }, diff --git a/private/protocol/xml/xmlutil/unmarshal_bench_test.go b/private/protocol/xml/xmlutil/unmarshal_bench_test.go index 8bbf2de939f..06a32f3cd81 100644 --- a/private/protocol/xml/xmlutil/unmarshal_bench_test.go +++ b/private/protocol/xml/xmlutil/unmarshal_bench_test.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/private/protocol/xml/xmlutil" - "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) type DataOutput struct { @@ -166,6 +166,6 @@ func getXMLResponseComplex() *aws.Request { `)) - req := aws.Request{Data: &ec2.DescribeInstancesOutput{}, HTTPResponse: &http.Response{Body: ioutil.NopCloser(buf)}} + req := aws.Request{Data: &types.DescribeInstancesOutput{}, HTTPResponse: &http.Response{Body: ioutil.NopCloser(buf)}} return &req } diff --git a/service/apigateway/api_enums.go b/service/apigateway/api_enums.go deleted file mode 100644 index 10e49ae38d7..00000000000 --- a/service/apigateway/api_enums.go +++ /dev/null @@ -1,390 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package apigateway - -type ApiKeySourceType string - -// Enum values for ApiKeySourceType -const ( - ApiKeySourceTypeHeader ApiKeySourceType = "HEADER" - ApiKeySourceTypeAuthorizer ApiKeySourceType = "AUTHORIZER" -) - -func (enum ApiKeySourceType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum ApiKeySourceType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type ApiKeysFormat string - -// Enum values for ApiKeysFormat -const ( - ApiKeysFormatCsv ApiKeysFormat = "csv" -) - -func (enum ApiKeysFormat) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum ApiKeysFormat) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -// The authorizer type. Valid values are TOKEN for a Lambda function using a -// single authorization token submitted in a custom header, REQUEST for a Lambda -// function using incoming request parameters, and COGNITO_USER_POOLS for using -// an Amazon Cognito user pool. -type AuthorizerType string - -// Enum values for AuthorizerType -const ( - AuthorizerTypeToken AuthorizerType = "TOKEN" - AuthorizerTypeRequest AuthorizerType = "REQUEST" - AuthorizerTypeCognitoUserPools AuthorizerType = "COGNITO_USER_POOLS" -) - -func (enum AuthorizerType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum AuthorizerType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -// Returns the size of the CacheCluster. -type CacheClusterSize string - -// Enum values for CacheClusterSize -const ( - CacheClusterSize05 CacheClusterSize = "0.5" - CacheClusterSize16 CacheClusterSize = "1.6" - CacheClusterSize61 CacheClusterSize = "6.1" - CacheClusterSize135 CacheClusterSize = "13.5" - CacheClusterSize284 CacheClusterSize = "28.4" - CacheClusterSize582 CacheClusterSize = "58.2" - CacheClusterSize118 CacheClusterSize = "118" - CacheClusterSize237 CacheClusterSize = "237" -) - -func (enum CacheClusterSize) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum CacheClusterSize) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -// Returns the status of the CacheCluster. -type CacheClusterStatus string - -// Enum values for CacheClusterStatus -const ( - CacheClusterStatusCreateInProgress CacheClusterStatus = "CREATE_IN_PROGRESS" - CacheClusterStatusAvailable CacheClusterStatus = "AVAILABLE" - CacheClusterStatusDeleteInProgress CacheClusterStatus = "DELETE_IN_PROGRESS" - CacheClusterStatusNotAvailable CacheClusterStatus = "NOT_AVAILABLE" - CacheClusterStatusFlushInProgress CacheClusterStatus = "FLUSH_IN_PROGRESS" -) - -func (enum CacheClusterStatus) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum CacheClusterStatus) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type ConnectionType string - -// Enum values for ConnectionType -const ( - ConnectionTypeInternet ConnectionType = "INTERNET" - ConnectionTypeVpcLink ConnectionType = "VPC_LINK" -) - -func (enum ConnectionType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum ConnectionType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type ContentHandlingStrategy string - -// Enum values for ContentHandlingStrategy -const ( - ContentHandlingStrategyConvertToBinary ContentHandlingStrategy = "CONVERT_TO_BINARY" - ContentHandlingStrategyConvertToText ContentHandlingStrategy = "CONVERT_TO_TEXT" -) - -func (enum ContentHandlingStrategy) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum ContentHandlingStrategy) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type DocumentationPartType string - -// Enum values for DocumentationPartType -const ( - DocumentationPartTypeApi DocumentationPartType = "API" - DocumentationPartTypeAuthorizer DocumentationPartType = "AUTHORIZER" - DocumentationPartTypeModel DocumentationPartType = "MODEL" - DocumentationPartTypeResource DocumentationPartType = "RESOURCE" - DocumentationPartTypeMethod DocumentationPartType = "METHOD" - DocumentationPartTypePathParameter DocumentationPartType = "PATH_PARAMETER" - DocumentationPartTypeQueryParameter DocumentationPartType = "QUERY_PARAMETER" - DocumentationPartTypeRequestHeader DocumentationPartType = "REQUEST_HEADER" - DocumentationPartTypeRequestBody DocumentationPartType = "REQUEST_BODY" - DocumentationPartTypeResponse DocumentationPartType = "RESPONSE" - DocumentationPartTypeResponseHeader DocumentationPartType = "RESPONSE_HEADER" - DocumentationPartTypeResponseBody DocumentationPartType = "RESPONSE_BODY" -) - -func (enum DocumentationPartType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum DocumentationPartType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type DomainNameStatus string - -// Enum values for DomainNameStatus -const ( - DomainNameStatusAvailable DomainNameStatus = "AVAILABLE" - DomainNameStatusUpdating DomainNameStatus = "UPDATING" - DomainNameStatusPending DomainNameStatus = "PENDING" -) - -func (enum DomainNameStatus) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum DomainNameStatus) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -// The endpoint type. The valid values are EDGE for edge-optimized API setup, -// most suitable for mobile applications; REGIONAL for regional API endpoint -// setup, most suitable for calling from AWS Region; and PRIVATE for private -// APIs. -type EndpointType string - -// Enum values for EndpointType -const ( - EndpointTypeRegional EndpointType = "REGIONAL" - EndpointTypeEdge EndpointType = "EDGE" - EndpointTypePrivate EndpointType = "PRIVATE" -) - -func (enum EndpointType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum EndpointType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type GatewayResponseType string - -// Enum values for GatewayResponseType -const ( - GatewayResponseTypeDefault4xx GatewayResponseType = "DEFAULT_4XX" - GatewayResponseTypeDefault5xx GatewayResponseType = "DEFAULT_5XX" - GatewayResponseTypeResourceNotFound GatewayResponseType = "RESOURCE_NOT_FOUND" - GatewayResponseTypeUnauthorized GatewayResponseType = "UNAUTHORIZED" - GatewayResponseTypeInvalidApiKey GatewayResponseType = "INVALID_API_KEY" - GatewayResponseTypeAccessDenied GatewayResponseType = "ACCESS_DENIED" - GatewayResponseTypeAuthorizerFailure GatewayResponseType = "AUTHORIZER_FAILURE" - GatewayResponseTypeAuthorizerConfigurationError GatewayResponseType = "AUTHORIZER_CONFIGURATION_ERROR" - GatewayResponseTypeInvalidSignature GatewayResponseType = "INVALID_SIGNATURE" - GatewayResponseTypeExpiredToken GatewayResponseType = "EXPIRED_TOKEN" - GatewayResponseTypeMissingAuthenticationToken GatewayResponseType = "MISSING_AUTHENTICATION_TOKEN" - GatewayResponseTypeIntegrationFailure GatewayResponseType = "INTEGRATION_FAILURE" - GatewayResponseTypeIntegrationTimeout GatewayResponseType = "INTEGRATION_TIMEOUT" - GatewayResponseTypeApiConfigurationError GatewayResponseType = "API_CONFIGURATION_ERROR" - GatewayResponseTypeUnsupportedMediaType GatewayResponseType = "UNSUPPORTED_MEDIA_TYPE" - GatewayResponseTypeBadRequestParameters GatewayResponseType = "BAD_REQUEST_PARAMETERS" - GatewayResponseTypeBadRequestBody GatewayResponseType = "BAD_REQUEST_BODY" - GatewayResponseTypeRequestTooLarge GatewayResponseType = "REQUEST_TOO_LARGE" - GatewayResponseTypeThrottled GatewayResponseType = "THROTTLED" - GatewayResponseTypeQuotaExceeded GatewayResponseType = "QUOTA_EXCEEDED" -) - -func (enum GatewayResponseType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum GatewayResponseType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -// The integration type. The valid value is HTTP for integrating an API method -// with an HTTP backend; AWS with any AWS service endpoints; MOCK for testing -// without actually invoking the backend; HTTP_PROXY for integrating with the -// HTTP proxy integration; AWS_PROXY for integrating with the Lambda proxy integration. -type IntegrationType string - -// Enum values for IntegrationType -const ( - IntegrationTypeHttp IntegrationType = "HTTP" - IntegrationTypeAws IntegrationType = "AWS" - IntegrationTypeMock IntegrationType = "MOCK" - IntegrationTypeHttpProxy IntegrationType = "HTTP_PROXY" - IntegrationTypeAwsProxy IntegrationType = "AWS_PROXY" -) - -func (enum IntegrationType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum IntegrationType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type LocationStatusType string - -// Enum values for LocationStatusType -const ( - LocationStatusTypeDocumented LocationStatusType = "DOCUMENTED" - LocationStatusTypeUndocumented LocationStatusType = "UNDOCUMENTED" -) - -func (enum LocationStatusType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum LocationStatusType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type Op string - -// Enum values for Op -const ( - OpAdd Op = "add" - OpRemove Op = "remove" - OpReplace Op = "replace" - OpMove Op = "move" - OpCopy Op = "copy" - OpTest Op = "test" -) - -func (enum Op) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum Op) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type PutMode string - -// Enum values for PutMode -const ( - PutModeMerge PutMode = "merge" - PutModeOverwrite PutMode = "overwrite" -) - -func (enum PutMode) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum PutMode) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type QuotaPeriodType string - -// Enum values for QuotaPeriodType -const ( - QuotaPeriodTypeDay QuotaPeriodType = "DAY" - QuotaPeriodTypeWeek QuotaPeriodType = "WEEK" - QuotaPeriodTypeMonth QuotaPeriodType = "MONTH" -) - -func (enum QuotaPeriodType) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum QuotaPeriodType) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type SecurityPolicy string - -// Enum values for SecurityPolicy -const ( - SecurityPolicyTls10 SecurityPolicy = "TLS_1_0" - SecurityPolicyTls12 SecurityPolicy = "TLS_1_2" -) - -func (enum SecurityPolicy) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum SecurityPolicy) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type UnauthorizedCacheControlHeaderStrategy string - -// Enum values for UnauthorizedCacheControlHeaderStrategy -const ( - UnauthorizedCacheControlHeaderStrategyFailWith403 UnauthorizedCacheControlHeaderStrategy = "FAIL_WITH_403" - UnauthorizedCacheControlHeaderStrategySucceedWithResponseHeader UnauthorizedCacheControlHeaderStrategy = "SUCCEED_WITH_RESPONSE_HEADER" - UnauthorizedCacheControlHeaderStrategySucceedWithoutResponseHeader UnauthorizedCacheControlHeaderStrategy = "SUCCEED_WITHOUT_RESPONSE_HEADER" -) - -func (enum UnauthorizedCacheControlHeaderStrategy) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum UnauthorizedCacheControlHeaderStrategy) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} - -type VpcLinkStatus string - -// Enum values for VpcLinkStatus -const ( - VpcLinkStatusAvailable VpcLinkStatus = "AVAILABLE" - VpcLinkStatusPending VpcLinkStatus = "PENDING" - VpcLinkStatusDeleting VpcLinkStatus = "DELETING" - VpcLinkStatusFailed VpcLinkStatus = "FAILED" -) - -func (enum VpcLinkStatus) MarshalValue() (string, error) { - return string(enum), nil -} - -func (enum VpcLinkStatus) MarshalValueBuf(b []byte) ([]byte, error) { - b = b[0:0] - return append(b, enum...), nil -} diff --git a/service/apigateway/api_types.go b/service/apigateway/api_types.go deleted file mode 100644 index e5b1114847b..00000000000 --- a/service/apigateway/api_types.go +++ /dev/null @@ -1,3441 +0,0 @@ -// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. - -package apigateway - -import ( - "time" - - "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" - "github.com/aws/aws-sdk-go-v2/private/protocol" -) - -var _ aws.Config -var _ = awsutil.Prettify - -// Access log settings, including the access log format and access log destination -// ARN. -type AccessLogSettings struct { - _ struct{} `type:"structure"` - - // The ARN of the CloudWatch Logs log group to receive access logs. - DestinationArn *string `locationName:"destinationArn" type:"string"` - - // A single line format of the access logs of data, as specified by selected - // $context variables (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#context-variable-reference). - // The format must include at least $context.requestId. - Format *string `locationName:"format" type:"string"` -} - -// String returns the string representation -func (s AccessLogSettings) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s AccessLogSettings) MarshalFields(e protocol.FieldEncoder) error { - if s.DestinationArn != nil { - v := *s.DestinationArn - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "destinationArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Format != nil { - v := *s.Format - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "format", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// A resource that can be distributed to callers for executing Method resources -// that require an API key. API keys can be mapped to any Stage on any RestApi, -// which indicates that the callers with the API key can make requests to that -// stage. -// -// Use API Keys (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-api-keys.html) -type ApiKey struct { - _ struct{} `type:"structure"` - - // The timestamp when the API Key was created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // An AWS Marketplace customer identifier , when integrating with the AWS SaaS - // Marketplace. - CustomerId *string `locationName:"customerId" type:"string"` - - // The description of the API Key. - Description *string `locationName:"description" type:"string"` - - // Specifies whether the API Key can be used by callers. - Enabled *bool `locationName:"enabled" type:"boolean"` - - // The identifier of the API Key. - Id *string `locationName:"id" type:"string"` - - // The timestamp when the API Key was last updated. - LastUpdatedDate *time.Time `locationName:"lastUpdatedDate" type:"timestamp"` - - // The name of the API Key. - Name *string `locationName:"name" type:"string"` - - // A list of Stage resources that are associated with the ApiKey resource. - StageKeys []string `locationName:"stageKeys" type:"list"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` - - // The value of the API Key. - Value *string `locationName:"value" type:"string"` -} - -// String returns the string representation -func (s ApiKey) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s ApiKey) MarshalFields(e protocol.FieldEncoder) error { - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.CustomerId != nil { - v := *s.CustomerId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "customerId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Enabled != nil { - v := *s.Enabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "enabled", protocol.BoolValue(v), metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.LastUpdatedDate != nil { - v := *s.LastUpdatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "lastUpdatedDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.StageKeys != nil { - v := s.StageKeys - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "stageKeys", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.Value != nil { - v := *s.Value - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "value", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// API stage name of the associated API stage in a usage plan. -type ApiStage struct { - _ struct{} `type:"structure"` - - // API Id of the associated API stage in a usage plan. - ApiId *string `locationName:"apiId" type:"string"` - - // API stage name of the associated API stage in a usage plan. - Stage *string `locationName:"stage" type:"string"` - - // Map containing method level throttling information for API stage in a usage - // plan. - Throttle map[string]ThrottleSettings `locationName:"throttle" type:"map"` -} - -// String returns the string representation -func (s ApiStage) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s ApiStage) MarshalFields(e protocol.FieldEncoder) error { - if s.ApiId != nil { - v := *s.ApiId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "apiId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Stage != nil { - v := *s.Stage - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "stage", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Throttle != nil { - v := s.Throttle - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "throttle", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetFields(k1, v1) - } - ms0.End() - - } - return nil -} - -// Represents an authorization layer for methods. If enabled on a method, API -// Gateway will activate the authorizer when a client calls the method. -// -// Use Lambda Function as Authorizer (https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-use-lambda-authorizer.html) -// Use Cognito User Pool as Authorizer (https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-integrate-with-cognito.html) -type Authorizer struct { - _ struct{} `type:"structure"` - - // Optional customer-defined field, used in OpenAPI imports and exports without - // functional impact. - AuthType *string `locationName:"authType" type:"string"` - - // Specifies the required credentials as an IAM role for API Gateway to invoke - // the authorizer. To specify an IAM role for API Gateway to assume, use the - // role's Amazon Resource Name (ARN). To use resource-based permissions on the - // Lambda function, specify null. - AuthorizerCredentials *string `locationName:"authorizerCredentials" type:"string"` - - // The TTL in seconds of cached authorizer results. If it equals 0, authorization - // caching is disabled. If it is greater than 0, API Gateway will cache authorizer - // responses. If this field is not set, the default value is 300. The maximum - // value is 3600, or 1 hour. - AuthorizerResultTtlInSeconds *int64 `locationName:"authorizerResultTtlInSeconds" type:"integer"` - - // Specifies the authorizer's Uniform Resource Identifier (URI). For TOKEN or - // REQUEST authorizers, this must be a well-formed Lambda function URI, for - // example, arn:aws:apigateway:us-west-2:lambda:path/2015-03-31/functions/arn:aws:lambda:us-west-2:{account_id}:function:{lambda_function_name}/invocations. - // In general, the URI has this form arn:aws:apigateway:{region}:lambda:path/{service_api}, - // where {region} is the same as the region hosting the Lambda function, path - // indicates that the remaining substring in the URI should be treated as the - // path to the resource, including the initial /. For Lambda functions, this - // is usually of the form /2015-03-31/functions/[FunctionARN]/invocations. - AuthorizerUri *string `locationName:"authorizerUri" type:"string"` - - // The identifier for the authorizer resource. - Id *string `locationName:"id" type:"string"` - - // The identity source for which authorization is requested. - // * For a TOKEN or COGNITO_USER_POOLS authorizer, this is required and specifies - // the request header mapping expression for the custom header holding the - // authorization token submitted by the client. For example, if the token - // header name is Auth, the header mapping expression is method.request.header.Auth. - // - // * For the REQUEST authorizer, this is required when authorization caching - // is enabled. The value is a comma-separated string of one or more mapping - // expressions of the specified request parameters. For example, if an Auth - // header, a Name query string parameter are defined as identity sources, - // this value is method.request.header.Auth, method.request.querystring.Name. - // These parameters will be used to derive the authorization caching key - // and to perform runtime validation of the REQUEST authorizer by verifying - // all of the identity-related request parameters are present, not null and - // non-empty. Only when this is true does the authorizer invoke the authorizer - // Lambda function, otherwise, it returns a 401 Unauthorized response without - // calling the Lambda function. The valid value is a string of comma-separated - // mapping expressions of the specified request parameters. When the authorization - // caching is not enabled, this property is optional. - IdentitySource *string `locationName:"identitySource" type:"string"` - - // A validation expression for the incoming identity token. For TOKEN authorizers, - // this value is a regular expression. For COGNITO_USER_POOLS authorizers, API - // Gateway will match the aud field of the incoming token from the client against - // the specified regular expression. It will invoke the authorizer's Lambda - // function when there is a match. Otherwise, it will return a 401 Unauthorized - // response without calling the Lambda function. The validation expression does - // not apply to the REQUEST authorizer. - IdentityValidationExpression *string `locationName:"identityValidationExpression" type:"string"` - - // [Required] The name of the authorizer. - Name *string `locationName:"name" type:"string"` - - // A list of the Amazon Cognito user pool ARNs for the COGNITO_USER_POOLS authorizer. - // Each element is of this format: arn:aws:cognito-idp:{region}:{account_id}:userpool/{user_pool_id}. - // For a TOKEN or REQUEST authorizer, this is not defined. - ProviderARNs []string `locationName:"providerARNs" type:"list"` - - // The authorizer type. Valid values are TOKEN for a Lambda function using a - // single authorization token submitted in a custom header, REQUEST for a Lambda - // function using incoming request parameters, and COGNITO_USER_POOLS for using - // an Amazon Cognito user pool. - Type AuthorizerType `locationName:"type" type:"string" enum:"true"` -} - -// String returns the string representation -func (s Authorizer) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Authorizer) MarshalFields(e protocol.FieldEncoder) error { - if s.AuthType != nil { - v := *s.AuthType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authType", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.AuthorizerCredentials != nil { - v := *s.AuthorizerCredentials - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizerCredentials", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.AuthorizerResultTtlInSeconds != nil { - v := *s.AuthorizerResultTtlInSeconds - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizerResultTtlInSeconds", protocol.Int64Value(v), metadata) - } - if s.AuthorizerUri != nil { - v := *s.AuthorizerUri - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizerUri", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.IdentitySource != nil { - v := *s.IdentitySource - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "identitySource", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.IdentityValidationExpression != nil { - v := *s.IdentityValidationExpression - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "identityValidationExpression", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ProviderARNs != nil { - v := s.ProviderARNs - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "providerARNs", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if len(s.Type) > 0 { - v := s.Type - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "type", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - return nil -} - -// Represents the base path that callers of the API must provide as part of -// the URL after the domain name. -// -// A custom domain name plus a BasePathMapping specification identifies a deployed -// RestApi in a given stage of the owner Account. -// -// Use Custom Domain Names (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html) -type BasePathMapping struct { - _ struct{} `type:"structure"` - - // The base path name that callers of the API must provide as part of the URL - // after the domain name. - BasePath *string `locationName:"basePath" type:"string"` - - // The string identifier of the associated RestApi. - RestApiId *string `locationName:"restApiId" type:"string"` - - // The name of the associated stage. - Stage *string `locationName:"stage" type:"string"` -} - -// String returns the string representation -func (s BasePathMapping) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s BasePathMapping) MarshalFields(e protocol.FieldEncoder) error { - if s.BasePath != nil { - v := *s.BasePath - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "basePath", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RestApiId != nil { - v := *s.RestApiId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "restApiId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Stage != nil { - v := *s.Stage - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "stage", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Configuration settings of a canary deployment. -type CanarySettings struct { - _ struct{} `type:"structure"` - - // The ID of the canary deployment. - DeploymentId *string `locationName:"deploymentId" type:"string"` - - // The percent (0-100) of traffic diverted to a canary deployment. - PercentTraffic *float64 `locationName:"percentTraffic" type:"double"` - - // Stage variables overridden for a canary release deployment, including new - // stage variables introduced in the canary. These stage variables are represented - // as a string-to-string map between stage variable names and their values. - StageVariableOverrides map[string]string `locationName:"stageVariableOverrides" type:"map"` - - // A Boolean flag to indicate whether the canary deployment uses the stage cache - // or not. - UseStageCache *bool `locationName:"useStageCache" type:"boolean"` -} - -// String returns the string representation -func (s CanarySettings) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s CanarySettings) MarshalFields(e protocol.FieldEncoder) error { - if s.DeploymentId != nil { - v := *s.DeploymentId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "deploymentId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.PercentTraffic != nil { - v := *s.PercentTraffic - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "percentTraffic", protocol.Float64Value(v), metadata) - } - if s.StageVariableOverrides != nil { - v := s.StageVariableOverrides - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "stageVariableOverrides", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.UseStageCache != nil { - v := *s.UseStageCache - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "useStageCache", protocol.BoolValue(v), metadata) - } - return nil -} - -// Represents a client certificate used to configure client-side SSL authentication -// while sending requests to the integration endpoint. -// -// Client certificates are used to authenticate an API by the backend server. -// To authenticate an API client (or user), use IAM roles and policies, a custom -// Authorizer or an Amazon Cognito user pool. -// -// Use Client-Side Certificate (https://docs.aws.amazon.com/apigateway/latest/developerguide/getting-started-client-side-ssl-authentication.html) -type Certificate struct { - _ struct{} `type:"structure"` - - // The identifier of the client certificate. - ClientCertificateId *string `locationName:"clientCertificateId" type:"string"` - - // The timestamp when the client certificate was created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // The description of the client certificate. - Description *string `locationName:"description" type:"string"` - - // The timestamp when the client certificate will expire. - ExpirationDate *time.Time `locationName:"expirationDate" type:"timestamp"` - - // The PEM-encoded public key of the client certificate, which can be used to - // configure certificate authentication in the integration endpoint . - PemEncodedCertificate *string `locationName:"pemEncodedCertificate" type:"string"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` -} - -// String returns the string representation -func (s Certificate) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Certificate) MarshalFields(e protocol.FieldEncoder) error { - if s.ClientCertificateId != nil { - v := *s.ClientCertificateId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "clientCertificateId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ExpirationDate != nil { - v := *s.ExpirationDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "expirationDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.PemEncodedCertificate != nil { - v := *s.PemEncodedCertificate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "pemEncodedCertificate", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - return nil -} - -// An immutable representation of a RestApi resource that can be called by users -// using Stages. A deployment must be associated with a Stage for it to be callable -// over the Internet. -// -// To create a deployment, call POST on the Deployments resource of a RestApi. -// To view, update, or delete a deployment, call GET, PATCH, or DELETE on the -// specified deployment resource (/restapis/{restapi_id}/deployments/{deployment_id}). -// -// RestApi, Deployments, Stage, AWS CLI (https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-deployment.html), -// AWS SDKs (https://aws.amazon.com/tools/) -type Deployment struct { - _ struct{} `type:"structure"` - - // A summary of the RestApi at the date and time that the deployment resource - // was created. - ApiSummary map[string]map[string]MethodSnapshot `locationName:"apiSummary" type:"map"` - - // The date and time that the deployment resource was created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // The description for the deployment resource. - Description *string `locationName:"description" type:"string"` - - // The identifier for the deployment resource. - Id *string `locationName:"id" type:"string"` -} - -// String returns the string representation -func (s Deployment) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Deployment) MarshalFields(e protocol.FieldEncoder) error { - if s.ApiSummary != nil { - v := s.ApiSummary - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "apiSummary", metadata) - ms0.Start() - for k1, v1 := range v { - ms1 := ms0.Map(k1) - ms1.Start() - for k2, v2 := range v1 { - ms1.MapSetFields(k2, v2) - } - ms1.End() - } - ms0.End() - - } - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// The input configuration for a canary deployment. -type DeploymentCanarySettings struct { - _ struct{} `type:"structure"` - - // The percentage (0.0-100.0) of traffic routed to the canary deployment. - PercentTraffic *float64 `locationName:"percentTraffic" type:"double"` - - // A stage variable overrides used for the canary release deployment. They can - // override existing stage variables or add new stage variables for the canary - // release deployment. These stage variables are represented as a string-to-string - // map between stage variable names and their values. - StageVariableOverrides map[string]string `locationName:"stageVariableOverrides" type:"map"` - - // A Boolean flag to indicate whether the canary release deployment uses the - // stage cache or not. - UseStageCache *bool `locationName:"useStageCache" type:"boolean"` -} - -// String returns the string representation -func (s DeploymentCanarySettings) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s DeploymentCanarySettings) MarshalFields(e protocol.FieldEncoder) error { - if s.PercentTraffic != nil { - v := *s.PercentTraffic - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "percentTraffic", protocol.Float64Value(v), metadata) - } - if s.StageVariableOverrides != nil { - v := s.StageVariableOverrides - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "stageVariableOverrides", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.UseStageCache != nil { - v := *s.UseStageCache - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "useStageCache", protocol.BoolValue(v), metadata) - } - return nil -} - -// A documentation part for a targeted API entity. -// -// A documentation part consists of a content map (properties) and a target -// (location). The target specifies an API entity to which the documentation -// content applies. The supported API entity types are API, AUTHORIZER, MODEL, -// RESOURCE, METHOD, PATH_PARAMETER, QUERY_PARAMETER, REQUEST_HEADER, REQUEST_BODY, -// RESPONSE, RESPONSE_HEADER, and RESPONSE_BODY. Valid location fields depend -// on the API entity type. All valid fields are not required. -// -// The content map is a JSON string of API-specific key-value pairs. Although -// an API can use any shape for the content map, only the OpenAPI-compliant -// documentation fields will be injected into the associated API entity definition -// in the exported OpenAPI definition file. -// -// Documenting an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-documenting-api.html), -// DocumentationParts -type DocumentationPart struct { - _ struct{} `type:"structure"` - - // The DocumentationPart identifier, generated by API Gateway when the DocumentationPart - // is created. - Id *string `locationName:"id" type:"string"` - - // The location of the API entity to which the documentation applies. Valid - // fields depend on the targeted API entity type. All the valid location fields - // are not required. If not explicitly specified, a valid location field is - // treated as a wildcard and associated documentation content may be inherited - // by matching entities, unless overridden. - Location *DocumentationPartLocation `locationName:"location" type:"structure"` - - // A content map of API-specific key-value pairs describing the targeted API - // entity. The map must be encoded as a JSON string, e.g., "{ \"description\": - // \"The API does ...\" }". Only OpenAPI-compliant documentation-related fields - // from the properties map are exported and, hence, published as part of the - // API entity definitions, while the original documentation parts are exported - // in a OpenAPI extension of x-amazon-apigateway-documentation. - Properties *string `locationName:"properties" type:"string"` -} - -// String returns the string representation -func (s DocumentationPart) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s DocumentationPart) MarshalFields(e protocol.FieldEncoder) error { - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Location != nil { - v := s.Location - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "location", v, metadata) - } - if s.Properties != nil { - v := *s.Properties - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "properties", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Specifies the target API entity to which the documentation applies. -type DocumentationPartLocation struct { - _ struct{} `type:"structure"` - - // The HTTP verb of a method. It is a valid field for the API entity types of - // METHOD, PATH_PARAMETER, QUERY_PARAMETER, REQUEST_HEADER, REQUEST_BODY, RESPONSE, - // RESPONSE_HEADER, and RESPONSE_BODY. The default value is * for any method. - // When an applicable child entity inherits the content of an entity of the - // same type with more general specifications of the other location attributes, - // the child entity's method attribute must match that of the parent entity - // exactly. - Method *string `locationName:"method" type:"string"` - - // The name of the targeted API entity. It is a valid and required field for - // the API entity types of AUTHORIZER, MODEL, PATH_PARAMETER, QUERY_PARAMETER, - // REQUEST_HEADER, REQUEST_BODY and RESPONSE_HEADER. It is an invalid field - // for any other entity type. - Name *string `locationName:"name" type:"string"` - - // The URL path of the target. It is a valid field for the API entity types - // of RESOURCE, METHOD, PATH_PARAMETER, QUERY_PARAMETER, REQUEST_HEADER, REQUEST_BODY, - // RESPONSE, RESPONSE_HEADER, and RESPONSE_BODY. The default value is / for - // the root resource. When an applicable child entity inherits the content of - // another entity of the same type with more general specifications of the other - // location attributes, the child entity's path attribute must match that of - // the parent entity as a prefix. - Path *string `locationName:"path" type:"string"` - - // The HTTP status code of a response. It is a valid field for the API entity - // types of RESPONSE, RESPONSE_HEADER, and RESPONSE_BODY. The default value - // is * for any status code. When an applicable child entity inherits the content - // of an entity of the same type with more general specifications of the other - // location attributes, the child entity's statusCode attribute must match that - // of the parent entity exactly. - StatusCode *string `locationName:"statusCode" type:"string"` - - // [Required] The type of API entity to which the documentation content applies. - // Valid values are API, AUTHORIZER, MODEL, RESOURCE, METHOD, PATH_PARAMETER, - // QUERY_PARAMETER, REQUEST_HEADER, REQUEST_BODY, RESPONSE, RESPONSE_HEADER, - // and RESPONSE_BODY. Content inheritance does not apply to any entity of the - // API, AUTHORIZER, METHOD, MODEL, REQUEST_BODY, or RESOURCE type. - // - // Type is a required field - Type DocumentationPartType `locationName:"type" type:"string" required:"true" enum:"true"` -} - -// String returns the string representation -func (s DocumentationPartLocation) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *DocumentationPartLocation) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "DocumentationPartLocation"} - if len(s.Type) == 0 { - invalidParams.Add(aws.NewErrParamRequired("Type")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s DocumentationPartLocation) MarshalFields(e protocol.FieldEncoder) error { - if s.Method != nil { - v := *s.Method - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "method", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Path != nil { - v := *s.Path - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "path", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.StatusCode != nil { - v := *s.StatusCode - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "statusCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.Type) > 0 { - v := s.Type - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "type", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - return nil -} - -// A snapshot of the documentation of an API. -// -// Publishing API documentation involves creating a documentation version associated -// with an API stage and exporting the versioned documentation to an external -// (e.g., OpenAPI) file. -// -// Documenting an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-documenting-api.html), -// DocumentationPart, DocumentationVersions -type DocumentationVersion struct { - _ struct{} `type:"structure"` - - // The date when the API documentation snapshot is created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // The description of the API documentation snapshot. - Description *string `locationName:"description" type:"string"` - - // The version identifier of the API documentation snapshot. - Version *string `locationName:"version" type:"string"` -} - -// String returns the string representation -func (s DocumentationVersion) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s DocumentationVersion) MarshalFields(e protocol.FieldEncoder) error { - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Version != nil { - v := *s.Version - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "version", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents a custom domain name as a user-friendly host name of an API (RestApi). -// -// When you deploy an API, API Gateway creates a default host name for the API. -// This default API host name is of the {restapi-id}.execute-api.{region}.amazonaws.com -// format. With the default host name, you can access the API's root resource -// with the URL of https://{restapi-id}.execute-api.{region}.amazonaws.com/{stage}/. -// When you set up a custom domain name of apis.example.com for this API, you -// can then access the same resource using the URL of the https://apis.examples.com/myApi, -// where myApi is the base path mapping (BasePathMapping) of your API under -// the custom domain name. -// -// Set a Custom Host Name for an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-custom-domains.html) -type DomainName struct { - _ struct{} `type:"structure"` - - // The reference to an AWS-managed certificate that will be used by edge-optimized - // endpoint for this domain name. AWS Certificate Manager is the only supported - // source. - CertificateArn *string `locationName:"certificateArn" type:"string"` - - // The name of the certificate that will be used by edge-optimized endpoint - // for this domain name. - CertificateName *string `locationName:"certificateName" type:"string"` - - // The timestamp when the certificate that was used by edge-optimized endpoint - // for this domain name was uploaded. - CertificateUploadDate *time.Time `locationName:"certificateUploadDate" type:"timestamp"` - - // The domain name of the Amazon CloudFront distribution associated with this - // custom domain name for an edge-optimized endpoint. You set up this association - // when adding a DNS record pointing the custom domain name to this distribution - // name. For more information about CloudFront distributions, see the Amazon - // CloudFront documentation (https://aws.amazon.com/documentation/cloudfront/). - DistributionDomainName *string `locationName:"distributionDomainName" type:"string"` - - // The region-agnostic Amazon Route 53 Hosted Zone ID of the edge-optimized - // endpoint. The valid value is Z2FDTNDATAQYW2 for all the regions. For more - // information, see Set up a Regional Custom Domain Name (https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html) - // and AWS Regions and Endpoints for API Gateway (https://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region). - DistributionHostedZoneId *string `locationName:"distributionHostedZoneId" type:"string"` - - // The custom domain name as an API host name, for example, my-api.example.com. - DomainName *string `locationName:"domainName" type:"string"` - - // The status of the DomainName migration. The valid values are AVAILABLE and - // UPDATING. If the status is UPDATING, the domain cannot be modified further - // until the existing operation is complete. If it is AVAILABLE, the domain - // can be updated. - DomainNameStatus DomainNameStatus `locationName:"domainNameStatus" type:"string" enum:"true"` - - // An optional text message containing detailed information about status of - // the DomainName migration. - DomainNameStatusMessage *string `locationName:"domainNameStatusMessage" type:"string"` - - // The endpoint configuration of this DomainName showing the endpoint types - // of the domain name. - EndpointConfiguration *EndpointConfiguration `locationName:"endpointConfiguration" type:"structure"` - - // The reference to an AWS-managed certificate that will be used for validating - // the regional domain name. AWS Certificate Manager is the only supported source. - RegionalCertificateArn *string `locationName:"regionalCertificateArn" type:"string"` - - // The name of the certificate that will be used for validating the regional - // domain name. - RegionalCertificateName *string `locationName:"regionalCertificateName" type:"string"` - - // The domain name associated with the regional endpoint for this custom domain - // name. You set up this association by adding a DNS record that points the - // custom domain name to this regional domain name. The regional domain name - // is returned by API Gateway when you create a regional endpoint. - RegionalDomainName *string `locationName:"regionalDomainName" type:"string"` - - // The region-specific Amazon Route 53 Hosted Zone ID of the regional endpoint. - // For more information, see Set up a Regional Custom Domain Name (https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-create.html) - // and AWS Regions and Endpoints for API Gateway (https://docs.aws.amazon.com/general/latest/gr/rande.html#apigateway_region). - RegionalHostedZoneId *string `locationName:"regionalHostedZoneId" type:"string"` - - // The Transport Layer Security (TLS) version + cipher suite for this DomainName. - // The valid values are TLS_1_0 and TLS_1_2. - SecurityPolicy SecurityPolicy `locationName:"securityPolicy" type:"string" enum:"true"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` -} - -// String returns the string representation -func (s DomainName) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s DomainName) MarshalFields(e protocol.FieldEncoder) error { - if s.CertificateArn != nil { - v := *s.CertificateArn - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "certificateArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.CertificateName != nil { - v := *s.CertificateName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "certificateName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.CertificateUploadDate != nil { - v := *s.CertificateUploadDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "certificateUploadDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.DistributionDomainName != nil { - v := *s.DistributionDomainName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "distributionDomainName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.DistributionHostedZoneId != nil { - v := *s.DistributionHostedZoneId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "distributionHostedZoneId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.DomainName != nil { - v := *s.DomainName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "domainName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.DomainNameStatus) > 0 { - v := s.DomainNameStatus - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "domainNameStatus", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.DomainNameStatusMessage != nil { - v := *s.DomainNameStatusMessage - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "domainNameStatusMessage", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.EndpointConfiguration != nil { - v := s.EndpointConfiguration - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "endpointConfiguration", v, metadata) - } - if s.RegionalCertificateArn != nil { - v := *s.RegionalCertificateArn - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "regionalCertificateArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RegionalCertificateName != nil { - v := *s.RegionalCertificateName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "regionalCertificateName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RegionalDomainName != nil { - v := *s.RegionalDomainName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "regionalDomainName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RegionalHostedZoneId != nil { - v := *s.RegionalHostedZoneId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "regionalHostedZoneId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.SecurityPolicy) > 0 { - v := s.SecurityPolicy - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "securityPolicy", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - return nil -} - -// The endpoint configuration to indicate the types of endpoints an API (RestApi) -// or its custom domain name (DomainName) has. -type EndpointConfiguration struct { - _ struct{} `type:"structure"` - - // A list of endpoint types of an API (RestApi) or its custom domain name (DomainName). - // For an edge-optimized API and its custom domain name, the endpoint type is - // "EDGE". For a regional API and its custom domain name, the endpoint type - // is REGIONAL. For a private API, the endpoint type is PRIVATE. - Types []EndpointType `locationName:"types" type:"list"` - - // A list of VpcEndpointIds of an API (RestApi) against which to create Route53 - // ALIASes. It is only supported for PRIVATE endpoint type. - VpcEndpointIds []string `locationName:"vpcEndpointIds" type:"list"` -} - -// String returns the string representation -func (s EndpointConfiguration) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s EndpointConfiguration) MarshalFields(e protocol.FieldEncoder) error { - if s.Types != nil { - v := s.Types - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "types", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if s.VpcEndpointIds != nil { - v := s.VpcEndpointIds - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "vpcEndpointIds", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - return nil -} - -// A gateway response of a given response type and status code, with optional -// response parameters and mapping templates. -// -// For more information about valid gateway response types, see Gateway Response -// Types Supported by API Gateway (https://docs.aws.amazon.com/apigateway/latest/developerguide/supported-gateway-response-types.html) -// -// Example: Get a Gateway Response of a given response type -// -// Request -// -// This example shows how to get a gateway response of the MISSING_AUTHENTICATION_TOKEN -// type. -// GET /restapis/o81lxisefl/gatewayresponses/MISSING_AUTHENTICATION_TOKEN HTTP/1.1 -// Host: beta-apigateway.us-east-1.amazonaws.com Content-Type: application/json -// X-Amz-Date: 20170503T202516Z Authorization: AWS4-HMAC-SHA256 Credential={access-key-id}/20170503/us-east-1/apigateway/aws4_request, -// SignedHeaders=content-type;host;x-amz-date, Signature=1b52460e3159c1a26cff29093855d50ea141c1c5b937528fecaf60f51129697a -// Cache-Control: no-cache Postman-Token: 3b2a1ce9-c848-2e26-2e2f-9c2caefbed45 -// The response type is specified as a URL path. -// -// Response -// -// The successful operation returns the 200 OK status code and a payload similar -// to the following: -// { "_links": { "curies": { "href": "http://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-gatewayresponse-{rel}.html", -// "name": "gatewayresponse", "templated": true }, "self": { "href": "/restapis/o81lxisefl/gatewayresponses/MISSING_AUTHENTICATION_TOKEN" -// }, "gatewayresponse:delete": { "href": "/restapis/o81lxisefl/gatewayresponses/MISSING_AUTHENTICATION_TOKEN" -// }, "gatewayresponse:put": { "href": "/restapis/o81lxisefl/gatewayresponses/{response_type}", -// "templated": true }, "gatewayresponse:update": { "href": "/restapis/o81lxisefl/gatewayresponses/MISSING_AUTHENTICATION_TOKEN" -// } }, "defaultResponse": false, "responseParameters": { "gatewayresponse.header.x-request-path": -// "method.request.path.petId", "gatewayresponse.header.Access-Control-Allow-Origin": -// "'a.b.c'", "gatewayresponse.header.x-request-query": "method.request.querystring.q", -// "gatewayresponse.header.x-request-header": "method.request.header.Accept" -// }, "responseTemplates": { "application/json": "{\n \"message\": $context.error.messageString,\n -// \"type\": \"$context.error.responseType\",\n \"stage\": \"$context.stage\",\n -// \"resourcePath\": \"$context.resourcePath\",\n \"stageVariables.a\": \"$stageVariables.a\",\n -// \"statusCode\": \"'404'\"\n}" }, "responseType": "MISSING_AUTHENTICATION_TOKEN", -// "statusCode": "404" } -// -// Customize Gateway Responses (https://docs.aws.amazon.com/apigateway/latest/developerguide/customize-gateway-responses.html) -type GatewayResponse struct { - _ struct{} `type:"structure"` - - // A Boolean flag to indicate whether this GatewayResponse is the default gateway - // response (true) or not (false). A default gateway response is one generated - // by API Gateway without any customization by an API developer. - DefaultResponse *bool `locationName:"defaultResponse" type:"boolean"` - - // Response parameters (paths, query strings and headers) of the GatewayResponse - // as a string-to-string map of key-value pairs. - ResponseParameters map[string]string `locationName:"responseParameters" type:"map"` - - // Response templates of the GatewayResponse as a string-to-string map of key-value - // pairs. - ResponseTemplates map[string]string `locationName:"responseTemplates" type:"map"` - - // The response type of the associated GatewayResponse. Valid values are - // * ACCESS_DENIED - // - // * API_CONFIGURATION_ERROR - // - // * AUTHORIZER_FAILURE - // - // * AUTHORIZER_CONFIGURATION_ERROR - // - // * BAD_REQUEST_PARAMETERS - // - // * BAD_REQUEST_BODY - // - // * DEFAULT_4XX - // - // * DEFAULT_5XX - // - // * EXPIRED_TOKEN - // - // * INVALID_SIGNATURE - // - // * INTEGRATION_FAILURE - // - // * INTEGRATION_TIMEOUT - // - // * INVALID_API_KEY - // - // * MISSING_AUTHENTICATION_TOKEN - // - // * QUOTA_EXCEEDED - // - // * REQUEST_TOO_LARGE - // - // * RESOURCE_NOT_FOUND - // - // * THROTTLED - // - // * UNAUTHORIZED - // - // * UNSUPPORTED_MEDIA_TYPE - ResponseType GatewayResponseType `locationName:"responseType" type:"string" enum:"true"` - - // The HTTP status code for this GatewayResponse. - StatusCode *string `locationName:"statusCode" type:"string"` -} - -// String returns the string representation -func (s GatewayResponse) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s GatewayResponse) MarshalFields(e protocol.FieldEncoder) error { - if s.DefaultResponse != nil { - v := *s.DefaultResponse - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "defaultResponse", protocol.BoolValue(v), metadata) - } - if s.ResponseParameters != nil { - v := s.ResponseParameters - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseParameters", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.ResponseTemplates != nil { - v := s.ResponseTemplates - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseTemplates", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if len(s.ResponseType) > 0 { - v := s.ResponseType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "responseType", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.StatusCode != nil { - v := *s.StatusCode - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "statusCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents an HTTP, HTTP_PROXY, AWS, AWS_PROXY, or Mock integration. -// -// In the API Gateway console, the built-in Lambda integration is an AWS integration. -// -// Creating an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) -type Integration struct { - _ struct{} `type:"structure"` - - // A list of request parameters whose values API Gateway caches. To be valid - // values for cacheKeyParameters, these parameters must also be specified for - // Method requestParameters. - CacheKeyParameters []string `locationName:"cacheKeyParameters" type:"list"` - - // An API-specific tag group of related cached parameters. To be valid values - // for cacheKeyParameters, these parameters must also be specified for Method - // requestParameters. - CacheNamespace *string `locationName:"cacheNamespace" type:"string"` - - // The (id (https://docs.aws.amazon.com/apigateway/api-reference/resource/vpc-link/#id)) - // of the VpcLink used for the integration when connectionType=VPC_LINK and - // undefined, otherwise. - ConnectionId *string `locationName:"connectionId" type:"string"` - - // The type of the network connection to the integration endpoint. The valid - // value is INTERNET for connections through the public routable internet or - // VPC_LINK for private connections between API Gateway and a network load balancer - // in a VPC. The default value is INTERNET. - ConnectionType ConnectionType `locationName:"connectionType" type:"string" enum:"true"` - - // Specifies how to handle request payload content type conversions. Supported - // values are CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following behaviors: - // - // * CONVERT_TO_BINARY: Converts a request payload from a Base64-encoded - // string to the corresponding binary blob. - // - // * CONVERT_TO_TEXT: Converts a request payload from a binary blob to a - // Base64-encoded string. - // - // If this property is not defined, the request payload will be passed through - // from the method request to integration request without modification, provided - // that the passthroughBehavior is configured to support payload pass-through. - ContentHandling ContentHandlingStrategy `locationName:"contentHandling" type:"string" enum:"true"` - - // Specifies the credentials required for the integration, if any. For AWS integrations, - // three options are available. To specify an IAM Role for API Gateway to assume, - // use the role's Amazon Resource Name (ARN). To require that the caller's identity - // be passed through from the request, specify the string arn:aws:iam::\*:user/\*. - // To use resource-based permissions on supported AWS services, specify null. - Credentials *string `locationName:"credentials" type:"string"` - - // Specifies the integration's HTTP method type. - HttpMethod *string `locationName:"httpMethod" type:"string"` - - // Specifies the integration's responses. - // - // Example: Get integration responses of a method - // - // Request - // GET /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200 - // HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com - // X-Amz-Date: 20160607T191449Z Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160607/us-east-1/apigateway/aws4_request, - // SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} - // Response - // - // The successful response returns 200 OK status and a payload as follows: - // { "_links": { "curies": { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html", - // "name": "integrationresponse", "templated": true }, "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200", - // "title": "200" }, "integrationresponse:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" - // }, "integrationresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" - // } }, "responseParameters": { "method.response.header.Content-Type": "'application/xml'" - // }, "responseTemplates": { "application/json": "$util.urlDecode(\"%3CkinesisStreams%3E#foreach($stream - // in $input.path('$.StreamNames'))%3Cstream%3E%3Cname%3E$stream%3C/name%3E%3C/stream%3E#end%3C/kinesisStreams%3E\")\n" - // }, "statusCode": "200" } - // - // Creating an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) - IntegrationResponses map[string]IntegrationResponse `locationName:"integrationResponses" type:"map"` - - // Specifies how the method request body of an unmapped content type will be - // passed through the integration request to the back end without transformation. - // A content type is unmapped if no mapping template is defined in the integration - // or the content type does not match any of the mapped content types, as specified - // in requestTemplates. The valid value is one of the following: - // - // * WHEN_NO_MATCH: passes the method request body through the integration - // request to the back end without transformation when the method request - // content type does not match any content type associated with the mapping - // templates defined in the integration request. - // - // * WHEN_NO_TEMPLATES: passes the method request body through the integration - // request to the back end without transformation when no mapping template - // is defined in the integration request. If a template is defined when this - // option is selected, the method request of an unmapped content-type will - // be rejected with an HTTP 415 Unsupported Media Type response. - // - // * NEVER: rejects the method request with an HTTP 415 Unsupported Media - // Type response when either the method request content type does not match - // any content type associated with the mapping templates defined in the - // integration request or no mapping template is defined in the integration - // request. - PassthroughBehavior *string `locationName:"passthroughBehavior" type:"string"` - - // A key-value map specifying request parameters that are passed from the method - // request to the back end. The key is an integration request parameter name - // and the associated value is a method request parameter value or static value - // that must be enclosed within single quotes and pre-encoded as required by - // the back end. The method request parameter value must match the pattern of - // method.request.{location}.{name}, where location is querystring, path, or - // header and name must be a valid and unique method request parameter name. - RequestParameters map[string]string `locationName:"requestParameters" type:"map"` - - // Represents a map of Velocity templates that are applied on the request payload - // based on the value of the Content-Type header sent by the client. The content - // type value is the key in this map, and the template (as a String) is the - // value. - RequestTemplates map[string]string `locationName:"requestTemplates" type:"map"` - - // Custom timeout between 50 and 29,000 milliseconds. The default value is 29,000 - // milliseconds or 29 seconds. - TimeoutInMillis *int64 `locationName:"timeoutInMillis" type:"integer"` - - // Specifies an API method integration type. The valid value is one of the following: - // - // * AWS: for integrating the API method request with an AWS service action, - // including the Lambda function-invoking action. With the Lambda function-invoking - // action, this is referred to as the Lambda custom integration. With any - // other AWS service action, this is known as AWS integration. - // - // * AWS_PROXY: for integrating the API method request with the Lambda function-invoking - // action with the client request passed through as-is. This integration - // is also referred to as the Lambda proxy integration. - // - // * HTTP: for integrating the API method request with an HTTP endpoint, - // including a private HTTP endpoint within a VPC. This integration is also - // referred to as the HTTP custom integration. - // - // * HTTP_PROXY: for integrating the API method request with an HTTP endpoint, - // including a private HTTP endpoint within a VPC, with the client request - // passed through as-is. This is also referred to as the HTTP proxy integration. - // - // * MOCK: for integrating the API method request with API Gateway as a "loop-back" - // endpoint without invoking any backend. - // - // For the HTTP and HTTP proxy integrations, each integration can specify a - // protocol (http/https), port and path. Standard 80 and 443 ports are supported - // as well as custom ports above 1024. An HTTP or HTTP proxy integration with - // a connectionType of VPC_LINK is referred to as a private integration and - // uses a VpcLink to connect API Gateway to a network load balancer of a VPC. - Type IntegrationType `locationName:"type" type:"string" enum:"true"` - - // Specifies Uniform Resource Identifier (URI) of the integration endpoint. - // - // * For HTTP or HTTP_PROXY integrations, the URI must be a fully formed, - // encoded HTTP(S) URL according to the RFC-3986 specification (https://en.wikipedia.org/wiki/Uniform_Resource_Identifier), - // for either standard integration, where connectionType is not VPC_LINK, - // or private integration, where connectionType is VPC_LINK. For a private - // HTTP integration, the URI is not used for routing. - // - // * For AWS or AWS_PROXY integrations, the URI is of the form arn:aws:apigateway:{region}:{subdomain.service|service}:path|action/{service_api}. - // Here, {Region} is the API Gateway region (e.g., us-east-1); {service} - // is the name of the integrated AWS service (e.g., s3); and {subdomain} - // is a designated subdomain supported by certain AWS service for fast host-name - // lookup. action can be used for an AWS service action-based API, using - // an Action={name}&{p1}={v1}&p2={v2}... query string. The ensuing {service_api} - // refers to a supported action {name} plus any required input parameters. - // Alternatively, path can be used for an AWS service path-based API. The - // ensuing service_api refers to the path to an AWS service resource, including - // the region of the integrated AWS service, if applicable. For example, - // for integration with the S3 API of GetObject (https://docs.aws.amazon.com/AmazonS3/latest/API/RESTObjectGET.html), - // the uri can be either arn:aws:apigateway:us-west-2:s3:action/GetObject&Bucket={bucket}&Key={key} - // or arn:aws:apigateway:us-west-2:s3:path/{bucket}/{key} - Uri *string `locationName:"uri" type:"string"` -} - -// String returns the string representation -func (s Integration) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Integration) MarshalFields(e protocol.FieldEncoder) error { - if s.CacheKeyParameters != nil { - v := s.CacheKeyParameters - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "cacheKeyParameters", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if s.CacheNamespace != nil { - v := *s.CacheNamespace - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheNamespace", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ConnectionId != nil { - v := *s.ConnectionId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "connectionId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.ConnectionType) > 0 { - v := s.ConnectionType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "connectionType", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if len(s.ContentHandling) > 0 { - v := s.ContentHandling - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "contentHandling", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.Credentials != nil { - v := *s.Credentials - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "credentials", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.HttpMethod != nil { - v := *s.HttpMethod - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "httpMethod", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.IntegrationResponses != nil { - v := s.IntegrationResponses - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "integrationResponses", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetFields(k1, v1) - } - ms0.End() - - } - if s.PassthroughBehavior != nil { - v := *s.PassthroughBehavior - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "passthroughBehavior", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RequestParameters != nil { - v := s.RequestParameters - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "requestParameters", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.RequestTemplates != nil { - v := s.RequestTemplates - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "requestTemplates", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.TimeoutInMillis != nil { - v := *s.TimeoutInMillis - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "timeoutInMillis", protocol.Int64Value(v), metadata) - } - if len(s.Type) > 0 { - v := s.Type - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "type", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.Uri != nil { - v := *s.Uri - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "uri", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents an integration response. The status code must map to an existing -// MethodResponse, and parameters and templates can be used to transform the -// back-end response. -// -// Creating an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) -type IntegrationResponse struct { - _ struct{} `type:"structure"` - - // Specifies how to handle response payload content type conversions. Supported - // values are CONVERT_TO_BINARY and CONVERT_TO_TEXT, with the following behaviors: - // - // * CONVERT_TO_BINARY: Converts a response payload from a Base64-encoded - // string to the corresponding binary blob. - // - // * CONVERT_TO_TEXT: Converts a response payload from a binary blob to a - // Base64-encoded string. - // - // If this property is not defined, the response payload will be passed through - // from the integration response to the method response without modification. - ContentHandling ContentHandlingStrategy `locationName:"contentHandling" type:"string" enum:"true"` - - // A key-value map specifying response parameters that are passed to the method - // response from the back end. The key is a method response header parameter - // name and the mapped value is an integration response header value, a static - // value enclosed within a pair of single quotes, or a JSON expression from - // the integration response body. The mapping key must match the pattern of - // method.response.header.{name}, where name is a valid and unique header name. - // The mapped non-static value must match the pattern of integration.response.header.{name} - // or integration.response.body.{JSON-expression}, where name is a valid and - // unique response header name and JSON-expression is a valid JSON expression - // without the $ prefix. - ResponseParameters map[string]string `locationName:"responseParameters" type:"map"` - - // Specifies the templates used to transform the integration response body. - // Response templates are represented as a key/value map, with a content-type - // as the key and a template as the value. - ResponseTemplates map[string]string `locationName:"responseTemplates" type:"map"` - - // Specifies the regular expression (regex) pattern used to choose an integration - // response based on the response from the back end. For example, if the success - // response returns nothing and the error response returns some string, you - // could use the .+ regex to match error response. However, make sure that the - // error response does not contain any newline (\n) character in such cases. - // If the back end is an AWS Lambda function, the AWS Lambda function error - // header is matched. For all other HTTP and AWS back ends, the HTTP status - // code is matched. - SelectionPattern *string `locationName:"selectionPattern" type:"string"` - - // Specifies the status code that is used to map the integration response to - // an existing MethodResponse. - StatusCode *string `locationName:"statusCode" type:"string"` -} - -// String returns the string representation -func (s IntegrationResponse) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s IntegrationResponse) MarshalFields(e protocol.FieldEncoder) error { - if len(s.ContentHandling) > 0 { - v := s.ContentHandling - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "contentHandling", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.ResponseParameters != nil { - v := s.ResponseParameters - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseParameters", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.ResponseTemplates != nil { - v := s.ResponseTemplates - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseTemplates", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.SelectionPattern != nil { - v := *s.SelectionPattern - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "selectionPattern", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.StatusCode != nil { - v := *s.StatusCode - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "statusCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents a client-facing interface by which the client calls the API to -// access back-end resources. A Method resource is integrated with an Integration -// resource. Both consist of a request and one or more responses. The method -// request takes the client input that is passed to the back end through the -// integration request. A method response returns the output from the back end -// to the client through an integration response. A method request is embodied -// in a Method resource, whereas an integration request is embodied in an Integration -// resource. On the other hand, a method response is represented by a MethodResponse -// resource, whereas an integration response is represented by an IntegrationResponse -// resource. -// -// Example: Retrive the GET method on a specified resource -// -// Request -// -// The following example request retrieves the information about the GET method -// on an API resource (3kzxbg5sa2) of an API (fugvjdxtri). -// GET /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET HTTP/1.1 Content-Type: -// application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date: 20160603T210259Z -// Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160603/us-east-1/apigateway/aws4_request, -// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} -// Response -// -// The successful response returns a 200 OK status code and a payload similar -// to the following: -// { "_links": { "curies": [ { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html", -// "name": "integration", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html", -// "name": "integrationresponse", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html", -// "name": "method", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html", -// "name": "methodresponse", "templated": true } ], "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET", -// "name": "GET", "title": "GET" }, "integration:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" -// }, "method:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" -// }, "method:integration": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" -// }, "method:responses": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", -// "name": "200", "title": "200" }, "method:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" -// }, "methodresponse:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/{status_code}", -// "templated": true } }, "apiKeyRequired": true, "authorizationType": "NONE", -// "httpMethod": "GET", "_embedded": { "method:integration": { "_links": { -// "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" -// }, "integration:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" -// }, "integration:responses": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200", -// "name": "200", "title": "200" }, "integration:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" -// }, "integrationresponse:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/{status_code}", -// "templated": true } }, "cacheKeyParameters": [], "cacheNamespace": "3kzxbg5sa2", -// "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "httpMethod": -// "POST", "passthroughBehavior": "WHEN_NO_MATCH", "requestParameters": { "integration.request.header.Content-Type": -// "'application/x-amz-json-1.1'" }, "requestTemplates": { "application/json": -// "{\n}" }, "type": "AWS", "uri": "arn:aws:apigateway:us-east-1:kinesis:action/ListStreams", -// "_embedded": { "integration:responses": { "_links": { "self": { "href": -// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200", -// "name": "200", "title": "200" }, "integrationresponse:delete": { "href": -// "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" -// }, "integrationresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" -// } }, "responseParameters": { "method.response.header.Content-Type": "'application/xml'" -// }, "responseTemplates": { "application/json": "$util.urlDecode(\"%3CkinesisStreams%3E%23foreach(%24stream%20in%20%24input.path(%27%24.StreamNames%27))%3Cstream%3E%3Cname%3E%24stream%3C%2Fname%3E%3C%2Fstream%3E%23end%3C%2FkinesisStreams%3E\")" -// }, "statusCode": "200" } } }, "method:responses": { "_links": { "self": -// { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", -// "name": "200", "title": "200" }, "methodresponse:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" -// }, "methodresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" -// } }, "responseModels": { "application/json": "Empty" }, "responseParameters": -// { "method.response.header.Content-Type": false }, "statusCode": "200" } -// } } -// In the example above, the response template for the 200 OK response maps -// the JSON output from the ListStreams action in the back end to an XML output. -// The mapping template is URL-encoded as %3CkinesisStreams%3E%23foreach(%24stream%20in%20%24input.path(%27%24.StreamNames%27))%3Cstream%3E%3Cname%3E%24stream%3C%2Fname%3E%3C%2Fstream%3E%23end%3C%2FkinesisStreams%3E -// and the output is decoded using the $util.urlDecode() (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html#util-templat-reference) -// helper function. -// -// MethodResponse, Integration, IntegrationResponse, Resource, Set up an API's -// method (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-method-settings.html) -type Method struct { - _ struct{} `type:"structure"` - - // A boolean flag specifying whether a valid ApiKey is required to invoke this - // method. - ApiKeyRequired *bool `locationName:"apiKeyRequired" type:"boolean"` - - // A list of authorization scopes configured on the method. The scopes are used - // with a COGNITO_USER_POOLS authorizer to authorize the method invocation. - // The authorization works by matching the method scopes against the scopes - // parsed from the access token in the incoming request. The method invocation - // is authorized if any method scopes matches a claimed scope in the access - // token. Otherwise, the invocation is not authorized. When the method scope - // is configured, the client must provide an access token instead of an identity - // token for authorization purposes. - AuthorizationScopes []string `locationName:"authorizationScopes" type:"list"` - - // The method's authorization type. Valid values are NONE for open access, AWS_IAM - // for using AWS IAM permissions, CUSTOM for using a custom authorizer, or COGNITO_USER_POOLS - // for using a Cognito user pool. - AuthorizationType *string `locationName:"authorizationType" type:"string"` - - // The identifier of an Authorizer to use on this method. The authorizationType - // must be CUSTOM. - AuthorizerId *string `locationName:"authorizerId" type:"string"` - - // The method's HTTP verb. - HttpMethod *string `locationName:"httpMethod" type:"string"` - - // Gets the method's integration responsible for passing the client-submitted - // request to the back end and performing necessary transformations to make - // the request compliant with the back end. - // - // Example: - // - // Request - // GET /restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration HTTP/1.1 - // Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com - // Content-Length: 117 X-Amz-Date: 20160613T213210Z Authorization: AWS4-HMAC-SHA256 - // Credential={access_key_ID}/20160613/us-east-1/apigateway/aws4_request, - // SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} - // Response - // - // The successful response returns a 200 OK status code and a payload similar - // to the following: - // { "_links": { "curies": [ { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html", - // "name": "integration", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html", - // "name": "integrationresponse", "templated": true } ], "self": { "href": - // "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" }, "integration:delete": - // { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" - // }, "integration:responses": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200", - // "name": "200", "title": "200" }, "integration:update": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration" - // }, "integrationresponse:put": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/{status_code}", - // "templated": true } }, "cacheKeyParameters": [], "cacheNamespace": "0cjtch", - // "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "httpMethod": - // "POST", "passthroughBehavior": "WHEN_NO_MATCH", "requestTemplates": { "application/json": - // "{\n \"a\": \"$input.params('operand1')\",\n \"b\": \"$input.params('operand2')\", - // \n \"op\": \"$input.params('operator')\" \n}" }, "type": "AWS", "uri": "arn:aws:apigateway:us-west-2:lambda:path//2015-03-31/functions/arn:aws:lambda:us-west-2:123456789012:function:Calc/invocations", - // "_embedded": { "integration:responses": { "_links": { "self": { "href": - // "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200", - // "name": "200", "title": "200" }, "integrationresponse:delete": { "href": - // "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200" - // }, "integrationresponse:update": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/integration/responses/200" - // } }, "responseParameters": { "method.response.header.operator": "integration.response.body.op", - // "method.response.header.operand_2": "integration.response.body.b", "method.response.header.operand_1": - // "integration.response.body.a" }, "responseTemplates": { "application/json": - // "#set($res = $input.path('$'))\n{\n \"result\": \"$res.a, $res.b, $res.op - // => $res.c\",\n \"a\" : \"$res.a\",\n \"b\" : \"$res.b\",\n \"op\" : \"$res.op\",\n - // \"c\" : \"$res.c\"\n}" }, "selectionPattern": "", "statusCode": "200" } - // } } - // - // AWS CLI (https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-integration.html) - MethodIntegration *Integration `locationName:"methodIntegration" type:"structure"` - - // Gets a method response associated with a given HTTP status code. - // - // The collection of method responses are encapsulated in a key-value map, where - // the key is a response's HTTP status code and the value is a MethodResponse - // resource that specifies the response returned to the caller from the back - // end through the integration response. - // - // Example: Get a 200 OK response of a GET method - // - // Request - // GET /restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200 HTTP/1.1 - // Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com - // Content-Length: 117 X-Amz-Date: 20160613T215008Z Authorization: AWS4-HMAC-SHA256 - // Credential={access_key_ID}/20160613/us-east-1/apigateway/aws4_request, - // SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} - // Response - // - // The successful response returns a 200 OK status code and a payload similar - // to the following: - // { "_links": { "curies": { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html", - // "name": "methodresponse", "templated": true }, "self": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200", - // "title": "200" }, "methodresponse:delete": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200" - // }, "methodresponse:update": { "href": "/restapis/uojnr9hd57/resources/0cjtch/methods/GET/responses/200" - // } }, "responseModels": { "application/json": "Empty" }, "responseParameters": - // { "method.response.header.operator": false, "method.response.header.operand_2": - // false, "method.response.header.operand_1": false }, "statusCode": "200" - // } - // - // AWS CLI (https://docs.aws.amazon.com/cli/latest/reference/apigateway/get-method-response.html) - MethodResponses map[string]MethodResponse `locationName:"methodResponses" type:"map"` - - // A human-friendly operation identifier for the method. For example, you can - // assign the operationName of ListPets for the GET /pets method in the PetStore - // example. - OperationName *string `locationName:"operationName" type:"string"` - - // A key-value map specifying data schemas, represented by Model resources, - // (as the mapped value) of the request payloads of given content types (as - // the mapping key). - RequestModels map[string]string `locationName:"requestModels" type:"map"` - - // A key-value map defining required or optional method request parameters that - // can be accepted by API Gateway. A key is a method request parameter name - // matching the pattern of method.request.{location}.{name}, where location - // is querystring, path, or header and name is a valid and unique parameter - // name. The value associated with the key is a Boolean flag indicating whether - // the parameter is required (true) or optional (false). The method request - // parameter names defined here are available in Integration to be mapped to - // integration request parameters or templates. - RequestParameters map[string]bool `locationName:"requestParameters" type:"map"` - - // The identifier of a RequestValidator for request validation. - RequestValidatorId *string `locationName:"requestValidatorId" type:"string"` -} - -// String returns the string representation -func (s Method) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Method) MarshalFields(e protocol.FieldEncoder) error { - if s.ApiKeyRequired != nil { - v := *s.ApiKeyRequired - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "apiKeyRequired", protocol.BoolValue(v), metadata) - } - if s.AuthorizationScopes != nil { - v := s.AuthorizationScopes - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "authorizationScopes", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if s.AuthorizationType != nil { - v := *s.AuthorizationType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizationType", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.AuthorizerId != nil { - v := *s.AuthorizerId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizerId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.HttpMethod != nil { - v := *s.HttpMethod - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "httpMethod", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.MethodIntegration != nil { - v := s.MethodIntegration - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "methodIntegration", v, metadata) - } - if s.MethodResponses != nil { - v := s.MethodResponses - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "methodResponses", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetFields(k1, v1) - } - ms0.End() - - } - if s.OperationName != nil { - v := *s.OperationName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "operationName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.RequestModels != nil { - v := s.RequestModels - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "requestModels", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.RequestParameters != nil { - v := s.RequestParameters - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "requestParameters", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.BoolValue(v1)) - } - ms0.End() - - } - if s.RequestValidatorId != nil { - v := *s.RequestValidatorId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "requestValidatorId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents a method response of a given HTTP status code returned to the -// client. The method response is passed from the back end through the associated -// integration response that can be transformed using a mapping template. -// -// Example: A MethodResponse instance of an API -// -// Request -// -// The example request retrieves a MethodResponse of the 200 status code. -// GET /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200 -// HTTP/1.1 Content-Type: application/json Host: apigateway.us-east-1.amazonaws.com -// X-Amz-Date: 20160603T222952Z Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20160603/us-east-1/apigateway/aws4_request, -// SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} -// Response -// -// The successful response returns 200 OK status and a payload as follows: -// { "_links": { "curies": { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html", -// "name": "methodresponse", "templated": true }, "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", -// "title": "200" }, "methodresponse:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" -// }, "methodresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" -// } }, "responseModels": { "application/json": "Empty" }, "responseParameters": -// { "method.response.header.Content-Type": false }, "statusCode": "200" } -// -// Method, IntegrationResponse, Integration Creating an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) -type MethodResponse struct { - _ struct{} `type:"structure"` - - // Specifies the Model resources used for the response's content-type. Response - // models are represented as a key/value map, with a content-type as the key - // and a Model name as the value. - ResponseModels map[string]string `locationName:"responseModels" type:"map"` - - // A key-value map specifying required or optional response parameters that - // API Gateway can send back to the caller. A key defines a method response - // header and the value specifies whether the associated method response header - // is required or not. The expression of the key must match the pattern method.response.header.{name}, - // where name is a valid and unique header name. API Gateway passes certain - // integration response data to the method response headers specified here according - // to the mapping you prescribe in the API's IntegrationResponse. The integration - // response data that can be mapped include an integration response header expressed - // in integration.response.header.{name}, a static value enclosed within a pair - // of single quotes (e.g., 'application/json'), or a JSON expression from the - // back-end response payload in the form of integration.response.body.{JSON-expression}, - // where JSON-expression is a valid JSON expression without the $ prefix.) - ResponseParameters map[string]bool `locationName:"responseParameters" type:"map"` - - // The method response's status code. - StatusCode *string `locationName:"statusCode" type:"string"` -} - -// String returns the string representation -func (s MethodResponse) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s MethodResponse) MarshalFields(e protocol.FieldEncoder) error { - if s.ResponseModels != nil { - v := s.ResponseModels - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseModels", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.ResponseParameters != nil { - v := s.ResponseParameters - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "responseParameters", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.BoolValue(v1)) - } - ms0.End() - - } - if s.StatusCode != nil { - v := *s.StatusCode - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "statusCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Specifies the method setting properties. -type MethodSetting struct { - _ struct{} `type:"structure"` - - // Specifies whether the cached responses are encrypted. The PATCH path for - // this setting is /{method_setting_key}/caching/dataEncrypted, and the value - // is a Boolean. - CacheDataEncrypted *bool `locationName:"cacheDataEncrypted" type:"boolean"` - - // Specifies the time to live (TTL), in seconds, for cached responses. The higher - // the TTL, the longer the response will be cached. The PATCH path for this - // setting is /{method_setting_key}/caching/ttlInSeconds, and the value is an - // integer. - CacheTtlInSeconds *int64 `locationName:"cacheTtlInSeconds" type:"integer"` - - // Specifies whether responses should be cached and returned for requests. A - // cache cluster must be enabled on the stage for responses to be cached. The - // PATCH path for this setting is /{method_setting_key}/caching/enabled, and - // the value is a Boolean. - CachingEnabled *bool `locationName:"cachingEnabled" type:"boolean"` - - // Specifies whether data trace logging is enabled for this method, which affects - // the log entries pushed to Amazon CloudWatch Logs. The PATCH path for this - // setting is /{method_setting_key}/logging/dataTrace, and the value is a Boolean. - DataTraceEnabled *bool `locationName:"dataTraceEnabled" type:"boolean"` - - // Specifies the logging level for this method, which affects the log entries - // pushed to Amazon CloudWatch Logs. The PATCH path for this setting is /{method_setting_key}/logging/loglevel, - // and the available levels are OFF, ERROR, and INFO. - LoggingLevel *string `locationName:"loggingLevel" type:"string"` - - // Specifies whether Amazon CloudWatch metrics are enabled for this method. - // The PATCH path for this setting is /{method_setting_key}/metrics/enabled, - // and the value is a Boolean. - MetricsEnabled *bool `locationName:"metricsEnabled" type:"boolean"` - - // Specifies whether authorization is required for a cache invalidation request. - // The PATCH path for this setting is /{method_setting_key}/caching/requireAuthorizationForCacheControl, - // and the value is a Boolean. - RequireAuthorizationForCacheControl *bool `locationName:"requireAuthorizationForCacheControl" type:"boolean"` - - // Specifies the throttling burst limit. The PATCH path for this setting is - // /{method_setting_key}/throttling/burstLimit, and the value is an integer. - ThrottlingBurstLimit *int64 `locationName:"throttlingBurstLimit" type:"integer"` - - // Specifies the throttling rate limit. The PATCH path for this setting is /{method_setting_key}/throttling/rateLimit, - // and the value is a double. - ThrottlingRateLimit *float64 `locationName:"throttlingRateLimit" type:"double"` - - // Specifies how to handle unauthorized requests for cache invalidation. The - // PATCH path for this setting is /{method_setting_key}/caching/unauthorizedCacheControlHeaderStrategy, - // and the available values are FAIL_WITH_403, SUCCEED_WITH_RESPONSE_HEADER, - // SUCCEED_WITHOUT_RESPONSE_HEADER. - UnauthorizedCacheControlHeaderStrategy UnauthorizedCacheControlHeaderStrategy `locationName:"unauthorizedCacheControlHeaderStrategy" type:"string" enum:"true"` -} - -// String returns the string representation -func (s MethodSetting) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s MethodSetting) MarshalFields(e protocol.FieldEncoder) error { - if s.CacheDataEncrypted != nil { - v := *s.CacheDataEncrypted - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheDataEncrypted", protocol.BoolValue(v), metadata) - } - if s.CacheTtlInSeconds != nil { - v := *s.CacheTtlInSeconds - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheTtlInSeconds", protocol.Int64Value(v), metadata) - } - if s.CachingEnabled != nil { - v := *s.CachingEnabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cachingEnabled", protocol.BoolValue(v), metadata) - } - if s.DataTraceEnabled != nil { - v := *s.DataTraceEnabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "dataTraceEnabled", protocol.BoolValue(v), metadata) - } - if s.LoggingLevel != nil { - v := *s.LoggingLevel - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "loggingLevel", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.MetricsEnabled != nil { - v := *s.MetricsEnabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "metricsEnabled", protocol.BoolValue(v), metadata) - } - if s.RequireAuthorizationForCacheControl != nil { - v := *s.RequireAuthorizationForCacheControl - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "requireAuthorizationForCacheControl", protocol.BoolValue(v), metadata) - } - if s.ThrottlingBurstLimit != nil { - v := *s.ThrottlingBurstLimit - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "throttlingBurstLimit", protocol.Int64Value(v), metadata) - } - if s.ThrottlingRateLimit != nil { - v := *s.ThrottlingRateLimit - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "throttlingRateLimit", protocol.Float64Value(v), metadata) - } - if len(s.UnauthorizedCacheControlHeaderStrategy) > 0 { - v := s.UnauthorizedCacheControlHeaderStrategy - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "unauthorizedCacheControlHeaderStrategy", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - return nil -} - -// Represents a summary of a Method resource, given a particular date and time. -type MethodSnapshot struct { - _ struct{} `type:"structure"` - - // Specifies whether the method requires a valid ApiKey. - ApiKeyRequired *bool `locationName:"apiKeyRequired" type:"boolean"` - - // The method's authorization type. Valid values are NONE for open access, AWS_IAM - // for using AWS IAM permissions, CUSTOM for using a custom authorizer, or COGNITO_USER_POOLS - // for using a Cognito user pool. - AuthorizationType *string `locationName:"authorizationType" type:"string"` -} - -// String returns the string representation -func (s MethodSnapshot) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s MethodSnapshot) MarshalFields(e protocol.FieldEncoder) error { - if s.ApiKeyRequired != nil { - v := *s.ApiKeyRequired - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "apiKeyRequired", protocol.BoolValue(v), metadata) - } - if s.AuthorizationType != nil { - v := *s.AuthorizationType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "authorizationType", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents the data structure of a method's request or response payload. -// -// A request model defines the data structure of the client-supplied request -// payload. A response model defines the data structure of the response payload -// returned by the back end. Although not required, models are useful for mapping -// payloads between the front end and back end. -// -// A model is used for generating an API's SDK, validating the input request -// body, and creating a skeletal mapping template. -// -// Method, MethodResponse, Models and Mappings (https://docs.aws.amazon.com/apigateway/latest/developerguide/models-mappings.html) -type Model struct { - _ struct{} `type:"structure"` - - // The content-type for the model. - ContentType *string `locationName:"contentType" type:"string"` - - // The description of the model. - Description *string `locationName:"description" type:"string"` - - // The identifier for the model resource. - Id *string `locationName:"id" type:"string"` - - // The name of the model. Must be an alphanumeric string. - Name *string `locationName:"name" type:"string"` - - // The schema for the model. For application/json models, this should be JSON - // schema draft 4 (https://tools.ietf.org/html/draft-zyp-json-schema-04) model. - // Do not include "\*/" characters in the description of any properties because - // such "\*/" characters may be interpreted as the closing marker for comments - // in some languages, such as Java or JavaScript, causing the installation of - // your API's SDK generated by API Gateway to fail. - Schema *string `locationName:"schema" type:"string"` -} - -// String returns the string representation -func (s Model) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Model) MarshalFields(e protocol.FieldEncoder) error { - if s.ContentType != nil { - v := *s.ContentType - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "contentType", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Schema != nil { - v := *s.Schema - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "schema", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// A single patch operation to apply to the specified resource. Please refer -// to http://tools.ietf.org/html/rfc6902#section-4 for an explanation of how -// each operation is used. -type PatchOperation struct { - _ struct{} `type:"structure"` - - // The copy update operation's source as identified by a JSON-Pointer value - // referencing the location within the targeted resource to copy the value from. - // For example, to promote a canary deployment, you copy the canary deployment - // ID to the affiliated deployment ID by calling a PATCH request on a Stage - // resource with "op":"copy", "from":"/canarySettings/deploymentId" and "path":"/deploymentId". - From *string `locationName:"from" type:"string"` - - // An update operation to be performed with this PATCH request. The valid value - // can be add, remove, replace or copy. Not all valid operations are supported - // for a given resource. Support of the operations depends on specific operational - // contexts. Attempts to apply an unsupported operation on a resource will return - // an error message. - Op Op `locationName:"op" type:"string" enum:"true"` - - // The op operation's target, as identified by a JSON Pointer (https://tools.ietf.org/html/draft-ietf-appsawg-json-pointer-08) - // value that references a location within the targeted resource. For example, - // if the target resource has an updateable property of {"name":"value"}, the - // path for this property is /name. If the name property value is a JSON object - // (e.g., {"name": {"child/name": "child-value"}}), the path for the child/name - // property will be /name/child~1name. Any slash ("/") character appearing in - // path names must be escaped with "~1", as shown in the example above. Each - // op operation can have only one path associated with it. - Path *string `locationName:"path" type:"string"` - - // The new target value of the update operation. It is applicable for the add - // or replace operation. When using AWS CLI to update a property of a JSON value, - // enclose the JSON object with a pair of single quotes in a Linux shell, e.g., - // '{"a": ...}'. In a Windows shell, see Using JSON for Parameters (https://docs.aws.amazon.com/cli/latest/userguide/cli-using-param.html#cli-using-param-json). - Value *string `locationName:"value" type:"string"` -} - -// String returns the string representation -func (s PatchOperation) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s PatchOperation) MarshalFields(e protocol.FieldEncoder) error { - if s.From != nil { - v := *s.From - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "from", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.Op) > 0 { - v := s.Op - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "op", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.Path != nil { - v := *s.Path - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "path", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Value != nil { - v := *s.Value - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "value", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Quotas configured for a usage plan. -type QuotaSettings struct { - _ struct{} `type:"structure"` - - // The maximum number of requests that can be made in a given time period. - Limit *int64 `locationName:"limit" type:"integer"` - - // The number of requests subtracted from the given limit in the initial time - // period. - Offset *int64 `locationName:"offset" type:"integer"` - - // The time period in which the limit applies. Valid values are "DAY", "WEEK" - // or "MONTH". - Period QuotaPeriodType `locationName:"period" type:"string" enum:"true"` -} - -// String returns the string representation -func (s QuotaSettings) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s QuotaSettings) MarshalFields(e protocol.FieldEncoder) error { - if s.Limit != nil { - v := *s.Limit - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "limit", protocol.Int64Value(v), metadata) - } - if s.Offset != nil { - v := *s.Offset - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "offset", protocol.Int64Value(v), metadata) - } - if len(s.Period) > 0 { - v := s.Period - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "period", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - return nil -} - -// A set of validation rules for incoming Method requests. -// -// In OpenAPI, a RequestValidator of an API is defined by the x-amazon-apigateway-request-validators.requestValidator -// (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html#api-gateway-swagger-extensions-request-validators.requestValidator.html) -// object. It the referenced using the x-amazon-apigateway-request-validator -// (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-swagger-extensions.html#api-gateway-swagger-extensions-request-validator) -// property. -// -// Enable Basic Request Validation in API Gateway (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-method-request-validation.html) -type RequestValidator struct { - _ struct{} `type:"structure"` - - // The identifier of this RequestValidator. - Id *string `locationName:"id" type:"string"` - - // The name of this RequestValidator - Name *string `locationName:"name" type:"string"` - - // A Boolean flag to indicate whether to validate a request body according to - // the configured Model schema. - ValidateRequestBody *bool `locationName:"validateRequestBody" type:"boolean"` - - // A Boolean flag to indicate whether to validate request parameters (true) - // or not (false). - ValidateRequestParameters *bool `locationName:"validateRequestParameters" type:"boolean"` -} - -// String returns the string representation -func (s RequestValidator) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s RequestValidator) MarshalFields(e protocol.FieldEncoder) error { - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ValidateRequestBody != nil { - v := *s.ValidateRequestBody - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "validateRequestBody", protocol.BoolValue(v), metadata) - } - if s.ValidateRequestParameters != nil { - v := *s.ValidateRequestParameters - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "validateRequestParameters", protocol.BoolValue(v), metadata) - } - return nil -} - -// Represents an API resource. -// -// Create an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) -type Resource struct { - _ struct{} `type:"structure"` - - // The resource's identifier. - Id *string `locationName:"id" type:"string"` - - // The parent resource's identifier. - ParentId *string `locationName:"parentId" type:"string"` - - // The full path for this resource. - Path *string `locationName:"path" type:"string"` - - // The last path segment for this resource. - PathPart *string `locationName:"pathPart" type:"string"` - - // Gets an API resource's method of a given HTTP verb. - // - // The resource methods are a map of methods indexed by methods' HTTP verbs - // enabled on the resource. This method map is included in the 200 OK response - // of the GET /restapis/{restapi_id}/resources/{resource_id} or GET /restapis/{restapi_id}/resources/{resource_id}?embed=methods - // request. - // - // Example: Get the GET method of an API resource - // - // Request - // GET /restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET HTTP/1.1 Content-Type: - // application/json Host: apigateway.us-east-1.amazonaws.com X-Amz-Date: 20170223T031827Z - // Authorization: AWS4-HMAC-SHA256 Credential={access_key_ID}/20170223/us-east-1/apigateway/aws4_request, - // SignedHeaders=content-type;host;x-amz-date, Signature={sig4_hash} - // Response - // { "_links": { "curies": [ { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-{rel}.html", - // "name": "integration", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-integration-response-{rel}.html", - // "name": "integrationresponse", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-{rel}.html", - // "name": "method", "templated": true }, { "href": "https://docs.aws.amazon.com/apigateway/latest/developerguide/restapi-method-response-{rel}.html", - // "name": "methodresponse", "templated": true } ], "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET", - // "name": "GET", "title": "GET" }, "integration:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" - // }, "method:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" - // }, "method:integration": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" - // }, "method:responses": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", - // "name": "200", "title": "200" }, "method:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET" - // }, "methodresponse:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/{status_code}", - // "templated": true } }, "apiKeyRequired": false, "authorizationType": "NONE", - // "httpMethod": "GET", "_embedded": { "method:integration": { "_links": { - // "self": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" - // }, "integration:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" - // }, "integration:responses": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200", - // "name": "200", "title": "200" }, "integration:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration" - // }, "integrationresponse:put": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/{status_code}", - // "templated": true } }, "cacheKeyParameters": [], "cacheNamespace": "3kzxbg5sa2", - // "credentials": "arn:aws:iam::123456789012:role/apigAwsProxyRole", "httpMethod": - // "POST", "passthroughBehavior": "WHEN_NO_MATCH", "requestParameters": { "integration.request.header.Content-Type": - // "'application/x-amz-json-1.1'" }, "requestTemplates": { "application/json": - // "{\n}" }, "type": "AWS", "uri": "arn:aws:apigateway:us-east-1:kinesis:action/ListStreams", - // "_embedded": { "integration:responses": { "_links": { "self": { "href": - // "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200", - // "name": "200", "title": "200" }, "integrationresponse:delete": { "href": - // "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" - // }, "integrationresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/integration/responses/200" - // } }, "responseParameters": { "method.response.header.Content-Type": "'application/xml'" - // }, "responseTemplates": { "application/json": "$util.urlDecode(\"%3CkinesisStreams%3E#foreach($stream - // in $input.path('$.StreamNames'))%3Cstream%3E%3Cname%3E$stream%3C/name%3E%3C/stream%3E#end%3C/kinesisStreams%3E\")\n" - // }, "statusCode": "200" } } }, "method:responses": { "_links": { "self": - // { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200", - // "name": "200", "title": "200" }, "methodresponse:delete": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" - // }, "methodresponse:update": { "href": "/restapis/fugvjdxtri/resources/3kzxbg5sa2/methods/GET/responses/200" - // } }, "responseModels": { "application/json": "Empty" }, "responseParameters": - // { "method.response.header.Content-Type": false }, "statusCode": "200" } - // } } - // If the OPTIONS is enabled on the resource, you can follow the example here - // to get that method. Just replace the GET of the last path segment in the - // request URL with OPTIONS. - ResourceMethods map[string]Method `locationName:"resourceMethods" type:"map"` -} - -// String returns the string representation -func (s Resource) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Resource) MarshalFields(e protocol.FieldEncoder) error { - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ParentId != nil { - v := *s.ParentId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "parentId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Path != nil { - v := *s.Path - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "path", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.PathPart != nil { - v := *s.PathPart - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "pathPart", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ResourceMethods != nil { - v := s.ResourceMethods - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "resourceMethods", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetFields(k1, v1) - } - ms0.End() - - } - return nil -} - -// Represents a REST API. -// -// Create an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-create-api.html) -type RestApi struct { - _ struct{} `type:"structure"` - - // The source of the API key for metering requests according to a usage plan. - // Valid values are: - // * HEADER to read the API key from the X-API-Key header of a request. - // - // * AUTHORIZER to read the API key from the UsageIdentifierKey from a custom - // authorizer. - ApiKeySource ApiKeySourceType `locationName:"apiKeySource" type:"string" enum:"true"` - - // The list of binary media types supported by the RestApi. By default, the - // RestApi supports only UTF-8-encoded text payloads. - BinaryMediaTypes []string `locationName:"binaryMediaTypes" type:"list"` - - // The timestamp when the API was created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // The API's description. - Description *string `locationName:"description" type:"string"` - - // The endpoint configuration of this RestApi showing the endpoint types of - // the API. - EndpointConfiguration *EndpointConfiguration `locationName:"endpointConfiguration" type:"structure"` - - // The API's identifier. This identifier is unique across all of your APIs in - // API Gateway. - Id *string `locationName:"id" type:"string"` - - // A nullable integer that is used to enable compression (with non-negative - // between 0 and 10485760 (10M) bytes, inclusive) or disable compression (with - // a null value) on an API. When compression is enabled, compression or decompression - // is not applied on the payload if the payload size is smaller than this value. - // Setting it to zero allows compression for any payload size. - MinimumCompressionSize *int64 `locationName:"minimumCompressionSize" type:"integer"` - - // The API's name. - Name *string `locationName:"name" type:"string"` - - // A stringified JSON policy document that applies to this RestApi regardless - // of the caller and Method configuration. - Policy *string `locationName:"policy" type:"string"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` - - // A version identifier for the API. - Version *string `locationName:"version" type:"string"` - - // The warning messages reported when failonwarnings is turned on during API - // import. - Warnings []string `locationName:"warnings" type:"list"` -} - -// String returns the string representation -func (s RestApi) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s RestApi) MarshalFields(e protocol.FieldEncoder) error { - if len(s.ApiKeySource) > 0 { - v := s.ApiKeySource - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "apiKeySource", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.BinaryMediaTypes != nil { - v := s.BinaryMediaTypes - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "binaryMediaTypes", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.EndpointConfiguration != nil { - v := s.EndpointConfiguration - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "endpointConfiguration", v, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.MinimumCompressionSize != nil { - v := *s.MinimumCompressionSize - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "minimumCompressionSize", protocol.Int64Value(v), metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Policy != nil { - v := *s.Policy - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "policy", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.Version != nil { - v := *s.Version - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "version", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Warnings != nil { - v := s.Warnings - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "warnings", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - return nil -} - -// A configuration property of an SDK type. -type SdkConfigurationProperty struct { - _ struct{} `type:"structure"` - - // The default value of an SdkType configuration property. - DefaultValue *string `locationName:"defaultValue" type:"string"` - - // The description of an SdkType configuration property. - Description *string `locationName:"description" type:"string"` - - // The user-friendly name of an SdkType configuration property. - FriendlyName *string `locationName:"friendlyName" type:"string"` - - // The name of a an SdkType configuration property. - Name *string `locationName:"name" type:"string"` - - // A boolean flag of an SdkType configuration property to indicate if the associated - // SDK configuration property is required (true) or not (false). - Required *bool `locationName:"required" type:"boolean"` -} - -// String returns the string representation -func (s SdkConfigurationProperty) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s SdkConfigurationProperty) MarshalFields(e protocol.FieldEncoder) error { - if s.DefaultValue != nil { - v := *s.DefaultValue - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "defaultValue", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.FriendlyName != nil { - v := *s.FriendlyName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "friendlyName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Required != nil { - v := *s.Required - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "required", protocol.BoolValue(v), metadata) - } - return nil -} - -// A type of SDK that API Gateway can generate. -type SdkType struct { - _ struct{} `type:"structure"` - - // A list of configuration properties of an SdkType. - ConfigurationProperties []SdkConfigurationProperty `locationName:"configurationProperties" type:"list"` - - // The description of an SdkType. - Description *string `locationName:"description" type:"string"` - - // The user-friendly name of an SdkType instance. - FriendlyName *string `locationName:"friendlyName" type:"string"` - - // The identifier of an SdkType instance. - Id *string `locationName:"id" type:"string"` -} - -// String returns the string representation -func (s SdkType) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s SdkType) MarshalFields(e protocol.FieldEncoder) error { - if s.ConfigurationProperties != nil { - v := s.ConfigurationProperties - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "configurationProperties", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddFields(v1) - } - ls0.End() - - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.FriendlyName != nil { - v := *s.FriendlyName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "friendlyName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// Represents a unique identifier for a version of a deployed RestApi that is -// callable by users. -// -// Deploy an API (https://docs.aws.amazon.com/apigateway/latest/developerguide/how-to-deploy-api.html) -type Stage struct { - _ struct{} `type:"structure"` - - // Settings for logging access in this stage. - AccessLogSettings *AccessLogSettings `locationName:"accessLogSettings" type:"structure"` - - // Specifies whether a cache cluster is enabled for the stage. - CacheClusterEnabled *bool `locationName:"cacheClusterEnabled" type:"boolean"` - - // The size of the cache cluster for the stage, if enabled. - CacheClusterSize CacheClusterSize `locationName:"cacheClusterSize" type:"string" enum:"true"` - - // The status of the cache cluster for the stage, if enabled. - CacheClusterStatus CacheClusterStatus `locationName:"cacheClusterStatus" type:"string" enum:"true"` - - // Settings for the canary deployment in this stage. - CanarySettings *CanarySettings `locationName:"canarySettings" type:"structure"` - - // The identifier of a client certificate for an API stage. - ClientCertificateId *string `locationName:"clientCertificateId" type:"string"` - - // The timestamp when the stage was created. - CreatedDate *time.Time `locationName:"createdDate" type:"timestamp"` - - // The identifier of the Deployment that the stage points to. - DeploymentId *string `locationName:"deploymentId" type:"string"` - - // The stage's description. - Description *string `locationName:"description" type:"string"` - - // The version of the associated API documentation. - DocumentationVersion *string `locationName:"documentationVersion" type:"string"` - - // The timestamp when the stage last updated. - LastUpdatedDate *time.Time `locationName:"lastUpdatedDate" type:"timestamp"` - - // A map that defines the method settings for a Stage resource. Keys (designated - // as /{method_setting_key below) are method paths defined as {resource_path}/{http_method} - // for an individual method override, or /\*/\* for overriding all methods in - // the stage. - MethodSettings map[string]MethodSetting `locationName:"methodSettings" type:"map"` - - // The name of the stage is the first path segment in the Uniform Resource Identifier - // (URI) of a call to API Gateway. Stage names can only contain alphanumeric - // characters, hyphens, and underscores. Maximum length is 128 characters. - StageName *string `locationName:"stageName" type:"string"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` - - // Specifies whether active tracing with X-ray is enabled for the Stage. - TracingEnabled *bool `locationName:"tracingEnabled" type:"boolean"` - - // A map that defines the stage variables for a Stage resource. Variable names - // can have alphanumeric and underscore characters, and the values must match - // [A-Za-z0-9-._~:/?#&=,]+. - Variables map[string]string `locationName:"variables" type:"map"` - - // The ARN of the WebAcl associated with the Stage. - WebAclArn *string `locationName:"webAclArn" type:"string"` -} - -// String returns the string representation -func (s Stage) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s Stage) MarshalFields(e protocol.FieldEncoder) error { - if s.AccessLogSettings != nil { - v := s.AccessLogSettings - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "accessLogSettings", v, metadata) - } - if s.CacheClusterEnabled != nil { - v := *s.CacheClusterEnabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheClusterEnabled", protocol.BoolValue(v), metadata) - } - if len(s.CacheClusterSize) > 0 { - v := s.CacheClusterSize - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheClusterSize", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if len(s.CacheClusterStatus) > 0 { - v := s.CacheClusterStatus - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "cacheClusterStatus", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.CanarySettings != nil { - v := s.CanarySettings - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "canarySettings", v, metadata) - } - if s.ClientCertificateId != nil { - v := *s.ClientCertificateId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "clientCertificateId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.CreatedDate != nil { - v := *s.CreatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "createdDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.DeploymentId != nil { - v := *s.DeploymentId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "deploymentId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.DocumentationVersion != nil { - v := *s.DocumentationVersion - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "documentationVersion", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.LastUpdatedDate != nil { - v := *s.LastUpdatedDate - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "lastUpdatedDate", - protocol.TimeValue{V: v, Format: protocol.UnixTimeFormatName, QuotedFormatTime: true}, metadata) - } - if s.MethodSettings != nil { - v := s.MethodSettings - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "methodSettings", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetFields(k1, v1) - } - ms0.End() - - } - if s.StageName != nil { - v := *s.StageName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "stageName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.TracingEnabled != nil { - v := *s.TracingEnabled - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "tracingEnabled", protocol.BoolValue(v), metadata) - } - if s.Variables != nil { - v := s.Variables - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "variables", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.WebAclArn != nil { - v := *s.WebAclArn - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "webAclArn", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// A reference to a unique stage identified in the format {restApiId}/{stage}. -type StageKey struct { - _ struct{} `type:"structure"` - - // The string identifier of the associated RestApi. - RestApiId *string `locationName:"restApiId" type:"string"` - - // The stage name associated with the stage key. - StageName *string `locationName:"stageName" type:"string"` -} - -// String returns the string representation -func (s StageKey) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s StageKey) MarshalFields(e protocol.FieldEncoder) error { - if s.RestApiId != nil { - v := *s.RestApiId - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "restApiId", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.StageName != nil { - v := *s.StageName - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "stageName", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// The API request rate limits. -type ThrottleSettings struct { - _ struct{} `type:"structure"` - - // The API request burst limit, the maximum rate limit over a time ranging from - // one to a few seconds, depending upon whether the underlying token bucket - // is at its full capacity. - BurstLimit *int64 `locationName:"burstLimit" type:"integer"` - - // The API request steady-state rate limit. - RateLimit *float64 `locationName:"rateLimit" type:"double"` -} - -// String returns the string representation -func (s ThrottleSettings) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s ThrottleSettings) MarshalFields(e protocol.FieldEncoder) error { - if s.BurstLimit != nil { - v := *s.BurstLimit - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "burstLimit", protocol.Int64Value(v), metadata) - } - if s.RateLimit != nil { - v := *s.RateLimit - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "rateLimit", protocol.Float64Value(v), metadata) - } - return nil -} - -// Represents a usage plan than can specify who can assess associated API stages -// with specified request limits and quotas. -// -// In a usage plan, you associate an API by specifying the API's Id and a stage -// name of the specified API. You add plan customers by adding API keys to the -// plan. -// -// Create and Use Usage Plans (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html) -type UsagePlan struct { - _ struct{} `type:"structure"` - - // The associated API stages of a usage plan. - ApiStages []ApiStage `locationName:"apiStages" type:"list"` - - // The description of a usage plan. - Description *string `locationName:"description" type:"string"` - - // The identifier of a UsagePlan resource. - Id *string `locationName:"id" type:"string"` - - // The name of a usage plan. - Name *string `locationName:"name" type:"string"` - - // The AWS Markeplace product identifier to associate with the usage plan as - // a SaaS product on AWS Marketplace. - ProductCode *string `locationName:"productCode" type:"string"` - - // The maximum number of permitted requests per a given unit time interval. - Quota *QuotaSettings `locationName:"quota" type:"structure"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` - - // The request throttle limits of a usage plan. - Throttle *ThrottleSettings `locationName:"throttle" type:"structure"` -} - -// String returns the string representation -func (s UsagePlan) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s UsagePlan) MarshalFields(e protocol.FieldEncoder) error { - if s.ApiStages != nil { - v := s.ApiStages - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "apiStages", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddFields(v1) - } - ls0.End() - - } - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.ProductCode != nil { - v := *s.ProductCode - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "productCode", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Quota != nil { - v := s.Quota - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "quota", v, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.Throttle != nil { - v := s.Throttle - - metadata := protocol.Metadata{} - e.SetFields(protocol.BodyTarget, "throttle", v, metadata) - } - return nil -} - -// Represents a usage plan key to identify a plan customer. -// -// To associate an API stage with a selected API key in a usage plan, you must -// create a UsagePlanKey resource to represent the selected ApiKey. -// -// " -// Create and Use Usage Plans (https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-api-usage-plans.html) -type UsagePlanKey struct { - _ struct{} `type:"structure"` - - // The Id of a usage plan key. - Id *string `locationName:"id" type:"string"` - - // The name of a usage plan key. - Name *string `locationName:"name" type:"string"` - - // The type of a usage plan key. Currently, the valid key type is API_KEY. - Type *string `locationName:"type" type:"string"` - - // The value of a usage plan key. - Value *string `locationName:"value" type:"string"` -} - -// String returns the string representation -func (s UsagePlanKey) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s UsagePlanKey) MarshalFields(e protocol.FieldEncoder) error { - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Type != nil { - v := *s.Type - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "type", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Value != nil { - v := *s.Value - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "value", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - return nil -} - -// A API Gateway VPC link for a RestApi to access resources in an Amazon Virtual -// Private Cloud (VPC). -// -// To enable access to a resource in an Amazon Virtual Private Cloud through -// Amazon API Gateway, you, as an API developer, create a VpcLink resource targeted -// for one or more network load balancers of the VPC and then integrate an API -// method with a private integration that uses the VpcLink. The private integration -// has an integration type of HTTP or HTTP_PROXY and has a connection type of -// VPC_LINK. The integration uses the connectionId property to identify the -// VpcLink used. -type VpcLink struct { - _ struct{} `type:"structure"` - - // The description of the VPC link. - Description *string `locationName:"description" type:"string"` - - // The identifier of the VpcLink. It is used in an Integration to reference - // this VpcLink. - Id *string `locationName:"id" type:"string"` - - // The name used to label and identify the VPC link. - Name *string `locationName:"name" type:"string"` - - // The status of the VPC link. The valid values are AVAILABLE, PENDING, DELETING, - // or FAILED. Deploying an API will wait if the status is PENDING and will fail - // if the status is DELETING. - Status VpcLinkStatus `locationName:"status" type:"string" enum:"true"` - - // A description about the VPC link status. - StatusMessage *string `locationName:"statusMessage" type:"string"` - - // The collection of tags. Each tag element is associated with a given resource. - Tags map[string]string `locationName:"tags" type:"map"` - - // The ARNs of network load balancers of the VPC targeted by the VPC link. The - // network load balancers must be owned by the same AWS account of the API owner. - TargetArns []string `locationName:"targetArns" type:"list"` -} - -// String returns the string representation -func (s VpcLink) String() string { - return awsutil.Prettify(s) -} - -// MarshalFields encodes the AWS API shape using the passed in protocol encoder. -func (s VpcLink) MarshalFields(e protocol.FieldEncoder) error { - if s.Description != nil { - v := *s.Description - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "description", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Id != nil { - v := *s.Id - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "id", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Name != nil { - v := *s.Name - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "name", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if len(s.Status) > 0 { - v := s.Status - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "status", protocol.QuotedValue{ValueMarshaler: v}, metadata) - } - if s.StatusMessage != nil { - v := *s.StatusMessage - - metadata := protocol.Metadata{} - e.SetValue(protocol.BodyTarget, "statusMessage", protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v)}, metadata) - } - if s.Tags != nil { - v := s.Tags - - metadata := protocol.Metadata{} - ms0 := e.Map(protocol.BodyTarget, "tags", metadata) - ms0.Start() - for k1, v1 := range v { - ms0.MapSetValue(k1, protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ms0.End() - - } - if s.TargetArns != nil { - v := s.TargetArns - - metadata := protocol.Metadata{} - ls0 := e.List(protocol.BodyTarget, "targetArns", metadata) - ls0.Start() - for _, v1 := range v { - ls0.ListAddValue(protocol.QuotedValue{ValueMarshaler: protocol.StringValue(v1)}) - } - ls0.End() - - } - return nil -} diff --git a/service/apigateway/internal/awsrestjson/marshal.go b/service/apigateway/internal/awsrestjson/marshal.go new file mode 100644 index 00000000000..a134fe99065 --- /dev/null +++ b/service/apigateway/internal/awsrestjson/marshal.go @@ -0,0 +1,75 @@ +package awsrestjson + +import ( + "github.com/aws/aws-sdk-go-v2/aws/awserr" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol/jsonrpc" + restlegacy "github.com/aws/aws-sdk-go-v2/private/protocol/rest" + restV2 "github.com/aws/aws-sdk-go-v2/private/protocol/rest/v2" + "github.com/aws/aws-sdk-go-v2/service/apigateway/types" +) + +// ProtoGetAPIKeyMarshaler defines marshaler for ProtoGetApiKey operation +type ProtoGetAPIKeyMarshaler struct { + Input *types.GetApiKeyInput +} + +// MarshalOperation is the top level method used within a handler stack to marshal an operation +// This method calls appropriate marshal shape functions as per the input shape and protocol used by the service. +func (m ProtoGetAPIKeyMarshaler) MarshalOperation(r *aws.Request) { + var err error + encoder := restV2.NewEncoder(r.HTTPRequest) + // adds content-type header + encoder.AddHeader("Content-Type").String("application/json") + + err = MarshalGetAPIKeyInputShapeAWSREST(m.Input, encoder) + if err != nil { + r.Error = err + return + } + encoder.Encode() + + // Todo Instead of passing aws.Request directly to MarshalGetAPIKeyInputShapeAWSJSON; + // we should pass the payload as an argument + err = MarshalGetAPIKeyInputShapeAWSJSON(m.Input, r) + if err != nil { + r.Error = err + return + } +} + +// MarshalGetAPIKeyInputShapeAWSREST is a stand alone function used to marshal the HTTP bindings a input shape. +// This method uses the rest encoder utility +func MarshalGetAPIKeyInputShapeAWSREST(input *types.GetApiKeyInput, encoder *restV2.Encoder) error { + // encode using rest encoder utility + if input.ApiKey != nil { + if err := encoder.SetURI("api_Key").String(*input.ApiKey); err != nil { + return awserr.New(aws.ErrCodeSerialization, "failed to marshal API KEY to URI using REST encoder:\n \t %v", err) + } + } + + if input.IncludeValue != nil { + encoder.AddQuery("includeValue").Boolean(*input.IncludeValue) + } + + return nil +} + +// MarshalGetAPIKeyInputShapeAWSJSON is a stand alone function used to marshal the json body +func MarshalGetAPIKeyInputShapeAWSJSON(v *types.GetApiKeyInput, r *aws.Request) error { + // delegate to reflection based marshaling + if t := restlegacy.PayloadType(r.Params); t == "structure" || t == "" { + jsonrpc.Build(r) + } + return r.Error +} + +// GetNamedBuildHandler returns a Named Build Handler for an operation marshal function +func (m ProtoGetAPIKeyMarshaler) GetNamedBuildHandler() aws.NamedHandler { + const BuildHandler = "ProtoGetApiKey.BuildHandler" + return aws.NamedHandler{ + Name: BuildHandler, + Fn: m.MarshalOperation, + } +} diff --git a/service/apigateway/protoGetAPIKeyRequest_test.go b/service/apigateway/protoGetAPIKeyRequest_test.go new file mode 100644 index 00000000000..af1a4dde0fe --- /dev/null +++ b/service/apigateway/protoGetAPIKeyRequest_test.go @@ -0,0 +1,41 @@ +package apigateway_test + +import ( + "context" + "testing" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awstesting/mock" + "github.com/aws/aws-sdk-go-v2/service/apigateway" + "github.com/aws/aws-sdk-go-v2/service/apigateway/types" + "github.com/google/go-cmp/cmp" +) + +func TestProtoGetApiKeyRequest_Diff(t *testing.T) { + svc := apigateway.New(mock.Config()) + + input := types.GetApiKeyInput{ + ApiKey: aws.String("mock key"), + IncludeValue: aws.Bool(true), + } + + request := svc.GetApiKeyRequest(&input) + _, err := request.Send(context.TODO()) + if err != nil { + t.Error(err) + } + + prototypeRequest := svc.ProtoGetAPIKeyRequest(&input) + _, err = prototypeRequest.Send(context.TODO()) + if err != nil { + t.Error(err) + } + + if diff := cmp.Diff(request.HTTPRequest.Header, prototypeRequest.HTTPRequest.Header); diff != "" { + t.Errorf("Found diff: %v", diff) + } + + if diff := cmp.Diff(request.HTTPRequest.URL, prototypeRequest.HTTPRequest.URL); diff != "" { + t.Errorf("Found diff: %v", diff) + } +} diff --git a/service/apigateway/proto_api_op_GetApiKey.go b/service/apigateway/proto_api_op_GetApiKey.go new file mode 100644 index 00000000000..9a28103e108 --- /dev/null +++ b/service/apigateway/proto_api_op_GetApiKey.go @@ -0,0 +1,78 @@ +package apigateway + +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol/restjson" + "github.com/aws/aws-sdk-go-v2/service/apigateway/internal/awsrestjson" + "github.com/aws/aws-sdk-go-v2/service/apigateway/types" +) + +const protoOpGetAPIKey = "GetApiKey" + +// ProtoGetAPIKeyRequest returns a request value for making API operation for +// Amazon API Gateway. +// +// Gets information about the current ApiKey resource. +// +// // Example sending a request using ProtoGetAPIKeyRequest. +// req := client.ProtoGetAPIKeyRequest(params) +// resp, err := req.Send(context.TODO()) +// if err == nil { +// fmt.Println(resp) +// } +func (c *Client) ProtoGetAPIKeyRequest(input *types.GetApiKeyInput) ProtoGetAPIKeyRequest { + op := &aws.Operation{ + Name: protoOpGetAPIKey, + HTTPMethod: "GET", + HTTPPath: "/apikeys/{api_Key}", + } + + if input == nil { + input = &types.GetApiKeyInput{} + } + + req := c.newRequest(op, input, &types.GetApiKeyOutput{}) + // swap existing build handler on svc, with a new named build handler + req.Handlers.Build.Swap(restjson.BuildHandler.Name, awsrestjson.ProtoGetAPIKeyMarshaler{Input: input}.GetNamedBuildHandler()) + return ProtoGetAPIKeyRequest{Request: req, Input: input, Copy: c.ProtoGetAPIKeyRequest} +} + +// ProtoGetAPIKeyRequest is the request type for the +// GetApiKey API operation. +type ProtoGetAPIKeyRequest struct { + *aws.Request + Input *types.GetApiKeyInput + Copy func(*types.GetApiKeyInput) ProtoGetAPIKeyRequest +} + +// Send marshals and sends the GetApiKey API request. +func (r ProtoGetAPIKeyRequest) Send(ctx context.Context) (*ProtoGetAPIKeyResponse, error) { + r.Request.SetContext(ctx) + err := r.Request.Send() + if err != nil { + return nil, err + } + + resp := &ProtoGetAPIKeyResponse{ + GetApiKeyOutput: r.Request.Data.(*types.GetApiKeyOutput), + response: &aws.Response{Request: r.Request}, + } + + return resp, nil +} + +// ProtoGetAPIKeyResponse is the response type for the +// GetApiKey API operation. +type ProtoGetAPIKeyResponse struct { + *types.GetApiKeyOutput + + response *aws.Response +} + +// SDKResponseMetdata returns the response metadata for the +// GetApiKey request. +func (r *ProtoGetAPIKeyResponse) SDKResponseMetdata() *aws.Response { + return r.response +} diff --git a/service/cognitoidentity/customizations_test.go b/service/cognitoidentity/customizations_test.go index 3a08b77b5ec..67854d82a9b 100644 --- a/service/cognitoidentity/customizations_test.go +++ b/service/cognitoidentity/customizations_test.go @@ -8,6 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/cognitoidentity" + "github.com/aws/aws-sdk-go-v2/service/cognitoidentity/types" ) var svc = cognitoidentity.New(unit.Config()) @@ -22,7 +23,7 @@ func TestUnsignedRequests(t *testing.T) { }{ "GetId": { ReqFn: func() reqSigner { - req := svc.GetIdRequest(&cognitoidentity.GetIdInput{ + req := svc.GetIdRequest(&types.GetIdInput{ IdentityPoolId: aws.String("IdentityPoolId"), }) return req @@ -30,7 +31,7 @@ func TestUnsignedRequests(t *testing.T) { }, "GetOpenIdToken": { ReqFn: func() reqSigner { - req := svc.GetOpenIdTokenRequest(&cognitoidentity.GetOpenIdTokenInput{ + req := svc.GetOpenIdTokenRequest(&types.GetOpenIdTokenInput{ IdentityId: aws.String("IdentityId"), }) return req @@ -38,7 +39,7 @@ func TestUnsignedRequests(t *testing.T) { }, "UnlinkIdentity": { ReqFn: func() reqSigner { - req := svc.UnlinkIdentityRequest(&cognitoidentity.UnlinkIdentityInput{ + req := svc.UnlinkIdentityRequest(&types.UnlinkIdentityInput{ IdentityId: aws.String("IdentityId"), Logins: map[string]string{}, LoginsToRemove: []string{}, @@ -48,7 +49,7 @@ func TestUnsignedRequests(t *testing.T) { }, "GetCredentialsForIdentity": { ReqFn: func() reqSigner { - req := svc.GetCredentialsForIdentityRequest(&cognitoidentity.GetCredentialsForIdentityInput{ + req := svc.GetCredentialsForIdentityRequest(&types.GetCredentialsForIdentityInput{ IdentityId: aws.String("IdentityId"), }) return req diff --git a/service/dynamodb/customizations_test.go b/service/dynamodb/customizations_test.go index 7025f9dd7cc..92cc2eb592e 100644 --- a/service/dynamodb/customizations_test.go +++ b/service/dynamodb/customizations_test.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) var db *dynamodb.Client @@ -119,7 +120,7 @@ func TestValidateCRC32IsValid(t *testing.T) { } // CRC check does not affect output parsing - out := req.Data.(*dynamodb.ListTablesOutput) + out := req.Data.(*types.ListTablesOutput) if e, a := "A", out.TableNames[0]; e != a { t.Errorf("expect %q table name, got %q", e, a) } @@ -160,7 +161,7 @@ func TestValidateCRC32DoesNotMatchNoComputeChecksum(t *testing.T) { } // CRC check disabled. Does not affect output parsing - out := req.Data.(*dynamodb.ListTablesOutput) + out := req.Data.(*types.ListTablesOutput) if e, a := "A", out.TableNames[0]; e != a { t.Errorf("expect %q table name, got %q", e, a) } diff --git a/service/dynamodb/dynamodbattribute/decode.go b/service/dynamodb/dynamodbattribute/decode.go index 49e32659dbb..aaf0e84a210 100644 --- a/service/dynamodb/dynamodbattribute/decode.go +++ b/service/dynamodb/dynamodbattribute/decode.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // An Unmarshaler is an interface to provide custom unmarshaling of @@ -30,7 +30,7 @@ import ( // return nil // } type Unmarshaler interface { - UnmarshalDynamoDBAttributeValue(*dynamodb.AttributeValue) error + UnmarshalDynamoDBAttributeValue(value *types.AttributeValue) error } // Unmarshal will unmarshal DynamoDB AttributeValues to Go value types. @@ -74,7 +74,7 @@ type Unmarshaler interface { // and return the error. // // The output value provided must be a non-nil pointer -func Unmarshal(av *dynamodb.AttributeValue, out interface{}) error { +func Unmarshal(av *types.AttributeValue, out interface{}) error { return NewDecoder().Decode(av, out) } @@ -82,16 +82,16 @@ func Unmarshal(av *dynamodb.AttributeValue, out interface{}) error { // a map of AttributeValues. // // The output value provided must be a non-nil pointer -func UnmarshalMap(m map[string]dynamodb.AttributeValue, out interface{}) error { - return NewDecoder().Decode(&dynamodb.AttributeValue{M: m}, out) +func UnmarshalMap(m map[string]types.AttributeValue, out interface{}) error { + return NewDecoder().Decode(&types.AttributeValue{M: m}, out) } // UnmarshalList is an alias for Unmarshal func which unmarshals // a slice of AttributeValues. // // The output value provided must be a non-nil pointer -func UnmarshalList(l []dynamodb.AttributeValue, out interface{}) error { - return NewDecoder().Decode(&dynamodb.AttributeValue{L: l}, out) +func UnmarshalList(l []types.AttributeValue, out interface{}) error { + return NewDecoder().Decode(&types.AttributeValue{L: l}, out) } // UnmarshalListOfMaps is an alias for Unmarshal func which unmarshals a @@ -101,10 +101,10 @@ func UnmarshalList(l []dynamodb.AttributeValue, out interface{}) error { // Query API call. // // The output value provided must be a non-nil pointer -func UnmarshalListOfMaps(l []map[string]dynamodb.AttributeValue, out interface{}) error { - items := make([]dynamodb.AttributeValue, len(l)) +func UnmarshalListOfMaps(l []map[string]types.AttributeValue, out interface{}) error { + items := make([]types.AttributeValue, len(l)) for i, m := range l { - items[i] = dynamodb.AttributeValue{M: m} + items[i] = types.AttributeValue{M: m} } return UnmarshalList(items, out) @@ -140,7 +140,7 @@ func NewDecoder(opts ...func(*Decoder)) *Decoder { // to the provide Go value type. // // The output value provided must be a non-nil pointer -func (d *Decoder) Decode(av *dynamodb.AttributeValue, out interface{}, opts ...func(*Decoder)) error { +func (d *Decoder) Decode(av *types.AttributeValue, out interface{}, opts ...func(*Decoder)) error { v := reflect.ValueOf(out) if v.Kind() != reflect.Ptr || v.IsNil() || !v.IsValid() { return &InvalidUnmarshalError{Type: reflect.TypeOf(out)} @@ -155,7 +155,7 @@ var byteSliceSlicetype = reflect.TypeOf([][]byte(nil)) var numberType = reflect.TypeOf(Number("")) var timeType = reflect.TypeOf(time.Time{}) -func (d *Decoder) decode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { +func (d *Decoder) decode(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { var u Unmarshaler if av == nil || av.NULL != nil { u, v = indirect(v, true) @@ -277,7 +277,7 @@ func (d *Decoder) decodeBinarySet(bs [][]byte, v reflect.Value) error { v.SetLen(i + 1) u, elem := indirect(v.Index(i), false) if u != nil { - return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{BS: bs}) + return u.UnmarshalDynamoDBAttributeValue(&types.AttributeValue{BS: bs}) } if err := d.decodeBinary(bs[i], elem); err != nil { return err @@ -399,7 +399,7 @@ func (d *Decoder) decodeNumberSet(ns []string, v reflect.Value) error { v.SetLen(i + 1) u, elem := indirect(v.Index(i), false) if u != nil { - return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{NS: ns}) + return u.UnmarshalDynamoDBAttributeValue(&types.AttributeValue{NS: ns}) } if err := d.decodeNumber(&ns[i], elem, tag{}); err != nil { return err @@ -409,7 +409,7 @@ func (d *Decoder) decodeNumberSet(ns []string, v reflect.Value) error { return nil } -func (d *Decoder) decodeList(avList []dynamodb.AttributeValue, v reflect.Value) error { +func (d *Decoder) decodeList(avList []types.AttributeValue, v reflect.Value) error { switch v.Kind() { case reflect.Slice: // Make room for the slice elements if needed @@ -443,7 +443,7 @@ func (d *Decoder) decodeList(avList []dynamodb.AttributeValue, v reflect.Value) return nil } -func (d *Decoder) decodeMap(avMap map[string]dynamodb.AttributeValue, v reflect.Value) error { +func (d *Decoder) decodeMap(avMap map[string]types.AttributeValue, v reflect.Value) error { switch v.Kind() { case reflect.Map: t := v.Type() @@ -551,7 +551,7 @@ func (d *Decoder) decodeStringSet(ss []string, v reflect.Value) error { v.SetLen(i + 1) u, elem := indirect(v.Index(i), false) if u != nil { - return u.UnmarshalDynamoDBAttributeValue(&dynamodb.AttributeValue{SS: ss}) + return u.UnmarshalDynamoDBAttributeValue(&types.AttributeValue{SS: ss}) } if err := d.decodeString(&ss[i], elem, tag{}); err != nil { return err diff --git a/service/dynamodb/dynamodbattribute/decode_test.go b/service/dynamodb/dynamodbattribute/decode_test.go index 6309b29f782..2b1d49eb5be 100644 --- a/service/dynamodb/dynamodbattribute/decode_test.go +++ b/service/dynamodb/dynamodbattribute/decode_test.go @@ -1,5 +1,7 @@ package dynamodbattribute +// code generation? No + import ( "fmt" "reflect" @@ -9,7 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) func TestUnmarshalErrorTypes(t *testing.T) { @@ -28,7 +30,7 @@ func TestUnmarshalShared(t *testing.T) { func TestUnmarshal(t *testing.T) { cases := []struct { - in *dynamodb.AttributeValue + in *types.AttributeValue actual, expected interface{} err error }{ @@ -36,35 +38,35 @@ func TestUnmarshal(t *testing.T) { // Sets //------------ { - in: &dynamodb.AttributeValue{BS: [][]byte{ + in: &types.AttributeValue{BS: [][]byte{ {48, 49}, {50, 51}, }}, actual: &[][]byte{}, expected: [][]byte{{48, 49}, {50, 51}}, }, { - in: &dynamodb.AttributeValue{NS: []string{ + in: &types.AttributeValue{NS: []string{ "123", "321", }}, actual: &[]int{}, expected: []int{123, 321}, }, { - in: &dynamodb.AttributeValue{NS: []string{ + in: &types.AttributeValue{NS: []string{ "123", "321", }}, actual: &[]interface{}{}, expected: []interface{}{123., 321.}, }, { - in: &dynamodb.AttributeValue{SS: []string{ + in: &types.AttributeValue{SS: []string{ "abc", "123", }}, actual: &[]string{}, expected: &[]string{"abc", "123"}, }, { - in: &dynamodb.AttributeValue{SS: []string{ + in: &types.AttributeValue{SS: []string{ "abc", "123", }}, actual: &[]*string{}, @@ -74,7 +76,7 @@ func TestUnmarshal(t *testing.T) { // Interfaces //------------ { - in: &dynamodb.AttributeValue{B: []byte{48, 49}}, + in: &types.AttributeValue{B: []byte{48, 49}}, actual: func() interface{} { var v interface{} return &v @@ -82,7 +84,7 @@ func TestUnmarshal(t *testing.T) { expected: []byte{48, 49}, }, { - in: &dynamodb.AttributeValue{BS: [][]byte{ + in: &types.AttributeValue{BS: [][]byte{ {48, 49}, {50, 51}, }}, actual: func() interface{} { @@ -92,7 +94,7 @@ func TestUnmarshal(t *testing.T) { expected: [][]byte{{48, 49}, {50, 51}}, }, { - in: &dynamodb.AttributeValue{BOOL: aws.Bool(true)}, + in: &types.AttributeValue{BOOL: aws.Bool(true)}, actual: func() interface{} { var v interface{} return &v @@ -100,7 +102,7 @@ func TestUnmarshal(t *testing.T) { expected: bool(true), }, { - in: &dynamodb.AttributeValue{L: []dynamodb.AttributeValue{ + in: &types.AttributeValue{L: []types.AttributeValue{ {S: aws.String("abc")}, {S: aws.String("123")}, }}, actual: func() interface{} { @@ -110,7 +112,7 @@ func TestUnmarshal(t *testing.T) { expected: []interface{}{"abc", "123"}, }, { - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "123": {S: aws.String("abc")}, "abc": {S: aws.String("123")}, }}, @@ -121,7 +123,7 @@ func TestUnmarshal(t *testing.T) { expected: map[string]interface{}{"123": "abc", "abc": "123"}, }, { - in: &dynamodb.AttributeValue{N: aws.String("123")}, + in: &types.AttributeValue{N: aws.String("123")}, actual: func() interface{} { var v interface{} return &v @@ -129,7 +131,7 @@ func TestUnmarshal(t *testing.T) { expected: float64(123), }, { - in: &dynamodb.AttributeValue{NS: []string{ + in: &types.AttributeValue{NS: []string{ "123", "321", }}, actual: func() interface{} { @@ -139,7 +141,7 @@ func TestUnmarshal(t *testing.T) { expected: []float64{123., 321.}, }, { - in: &dynamodb.AttributeValue{S: aws.String("123")}, + in: &types.AttributeValue{S: aws.String("123")}, actual: func() interface{} { var v interface{} return &v @@ -147,7 +149,7 @@ func TestUnmarshal(t *testing.T) { expected: "123", }, { - in: &dynamodb.AttributeValue{SS: []string{ + in: &types.AttributeValue{SS: []string{ "123", "321", }}, actual: func() interface{} { @@ -157,7 +159,7 @@ func TestUnmarshal(t *testing.T) { expected: []string{"123", "321"}, }, { - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "abc": {S: aws.String("123")}, "Cba": {S: aws.String("321")}, }}, @@ -165,7 +167,7 @@ func TestUnmarshal(t *testing.T) { expected: struct{ Abc, Cba string }{Abc: "123", Cba: "321"}, }, { - in: &dynamodb.AttributeValue{N: aws.String("512")}, + in: &types.AttributeValue{N: aws.String("512")}, actual: new(uint8), err: &UnmarshalTypeError{ Value: fmt.Sprintf("number overflow, 512"), @@ -185,7 +187,7 @@ func TestUnmarshal(t *testing.T) { func TestInterfaceInput(t *testing.T) { var v interface{} expected := []interface{}{"abc", "123"} - err := Unmarshal(&dynamodb.AttributeValue{L: []dynamodb.AttributeValue{ + err := Unmarshal(&types.AttributeValue{L: []types.AttributeValue{ {S: aws.String("abc")}, {S: aws.String("123")}, }}, &v) assertConvertTest(t, v, expected, err, nil) @@ -193,12 +195,12 @@ func TestInterfaceInput(t *testing.T) { func TestUnmarshalError(t *testing.T) { cases := []struct { - in *dynamodb.AttributeValue + in *types.AttributeValue actual, expected interface{} err error }{ { - in: &dynamodb.AttributeValue{}, + in: &types.AttributeValue{}, actual: int(0), expected: nil, err: &InvalidUnmarshalError{Type: reflect.TypeOf(int(0))}, @@ -224,12 +226,12 @@ func TestUnmarshalListShared(t *testing.T) { func TestUnmarshalListError(t *testing.T) { cases := []struct { - in []dynamodb.AttributeValue + in []types.AttributeValue actual, expected interface{} err error }{ { - in: []dynamodb.AttributeValue{}, + in: []types.AttributeValue{}, actual: []interface{}{}, expected: nil, err: &InvalidUnmarshalError{Type: reflect.TypeOf([]interface{}{})}, @@ -255,18 +257,18 @@ func TestUnmarshalMapShared(t *testing.T) { func TestUnmarshalMapError(t *testing.T) { cases := []struct { - in map[string]dynamodb.AttributeValue + in map[string]types.AttributeValue actual, expected interface{} err error }{ { - in: map[string]dynamodb.AttributeValue{}, + in: map[string]types.AttributeValue{}, actual: map[string]interface{}{}, expected: nil, err: &InvalidUnmarshalError{Type: reflect.TypeOf(map[string]interface{}{})}, }, { - in: map[string]dynamodb.AttributeValue{ + in: map[string]types.AttributeValue{ "BOOL": {BOOL: aws.Bool(true)}, }, actual: &map[int]interface{}{}, @@ -290,14 +292,14 @@ func TestUnmarshalListOfMaps(t *testing.T) { } cases := []struct { - in []map[string]dynamodb.AttributeValue + in []map[string]types.AttributeValue actual, expected interface{} err error }{ { // Simple map conversion. - in: []map[string]dynamodb.AttributeValue{ + in: []map[string]types.AttributeValue{ { - "Value": dynamodb.AttributeValue{ + "Value": types.AttributeValue{ BOOL: aws.Bool(true), }, }, @@ -310,12 +312,12 @@ func TestUnmarshalListOfMaps(t *testing.T) { }, }, { // attribute to struct. - in: []map[string]dynamodb.AttributeValue{ + in: []map[string]types.AttributeValue{ { - "Value": dynamodb.AttributeValue{ + "Value": types.AttributeValue{ S: aws.String("abc"), }, - "Value2": dynamodb.AttributeValue{ + "Value2": types.AttributeValue{ N: aws.String("123"), }, }, @@ -345,7 +347,7 @@ type unmarshalUnmarshaler struct { Value4 time.Time } -func (u *unmarshalUnmarshaler) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error { +func (u *unmarshalUnmarshaler) UnmarshalDynamoDBAttributeValue(av *types.AttributeValue) error { if av.M == nil { return fmt.Errorf("expected AttributeValue to be map") } @@ -395,8 +397,8 @@ func (u *unmarshalUnmarshaler) UnmarshalDynamoDBAttributeValue(av *dynamodb.Attr func TestUnmarshalUnmashaler(t *testing.T) { u := &unmarshalUnmarshaler{} - av := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + av := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "abc": {S: aws.String("value")}, "def": {N: aws.String("123")}, "ghi": {BOOL: aws.Bool(true)}, @@ -425,8 +427,8 @@ func TestUnmarshalUnmashaler(t *testing.T) { func TestDecodeUseNumber(t *testing.T) { u := map[string]interface{}{} - av := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + av := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "abc": {S: aws.String("value")}, "def": {N: aws.String("123")}, "ghi": {BOOL: aws.Bool(true)}, @@ -455,8 +457,8 @@ func TestDecodeUseNumber(t *testing.T) { func TestDecodeUseNumberNumberSet(t *testing.T) { u := map[string]interface{}{} - av := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + av := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "ns": { NS: []string{ "123", "321", @@ -495,8 +497,8 @@ func TestDecodeEmbeddedPointerStruct(t *testing.T) { *B *C } - av := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + av := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Aint": { N: aws.String("321"), }, @@ -527,7 +529,7 @@ func TestDecodeEmbeddedPointerStruct(t *testing.T) { func TestDecodeBooleanOverlay(t *testing.T) { type BooleanOverlay bool - av := &dynamodb.AttributeValue{ + av := &types.AttributeValue{ BOOL: aws.Bool(true), } @@ -557,8 +559,8 @@ func TestDecodeUnixTime(t *testing.T) { Typed: UnixTime(time.Unix(789, 0)), } - input := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + input := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Normal": { S: aws.String("1970-01-01T00:02:03Z"), }, @@ -592,8 +594,8 @@ func TestDecodeAliasedUnixTime(t *testing.T) { Tagged: AliasedTime(time.Unix(456, 0)), } - input := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + input := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Normal": { S: aws.String("1970-01-01T00:02:03Z"), }, diff --git a/service/dynamodb/dynamodbattribute/empty_collections_test.go b/service/dynamodb/dynamodbattribute/empty_collections_test.go index eadc7376410..d5a323077d9 100644 --- a/service/dynamodb/dynamodbattribute/empty_collections_test.go +++ b/service/dynamodb/dynamodbattribute/empty_collections_test.go @@ -5,7 +5,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) type testEmptyCollectionsNumericalScalars struct { @@ -105,13 +105,13 @@ type testEmptyCollectionStructOmitted struct { } var sharedEmptyCollectionsTestCases = map[string]struct { - in *dynamodb.AttributeValue + in *types.AttributeValue actual, expected interface{} err error }{ "scalars with zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "String": {NULL: aws.Bool(true)}, "Uint8": {N: aws.String("0")}, "Uint16": {N: aws.String("0")}, @@ -129,8 +129,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { expected: testEmptyCollectionsNumericalScalars{}, }, "scalars with non-zero values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "String": {S: aws.String("test string")}, "Uint8": {N: aws.String("1")}, "Uint16": {N: aws.String("2")}, @@ -160,13 +160,13 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "omittable scalars with zero value": { - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{}}, + in: &types.AttributeValue{M: map[string]types.AttributeValue{}}, actual: &testEmptyCollectionsOmittedNumericalScalars{}, expected: testEmptyCollectionsOmittedNumericalScalars{}, }, "omittable scalars with non-zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "String": {S: aws.String("test string")}, "Uint8": {N: aws.String("1")}, "Uint16": {N: aws.String("2")}, @@ -196,8 +196,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "nil pointer scalars": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrString": {NULL: aws.Bool(true)}, "PtrUint8": {NULL: aws.Bool(true)}, "PtrUint16": {NULL: aws.Bool(true)}, @@ -215,8 +215,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { expected: testEmptyCollectionsPtrScalars{}, }, "non-nil pointer to scalars with zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrString": {NULL: aws.Bool(true)}, "PtrUint8": {N: aws.String("0")}, "PtrUint16": {N: aws.String("0")}, @@ -245,8 +245,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "pointer scalars non-nil non-zero": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrString": {S: aws.String("test string")}, "PtrUint8": {N: aws.String("1")}, "PtrUint16": {N: aws.String("2")}, @@ -276,15 +276,15 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "omittable nil pointer scalars": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{}, + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{}, }, actual: &testEmptyCollectionsOmittedPtrNumericalScalars{}, expected: testEmptyCollectionsOmittedPtrNumericalScalars{}, }, "omittable non-nil pointer to scalars with zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrUint8": {N: aws.String("0")}, "PtrUint16": {N: aws.String("0")}, "PtrUint32": {N: aws.String("0")}, @@ -312,8 +312,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "omittable non-nil pointer to non-zero scalar": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrUint8": {N: aws.String("1")}, "PtrUint16": {N: aws.String("2")}, "PtrUint32": {N: aws.String("3")}, @@ -341,8 +341,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "maps slices nil values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Map": {NULL: aws.Bool(true)}, "Slice": {NULL: aws.Bool(true)}, "ByteSlice": {NULL: aws.Bool(true)}, @@ -357,10 +357,10 @@ var sharedEmptyCollectionsTestCases = map[string]struct { expected: testEmptyCollectionTypes{}, }, "maps slices zero values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Map": {M: map[string]dynamodb.AttributeValue{}}, - "Slice": {L: []dynamodb.AttributeValue{}}, + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Map": {M: map[string]types.AttributeValue{}}, + "Slice": {L: []types.AttributeValue{}}, "ByteSlice": {B: []byte{}}, "ByteArray": {B: make([]byte, 4)}, "ZeroArray": {B: make([]byte, 0)}, @@ -382,14 +382,14 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "maps slices non-zero values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Map": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "key": {S: aws.String("value")}, }, }, - "Slice": {L: []dynamodb.AttributeValue{{S: aws.String("test")}, {S: aws.String("slice")}}}, + "Slice": {L: []types.AttributeValue{{S: aws.String("test")}, {S: aws.String("slice")}}}, "ByteSlice": {B: []byte{0, 1}}, "ByteArray": {B: []byte{0, 1, 2, 3}}, "ZeroArray": {B: make([]byte, 0)}, @@ -411,8 +411,8 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "omittable maps slices nil values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "ByteArray": {B: make([]byte, 4)}, }, }, @@ -420,10 +420,10 @@ var sharedEmptyCollectionsTestCases = map[string]struct { expected: testEmptyCollectionTypesOmitted{}, }, "omittable maps slices zero values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Map": {M: map[string]dynamodb.AttributeValue{}}, - "Slice": {L: []dynamodb.AttributeValue{}}, + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Map": {M: map[string]types.AttributeValue{}}, + "Slice": {L: []types.AttributeValue{}}, "ByteSlice": {B: []byte{}}, "ByteArray": {B: make([]byte, 4)}, "BinarySet": {BS: [][]byte{}}, @@ -443,14 +443,14 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "omittable maps slices non-zero values": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Map": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "key": {S: aws.String("value")}, }, }, - "Slice": {L: []dynamodb.AttributeValue{{S: aws.String("test")}, {S: aws.String("slice")}}}, + "Slice": {L: []types.AttributeValue{{S: aws.String("test")}, {S: aws.String("slice")}}}, "ByteSlice": {B: []byte{0, 1}}, "ByteArray": {B: []byte{0, 1, 2, 3}}, "BinarySet": {BS: [][]byte{{0, 1}, {2, 3}}}, @@ -471,10 +471,10 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "structs with members zero": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Struct": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Int": {N: aws.String("0")}, }, }, @@ -491,15 +491,15 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }{}, }, "structs with members non-zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Struct": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Int": {N: aws.String("1")}, }, }, "PtrStruct": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Int": {N: aws.String("1")}, }, }, @@ -518,9 +518,9 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }, }, "struct with omittable members zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Struct": {M: map[string]dynamodb.AttributeValue{}}, + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Struct": {M: map[string]types.AttributeValue{}}, "PtrStruct": {NULL: aws.Bool(true)}, }, }, @@ -534,9 +534,9 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }{}, }, "omittable struct with omittable members zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Struct": {M: map[string]dynamodb.AttributeValue{}}, + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Struct": {M: map[string]types.AttributeValue{}}, }, }, actual: &struct { @@ -549,16 +549,16 @@ var sharedEmptyCollectionsTestCases = map[string]struct { }{}, }, "omittable struct with omittable members non-zero value": { - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Struct": { - M: map[string]dynamodb.AttributeValue{ - "Slice": {L: []dynamodb.AttributeValue{{S: aws.String("test")}}}, + M: map[string]types.AttributeValue{ + "Slice": {L: []types.AttributeValue{{S: aws.String("test")}}}, }, }, "InitPtrStruct": { - M: map[string]dynamodb.AttributeValue{ - "Slice": {L: []dynamodb.AttributeValue{{S: aws.String("test")}}}, + M: map[string]types.AttributeValue{ + "Slice": {L: []types.AttributeValue{{S: aws.String("test")}}}, }, }, }, @@ -594,8 +594,8 @@ func TestEmptyCollectionsSpecialCases(t *testing.T) { OmittedPtrString *string `dynamodbav:",omitempty"` } - expectedEncode := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expectedEncode := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "PtrString": {NULL: aws.Bool(true)}, }, } @@ -613,7 +613,7 @@ func TestEmptyCollectionsSpecialCases(t *testing.T) { } var actualDecode SpecialCases - err = Unmarshal(&dynamodb.AttributeValue{}, &actualDecode) + err = Unmarshal(&types.AttributeValue{}, &actualDecode) if err != nil { t.Fatalf("expected no err got %v", err) } diff --git a/service/dynamodb/dynamodbattribute/encode.go b/service/dynamodb/dynamodbattribute/encode.go index c1462fe3a6a..328356d1183 100644 --- a/service/dynamodb/dynamodbattribute/encode.go +++ b/service/dynamodb/dynamodbattribute/encode.go @@ -7,7 +7,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // An UnixTime provides aliasing of time.Time into a type that when marshaled @@ -26,7 +26,7 @@ type UnixTime time.Time // MarshalDynamoDBAttributeValue implements the Marshaler interface so that // the UnixTime can be marshaled from to a DynamoDB AttributeValue number // value encoded in the number of seconds since January 1, 1970 UTC. -func (e UnixTime) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error { +func (e UnixTime) MarshalDynamoDBAttributeValue(av *types.AttributeValue) error { t := time.Time(e) s := strconv.FormatInt(t.Unix(), 10) av.N = &s @@ -40,7 +40,7 @@ func (e UnixTime) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) err // // If an error parsing the AttributeValue number occurs UnmarshalError will be // returned. -func (e *UnixTime) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error { +func (e *UnixTime) UnmarshalDynamoDBAttributeValue(av *types.AttributeValue) error { t, err := decodeUnixTime(aws.StringValue(av.N)) if err != nil { return err @@ -64,7 +64,7 @@ func (e *UnixTime) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) // } // type Marshaler interface { - MarshalDynamoDBAttributeValue(*dynamodb.AttributeValue) error + MarshalDynamoDBAttributeValue(*types.AttributeValue) error } // Marshal will serialize the passed in Go value type into a DynamoDB AttributeValue @@ -152,7 +152,7 @@ type Marshaler interface { // // Marshal cannot represent cyclic data structures and will not handle them. // Passing cyclic structures to Marshal will result in an infinite recursion. -func Marshal(in interface{}) (*dynamodb.AttributeValue, error) { +func Marshal(in interface{}) (*types.AttributeValue, error) { return NewEncoder().Encode(in) } @@ -160,10 +160,10 @@ func Marshal(in interface{}) (*dynamodb.AttributeValue, error) { // type to a map of AttributeValues. // // This is useful for DynamoDB APIs such as PutItem. -func MarshalMap(in interface{}) (map[string]dynamodb.AttributeValue, error) { +func MarshalMap(in interface{}) (map[string]types.AttributeValue, error) { av, err := NewEncoder().Encode(in) if err != nil || av == nil || av.M == nil { - return map[string]dynamodb.AttributeValue{}, err + return map[string]types.AttributeValue{}, err } return av.M, nil @@ -171,10 +171,10 @@ func MarshalMap(in interface{}) (map[string]dynamodb.AttributeValue, error) { // MarshalList is an alias for Marshal func which marshals Go value // type to a slice of AttributeValues. -func MarshalList(in interface{}) ([]dynamodb.AttributeValue, error) { +func MarshalList(in interface{}) ([]types.AttributeValue, error) { av, err := NewEncoder().Encode(in) if err != nil || av == nil || av.L == nil { - return []dynamodb.AttributeValue{}, err + return []types.AttributeValue{}, err } return av.L, nil @@ -227,8 +227,8 @@ func NewEncoder(opts ...func(*Encoder)) *Encoder { // Encode will marshal a Go value type to an AttributeValue. Returning // the AttributeValue constructed or error. -func (e *Encoder) Encode(in interface{}) (*dynamodb.AttributeValue, error) { - av := &dynamodb.AttributeValue{} +func (e *Encoder) Encode(in interface{}) (*types.AttributeValue, error) { + av := &types.AttributeValue{} if err := e.encode(av, reflect.ValueOf(in), tag{}); err != nil { return nil, err } @@ -253,7 +253,7 @@ func fieldByIndex(v reflect.Value, index []int, return fv } -func (e *Encoder) encode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { +func (e *Encoder) encode(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { // We should check for omitted values first before dereferencing. if fieldTag.OmitEmpty && emptyValue(v) { encodeNull(av) @@ -287,7 +287,7 @@ func (e *Encoder) encode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag return nil } -func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { +func (e *Encoder) encodeStruct(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { // To maintain backwards compatibility with ConvertTo family of methods which // converted time.Time structs to strings if v.Type().ConvertibleTo(timeType) { @@ -301,7 +301,7 @@ func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value, fie return nil } - av.M = map[string]dynamodb.AttributeValue{} + av.M = map[string]types.AttributeValue{} fields := unionStructFields(v.Type(), e.MarshalOptions) for _, f := range fields { if f.Name == "" { @@ -316,7 +316,7 @@ func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value, fie if !found { continue } - elem := dynamodb.AttributeValue{} + elem := types.AttributeValue{} err := e.encode(&elem, fv, f.tag) if err != nil { return err @@ -334,8 +334,8 @@ func (e *Encoder) encodeStruct(av *dynamodb.AttributeValue, v reflect.Value, fie return nil } -func (e *Encoder) encodeMap(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { - av.M = map[string]dynamodb.AttributeValue{} +func (e *Encoder) encodeMap(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { + av.M = map[string]types.AttributeValue{} for _, key := range v.MapKeys() { keyName := fmt.Sprint(key.Interface()) if keyName == "" { @@ -343,7 +343,7 @@ func (e *Encoder) encodeMap(av *dynamodb.AttributeValue, v reflect.Value, fieldT } elemVal := v.MapIndex(key) - elem := dynamodb.AttributeValue{} + elem := types.AttributeValue{} err := e.encode(&elem, elemVal, tag{}) skip, err := keepOrOmitEmpty(fieldTag.OmitEmptyElem, elem, err) if err != nil { @@ -362,7 +362,7 @@ func (e *Encoder) encodeMap(av *dynamodb.AttributeValue, v reflect.Value, fieldT return nil } -func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { +func (e *Encoder) encodeSlice(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { if v.Kind() == reflect.Array && v.Len() == 0 && fieldTag.OmitEmpty { encodeNull(av) return nil @@ -382,11 +382,11 @@ func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fiel av.B = append([]byte{}, b...) default: - var elemFn func(dynamodb.AttributeValue) error + var elemFn func(types.AttributeValue) error if fieldTag.AsBinSet || v.Type() == byteSliceSlicetype { // Binary Set av.BS = make([][]byte, 0, v.Len()) - elemFn = func(elem dynamodb.AttributeValue) error { + elemFn = func(elem types.AttributeValue) error { if elem.B == nil { return &InvalidMarshalError{msg: "binary set must only contain non-nil byte slices"} } @@ -395,7 +395,7 @@ func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fiel } } else if fieldTag.AsNumSet { // Number Set av.NS = make([]string, 0, v.Len()) - elemFn = func(elem dynamodb.AttributeValue) error { + elemFn = func(elem types.AttributeValue) error { if elem.N == nil { return &InvalidMarshalError{msg: "number set must only contain non-nil string numbers"} } @@ -404,7 +404,7 @@ func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fiel } } else if fieldTag.AsStrSet { // String Set av.SS = make([]string, 0, v.Len()) - elemFn = func(elem dynamodb.AttributeValue) error { + elemFn = func(elem types.AttributeValue) error { if elem.S == nil { return &InvalidMarshalError{msg: "string set must only contain non-nil strings"} } @@ -412,8 +412,8 @@ func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fiel return nil } } else { // List - av.L = make([]dynamodb.AttributeValue, 0, v.Len()) - elemFn = func(elem dynamodb.AttributeValue) error { + av.L = make([]types.AttributeValue, 0, v.Len()) + elemFn = func(elem types.AttributeValue) error { av.L = append(av.L, elem) return nil } @@ -429,10 +429,10 @@ func (e *Encoder) encodeSlice(av *dynamodb.AttributeValue, v reflect.Value, fiel return nil } -func (e *Encoder) encodeList(v reflect.Value, fieldTag tag, elemFn func(dynamodb.AttributeValue) error) (int, error) { +func (e *Encoder) encodeList(v reflect.Value, fieldTag tag, elemFn func(types.AttributeValue) error) (int, error) { count := 0 for i := 0; i < v.Len(); i++ { - elem := dynamodb.AttributeValue{} + elem := types.AttributeValue{} err := e.encode(&elem, v.Index(i), tag{OmitEmpty: fieldTag.OmitEmptyElem}) skip, err := keepOrOmitEmpty(fieldTag.OmitEmptyElem, elem, err) if err != nil { @@ -450,7 +450,7 @@ func (e *Encoder) encodeList(v reflect.Value, fieldTag tag, elemFn func(dynamodb return count, nil } -func (e *Encoder) encodeScalar(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error { +func (e *Encoder) encodeScalar(av *types.AttributeValue, v reflect.Value, fieldTag tag) error { if v.Type() == numberType { s := v.String() if fieldTag.AsString { @@ -483,7 +483,7 @@ func (e *Encoder) encodeScalar(av *dynamodb.AttributeValue, v reflect.Value, fie return nil } -func (e *Encoder) encodeNumber(av *dynamodb.AttributeValue, v reflect.Value) error { +func (e *Encoder) encodeNumber(av *types.AttributeValue, v reflect.Value) error { if used, err := tryMarshaler(av, v); used { return err } @@ -507,7 +507,7 @@ func (e *Encoder) encodeNumber(av *dynamodb.AttributeValue, v reflect.Value) err return nil } -func (e *Encoder) encodeString(av *dynamodb.AttributeValue, v reflect.Value) error { +func (e *Encoder) encodeString(av *types.AttributeValue, v reflect.Value) error { if used, err := tryMarshaler(av, v); used { return err } @@ -536,9 +536,9 @@ func encodeUint(u uint64) string { func encodeFloat(f float64, bitSize int) string { return strconv.FormatFloat(f, 'f', -1, bitSize) } -func encodeNull(av *dynamodb.AttributeValue) { +func encodeNull(av *types.AttributeValue) { t := true - *av = dynamodb.AttributeValue{NULL: &t} + *av = types.AttributeValue{NULL: &t} } func valueElem(v reflect.Value) reflect.Value { @@ -574,7 +574,7 @@ func emptyValue(v reflect.Value) bool { return false } -func tryMarshaler(av *dynamodb.AttributeValue, v reflect.Value) (bool, error) { +func tryMarshaler(av *types.AttributeValue, v reflect.Value) (bool, error) { if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() { v = v.Addr() } @@ -590,7 +590,7 @@ func tryMarshaler(av *dynamodb.AttributeValue, v reflect.Value) (bool, error) { return false, nil } -func keepOrOmitEmpty(omitEmpty bool, av dynamodb.AttributeValue, err error) (bool, error) { +func keepOrOmitEmpty(omitEmpty bool, av types.AttributeValue, err error) (bool, error) { if err != nil { if _, ok := err.(*unsupportedMarshalTypeError); ok { return true, nil diff --git a/service/dynamodb/dynamodbattribute/encode_test.go b/service/dynamodb/dynamodbattribute/encode_test.go index 255b67e188f..bc749a7f2de 100644 --- a/service/dynamodb/dynamodbattribute/encode_test.go +++ b/service/dynamodb/dynamodbattribute/encode_test.go @@ -1,5 +1,6 @@ package dynamodbattribute +// code generation? No import ( "fmt" "reflect" @@ -8,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) func TestMarshalErrorTypes(t *testing.T) { @@ -50,8 +51,8 @@ type marshalMarshaler struct { Value4 time.Time } -func (m *marshalMarshaler) MarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error { - av.M = map[string]dynamodb.AttributeValue{ +func (m *marshalMarshaler) MarshalDynamoDBAttributeValue(av *types.AttributeValue) error { + av.M = map[string]types.AttributeValue{ "abc": {S: &m.Value}, "def": {N: aws.String(fmt.Sprintf("%d", m.Value2))}, "ghi": {BOOL: &m.Value3}, @@ -69,8 +70,8 @@ func TestMarshalMashaler(t *testing.T) { Value4: testDate, } - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "abc": {S: aws.String("value")}, "def": {N: aws.String("123")}, "ghi": {BOOL: aws.Bool(true)}, @@ -97,9 +98,9 @@ type testOmitEmptyElemMapStruct struct { } func TestMarshalListOmitEmptyElem(t *testing.T) { - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Values": {L: []dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Values": {L: []types.AttributeValue{ {S: aws.String("abc")}, {S: aws.String("123")}, }}, @@ -118,9 +119,9 @@ func TestMarshalListOmitEmptyElem(t *testing.T) { } func TestMarshalMapOmitEmptyElem(t *testing.T) { - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ - "Values": {M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ + "Values": {M: map[string]types.AttributeValue{ "abc": {N: aws.String("123")}, "klm": {S: aws.String("abc")}, }}, @@ -150,8 +151,8 @@ type testOmitEmptyScalar struct { } func TestMarshalOmitEmpty(t *testing.T) { - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "IntPtrSetZero": {N: aws.String("0")}, }, } @@ -194,8 +195,8 @@ func TestEncodeEmbeddedPointerStruct(t *testing.T) { if err != nil { t.Errorf("expect nil, got %v", err) } - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Aint": { N: aws.String("321"), }, @@ -226,8 +227,8 @@ func TestEncodeUnixTime(t *testing.T) { if err != nil { t.Errorf("expect nil, got %v", err) } - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Normal": { S: aws.String("1970-01-01T00:02:03Z"), }, @@ -261,8 +262,8 @@ func TestEncodeAliasedUnixTime(t *testing.T) { if err != nil { t.Errorf("expect no err, got %v", err) } - expect := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expect := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Normal": { S: aws.String("1970-01-01T00:02:03Z"), }, diff --git a/service/dynamodb/dynamodbattribute/marshaler_examples_test.go b/service/dynamodb/dynamodbattribute/marshaler_examples_test.go index 23b0f16ea1e..bb3145a5f3d 100644 --- a/service/dynamodb/dynamodbattribute/marshaler_examples_test.go +++ b/service/dynamodb/dynamodbattribute/marshaler_examples_test.go @@ -5,8 +5,8 @@ import ( "reflect" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) func ExampleMarshal() { @@ -80,14 +80,14 @@ func ExampleUnmarshal() { A2Num: map[string]int{"a": 1, "b": 2, "c": 3}, } - av := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + av := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Bytes": {B: []byte{48, 49}}, "MyField": {S: aws.String("MyFieldValue")}, - "Letters": {L: []dynamodb.AttributeValue{ + "Letters": {L: []types.AttributeValue{ {S: aws.String("a")}, {S: aws.String("b")}, {S: aws.String("c")}, {S: aws.String("d")}, }}, - "A2Num": {M: map[string]dynamodb.AttributeValue{ + "A2Num": {M: map[string]types.AttributeValue{ "a": {N: aws.String("1")}, "b": {N: aws.String("2")}, "c": {N: aws.String("3")}, diff --git a/service/dynamodb/dynamodbattribute/marshaler_test.go b/service/dynamodb/dynamodbattribute/marshaler_test.go index c52ddf85c14..5afe1bfb86e 100644 --- a/service/dynamodb/dynamodbattribute/marshaler_test.go +++ b/service/dynamodb/dynamodbattribute/marshaler_test.go @@ -8,7 +8,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awsutil" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) type simpleMarshalStruct struct { @@ -46,44 +46,44 @@ var falseValue = false var marshalerScalarInputs = []marshallerTestInput{ { input: nil, - expected: &dynamodb.AttributeValue{NULL: &trueValue}, + expected: &types.AttributeValue{NULL: &trueValue}, }, { input: "some string", - expected: &dynamodb.AttributeValue{S: aws.String("some string")}, + expected: &types.AttributeValue{S: aws.String("some string")}, }, { input: true, - expected: &dynamodb.AttributeValue{BOOL: &trueValue}, + expected: &types.AttributeValue{BOOL: &trueValue}, }, { input: false, - expected: &dynamodb.AttributeValue{BOOL: &falseValue}, + expected: &types.AttributeValue{BOOL: &falseValue}, }, { input: 3.14, - expected: &dynamodb.AttributeValue{N: aws.String("3.14")}, + expected: &types.AttributeValue{N: aws.String("3.14")}, }, { input: math.MaxFloat32, - expected: &dynamodb.AttributeValue{N: aws.String("340282346638528860000000000000000000000")}, + expected: &types.AttributeValue{N: aws.String("340282346638528860000000000000000000000")}, }, { input: math.MaxFloat64, - expected: &dynamodb.AttributeValue{N: aws.String("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")}, + expected: &types.AttributeValue{N: aws.String("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")}, }, { input: 12, - expected: &dynamodb.AttributeValue{N: aws.String("12")}, + expected: &types.AttributeValue{N: aws.String("12")}, }, { input: Number("12"), - expected: &dynamodb.AttributeValue{N: aws.String("12")}, + expected: &types.AttributeValue{N: aws.String("12")}, }, { input: simpleMarshalStruct{}, - expected: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expected: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Byte": {NULL: &trueValue}, "Bool": {BOOL: &falseValue}, "Float32": {N: aws.String("0")}, @@ -101,62 +101,62 @@ var marshallerMapTestInputs = []marshallerTestInput{ // Scalar tests { input: nil, - expected: map[string]dynamodb.AttributeValue{}, + expected: map[string]types.AttributeValue{}, }, { input: map[string]interface{}{"string": "some string"}, - expected: map[string]dynamodb.AttributeValue{"string": {S: aws.String("some string")}}, + expected: map[string]types.AttributeValue{"string": {S: aws.String("some string")}}, }, { input: map[string]interface{}{"bool": true}, - expected: map[string]dynamodb.AttributeValue{"bool": {BOOL: &trueValue}}, + expected: map[string]types.AttributeValue{"bool": {BOOL: &trueValue}}, }, { input: map[string]interface{}{"bool": false}, - expected: map[string]dynamodb.AttributeValue{"bool": {BOOL: &falseValue}}, + expected: map[string]types.AttributeValue{"bool": {BOOL: &falseValue}}, }, { input: map[string]interface{}{"null": nil}, - expected: map[string]dynamodb.AttributeValue{"null": {NULL: &trueValue}}, + expected: map[string]types.AttributeValue{"null": {NULL: &trueValue}}, }, { input: map[string]interface{}{"float": 3.14}, - expected: map[string]dynamodb.AttributeValue{"float": {N: aws.String("3.14")}}, + expected: map[string]types.AttributeValue{"float": {N: aws.String("3.14")}}, }, { input: map[string]interface{}{"float": math.MaxFloat32}, - expected: map[string]dynamodb.AttributeValue{"float": {N: aws.String("340282346638528860000000000000000000000")}}, + expected: map[string]types.AttributeValue{"float": {N: aws.String("340282346638528860000000000000000000000")}}, }, { input: map[string]interface{}{"float": math.MaxFloat64}, - expected: map[string]dynamodb.AttributeValue{"float": {N: aws.String("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")}}, + expected: map[string]types.AttributeValue{"float": {N: aws.String("179769313486231570000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")}}, }, { input: map[string]interface{}{"num": 12.}, - expected: map[string]dynamodb.AttributeValue{"num": {N: aws.String("12")}}, + expected: map[string]types.AttributeValue{"num": {N: aws.String("12")}}, }, { input: map[string]interface{}{"byte": []byte{48, 49}}, - expected: map[string]dynamodb.AttributeValue{"byte": {B: []byte{48, 49}}}, + expected: map[string]types.AttributeValue{"byte": {B: []byte{48, 49}}}, }, { input: struct{ Byte []byte }{Byte: []byte{48, 49}}, - expected: map[string]dynamodb.AttributeValue{"Byte": {B: []byte{48, 49}}}, + expected: map[string]types.AttributeValue{"Byte": {B: []byte{48, 49}}}, }, { input: map[string]interface{}{"byte_set": [][]byte{{48, 49}, {50, 51}}}, - expected: map[string]dynamodb.AttributeValue{"byte_set": {BS: [][]byte{{48, 49}, {50, 51}}}}, + expected: map[string]types.AttributeValue{"byte_set": {BS: [][]byte{{48, 49}, {50, 51}}}}, }, { input: struct{ ByteSet [][]byte }{ByteSet: [][]byte{{48, 49}, {50, 51}}}, - expected: map[string]dynamodb.AttributeValue{"ByteSet": {BS: [][]byte{{48, 49}, {50, 51}}}}, + expected: map[string]types.AttributeValue{"ByteSet": {BS: [][]byte{{48, 49}, {50, 51}}}}, }, // List { input: map[string]interface{}{"list": []interface{}{"a string", 12., 3.14, true, nil, false}}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "list": { - L: []dynamodb.AttributeValue{ + L: []types.AttributeValue{ {S: aws.String("a string")}, {N: aws.String("12")}, {N: aws.String("3.14")}, @@ -170,9 +170,9 @@ var marshallerMapTestInputs = []marshallerTestInput{ // Map { input: map[string]interface{}{"map": map[string]interface{}{"nestednum": 12.}}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "map": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "nestednum": { N: aws.String("12"), }, @@ -183,7 +183,7 @@ var marshallerMapTestInputs = []marshallerTestInput{ // Structs { input: simpleMarshalStruct{}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "Byte": {NULL: &trueValue}, "Bool": {BOOL: &falseValue}, "Float32": {N: aws.String("0")}, @@ -196,7 +196,7 @@ var marshallerMapTestInputs = []marshallerTestInput{ }, { input: complexMarshalStruct{}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "Simple": {NULL: &trueValue}, }, }, @@ -204,7 +204,7 @@ var marshallerMapTestInputs = []marshallerTestInput{ input: struct { Simple []string `json:"simple"` }{}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "simple": {NULL: &trueValue}, }, }, @@ -212,21 +212,21 @@ var marshallerMapTestInputs = []marshallerTestInput{ input: struct { Simple []string `json:"simple,omitempty"` }{}, - expected: map[string]dynamodb.AttributeValue{}, + expected: map[string]types.AttributeValue{}, }, { input: struct { Simple []string `json:"-"` }{}, - expected: map[string]dynamodb.AttributeValue{}, + expected: map[string]types.AttributeValue{}, }, { input: complexMarshalStruct{Simple: []simpleMarshalStruct{{Int: -2}, {Uint: 5}}}, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ "Simple": { - L: []dynamodb.AttributeValue{ + L: []types.AttributeValue{ { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Byte": {NULL: &trueValue}, "Bool": {BOOL: &falseValue}, "Float32": {N: aws.String("0")}, @@ -238,7 +238,7 @@ var marshallerMapTestInputs = []marshallerTestInput{ }, }, { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Byte": {NULL: &trueValue}, "Bool": {BOOL: &falseValue}, "Float32": {N: aws.String("0")}, @@ -258,19 +258,19 @@ var marshallerMapTestInputs = []marshallerTestInput{ var marshallerListTestInputs = []marshallerTestInput{ { input: nil, - expected: []dynamodb.AttributeValue{}, + expected: []types.AttributeValue{}, }, { input: []interface{}{}, - expected: []dynamodb.AttributeValue{}, + expected: []types.AttributeValue{}, }, { input: []simpleMarshalStruct{}, - expected: []dynamodb.AttributeValue{}, + expected: []types.AttributeValue{}, }, { input: []interface{}{"a string", 12., 3.14, true, nil, false}, - expected: []dynamodb.AttributeValue{ + expected: []types.AttributeValue{ {S: aws.String("a string")}, {N: aws.String("12")}, {N: aws.String("3.14")}, @@ -281,9 +281,9 @@ var marshallerListTestInputs = []marshallerTestInput{ }, { input: []simpleMarshalStruct{{}}, - expected: []dynamodb.AttributeValue{ + expected: []types.AttributeValue{ { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "Byte": {NULL: &trueValue}, "Bool": {BOOL: &falseValue}, "Float32": {N: aws.String("0")}, @@ -327,7 +327,7 @@ func Test_New_Unmarshal(t *testing.T) { continue } actual := reflect.New(reflect.TypeOf(test.input)).Interface() - if err := Unmarshal(test.expected.(*dynamodb.AttributeValue), actual); err != nil { + if err := Unmarshal(test.expected.(*types.AttributeValue), actual); err != nil { t.Errorf("Unmarshal %d, with input %#v retured error `%s`", i+1, test.expected, err) } compareObjects(t, test.input, reflect.ValueOf(actual).Elem().Interface()) @@ -391,7 +391,7 @@ func Test_New_UnmarshalMap(t *testing.T) { continue } actual := reflect.New(reflect.TypeOf(test.input)).Interface() - if err := UnmarshalMap(test.expected.(map[string]dynamodb.AttributeValue), actual); err != nil { + if err := UnmarshalMap(test.expected.(map[string]types.AttributeValue), actual); err != nil { t.Errorf("Unmarshal %d, with input %#v retured error `%s`", i+1, test.expected, err) } compareObjects(t, test.input, reflect.ValueOf(actual).Elem().Interface()) @@ -461,7 +461,7 @@ func Test_New_UnmarshalList(t *testing.T) { actual.Elem().Set(reflect.MakeSlice(iv.Type(), iv.Len(), iv.Cap())) } - if err := UnmarshalList(test.expected.([]dynamodb.AttributeValue), actual.Interface()); err != nil { + if err := UnmarshalList(test.expected.([]types.AttributeValue), actual.Interface()); err != nil { t.Errorf("Unmarshal %d, with input %#v retured error `%s`", i+1, test.expected, err) } compareObjects(t, test.input, actual.Elem().Interface()) @@ -553,8 +553,8 @@ func Test_Encode_YAML_TagKey(t *testing.T) { NoTag: "NoTag", } - expected := &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + expected := &types.AttributeValue{ + M: map[string]types.AttributeValue{ "string": {S: aws.String("String")}, "empty": {NULL: &trueValue}, "byte": {NULL: &trueValue}, @@ -563,13 +563,13 @@ func Test_Encode_YAML_TagKey(t *testing.T) { "int": {N: aws.String("0")}, "uint": {N: aws.String("0")}, "slice": { - L: []dynamodb.AttributeValue{ + L: []types.AttributeValue{ {S: aws.String("one")}, {S: aws.String("two")}, }, }, "map": { - M: map[string]dynamodb.AttributeValue{ + M: map[string]types.AttributeValue{ "one": {N: aws.String("1")}, "two": {N: aws.String("2")}, }, diff --git a/service/dynamodb/dynamodbattribute/shared_test.go b/service/dynamodb/dynamodbattribute/shared_test.go index bca695793a9..0675366960b 100644 --- a/service/dynamodb/dynamodbattribute/shared_test.go +++ b/service/dynamodb/dynamodbattribute/shared_test.go @@ -6,7 +6,7 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) type testBinarySetStruct struct { @@ -65,22 +65,22 @@ type testNamedPointer *int var testDate, _ = time.Parse(time.RFC3339, "2016-05-03T17:06:26.209072Z") var sharedTestCases = []struct { - in *dynamodb.AttributeValue + in *types.AttributeValue actual, expected interface{} err error }{ { // Binary slice - in: &dynamodb.AttributeValue{B: []byte{48, 49}}, + in: &types.AttributeValue{B: []byte{48, 49}}, actual: &[]byte{}, expected: []byte{48, 49}, }, { // Binary slice - in: &dynamodb.AttributeValue{B: []byte{48, 49}}, + in: &types.AttributeValue{B: []byte{48, 49}}, actual: &[]byte{}, expected: []byte{48, 49}, }, { // Binary slice oversized - in: &dynamodb.AttributeValue{B: []byte{48, 49}}, + in: &types.AttributeValue{B: []byte{48, 49}}, actual: func() *[]byte { v := make([]byte, 0, 10) return &v @@ -88,7 +88,7 @@ var sharedTestCases = []struct { expected: []byte{48, 49}, }, { // Binary slice pointer - in: &dynamodb.AttributeValue{B: []byte{48, 49}}, + in: &types.AttributeValue{B: []byte{48, 49}}, actual: func() **[]byte { v := make([]byte, 0, 10) v2 := &v @@ -97,33 +97,33 @@ var sharedTestCases = []struct { expected: []byte{48, 49}, }, { // Bool - in: &dynamodb.AttributeValue{BOOL: aws.Bool(true)}, + in: &types.AttributeValue{BOOL: aws.Bool(true)}, actual: new(bool), expected: true, }, { // List - in: &dynamodb.AttributeValue{L: []dynamodb.AttributeValue{ + in: &types.AttributeValue{L: []types.AttributeValue{ {N: aws.String("123")}, }}, actual: &[]int{}, expected: []int{123}, }, { // Map, interface - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "abc": {N: aws.String("123")}, }}, actual: &map[string]int{}, expected: map[string]int{"abc": 123}, }, { // Map, struct - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "Abc": {N: aws.String("123")}, }}, actual: &struct{ Abc int }{}, expected: struct{ Abc int }{Abc: 123}, }, { // Map, struct - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "abc": {N: aws.String("123")}, }}, actual: &struct { @@ -134,33 +134,33 @@ var sharedTestCases = []struct { }{Abc: 123}, }, { // Number, int - in: &dynamodb.AttributeValue{N: aws.String("123")}, + in: &types.AttributeValue{N: aws.String("123")}, actual: new(int), expected: 123, }, { // Number, Float - in: &dynamodb.AttributeValue{N: aws.String("123.1")}, + in: &types.AttributeValue{N: aws.String("123.1")}, actual: new(float64), expected: float64(123.1), }, { // Null - in: &dynamodb.AttributeValue{NULL: aws.Bool(true)}, + in: &types.AttributeValue{NULL: aws.Bool(true)}, actual: new(string), expected: "", }, { // Null ptr - in: &dynamodb.AttributeValue{NULL: aws.Bool(true)}, + in: &types.AttributeValue{NULL: aws.Bool(true)}, actual: new(*string), expected: nil, }, { // String - in: &dynamodb.AttributeValue{S: aws.String("abc")}, + in: &types.AttributeValue{S: aws.String("abc")}, actual: new(string), expected: "abc", }, { // Binary Set - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Binarys": {BS: [][]byte{{48, 49}, {50, 51}}}, }, }, @@ -168,8 +168,8 @@ var sharedTestCases = []struct { expected: testBinarySetStruct{Binarys: [][]byte{{48, 49}, {50, 51}}}, }, { // Number Set - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Numbers": {NS: []string{"123", "321"}}, }, }, @@ -177,8 +177,8 @@ var sharedTestCases = []struct { expected: testNumberSetStruct{Numbers: []int{123, 321}}, }, { // String Set - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Strings": {SS: []string{"abc", "efg"}}, }, }, @@ -186,8 +186,8 @@ var sharedTestCases = []struct { expected: testStringSetStruct{Strings: []string{"abc", "efg"}}, }, { // Int value as string - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Value": {S: aws.String("123")}, }, }, @@ -195,8 +195,8 @@ var sharedTestCases = []struct { expected: testIntAsStringStruct{Value: 123}, }, { // Omitempty - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Value3": {N: aws.String("0")}, }, }, @@ -204,25 +204,25 @@ var sharedTestCases = []struct { expected: testOmitEmptyStruct{Value: "", Value2: nil, Value3: 0}, }, { // aliased type - in: &dynamodb.AttributeValue{ - M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{ + M: map[string]types.AttributeValue{ "Value": {S: aws.String("123")}, "Value2": {N: aws.String("123")}, - "Value3": {M: map[string]dynamodb.AttributeValue{ + "Value3": {M: map[string]types.AttributeValue{ "Key": {N: aws.String("321")}, }}, - "Value4": {L: []dynamodb.AttributeValue{ + "Value4": {L: []types.AttributeValue{ {S: aws.String("1")}, {S: aws.String("2")}, {S: aws.String("3")}, }}, "Value5": {B: []byte{0, 1, 2}}, - "Value6": {L: []dynamodb.AttributeValue{ + "Value6": {L: []types.AttributeValue{ {N: aws.String("1")}, {N: aws.String("2")}, {N: aws.String("3")}, }}, - "Value7": {L: []dynamodb.AttributeValue{ + "Value7": {L: []types.AttributeValue{ {S: aws.String("1")}, {S: aws.String("2")}, {S: aws.String("3")}, @@ -240,18 +240,18 @@ var sharedTestCases = []struct { "2", "3", }}, - "Value11": {L: []dynamodb.AttributeValue{ + "Value11": {L: []types.AttributeValue{ {N: aws.String("1")}, {N: aws.String("2")}, {N: aws.String("3")}, }}, - "Value12": {L: []dynamodb.AttributeValue{ + "Value12": {L: []types.AttributeValue{ {S: aws.String("1")}, {S: aws.String("2")}, {S: aws.String("3")}, }}, "Value13": {BOOL: aws.Bool(true)}, - "Value14": {L: []dynamodb.AttributeValue{ + "Value14": {L: []types.AttributeValue{ {BOOL: aws.Bool(true)}, {BOOL: aws.Bool(false)}, {BOOL: aws.Bool(true)}, @@ -281,17 +281,17 @@ var sharedTestCases = []struct { }, }, { - in: &dynamodb.AttributeValue{N: aws.String("123")}, + in: &types.AttributeValue{N: aws.String("123")}, actual: new(testNamedPointer), expected: testNamedPointer(aws.Int(123)), }, { // time.Time - in: &dynamodb.AttributeValue{S: aws.String("2016-05-03T17:06:26.209072Z")}, + in: &types.AttributeValue{S: aws.String("2016-05-03T17:06:26.209072Z")}, actual: new(time.Time), expected: testDate, }, { // time.Time List - in: &dynamodb.AttributeValue{L: []dynamodb.AttributeValue{ + in: &types.AttributeValue{L: []types.AttributeValue{ {S: aws.String("2016-05-03T17:06:26.209072Z")}, {S: aws.String("2016-05-04T17:06:26.209072Z")}, }}, @@ -299,7 +299,7 @@ var sharedTestCases = []struct { expected: []time.Time{testDate, testDate.Add(24 * time.Hour)}, }, { // time.Time struct - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "abc": {S: aws.String("2016-05-03T17:06:26.209072Z")}, }}, actual: &struct { @@ -310,7 +310,7 @@ var sharedTestCases = []struct { }{Abc: testDate}, }, { // time.Time ptr struct - in: &dynamodb.AttributeValue{M: map[string]dynamodb.AttributeValue{ + in: &types.AttributeValue{M: map[string]types.AttributeValue{ "abc": {S: aws.String("2016-05-03T17:06:26.209072Z")}, }}, actual: &struct { @@ -323,12 +323,12 @@ var sharedTestCases = []struct { } var sharedListTestCases = []struct { - in []dynamodb.AttributeValue + in []types.AttributeValue actual, expected interface{} err error }{ { - in: []dynamodb.AttributeValue{ + in: []types.AttributeValue{ {B: []byte{48, 49}}, {BOOL: aws.Bool(true)}, {N: aws.String("123")}, @@ -341,7 +341,7 @@ var sharedListTestCases = []struct { expected: []interface{}{[]byte{48, 49}, true, 123., "123"}, }, { - in: []dynamodb.AttributeValue{ + in: []types.AttributeValue{ {N: aws.String("1")}, {N: aws.String("2")}, {N: aws.String("3")}, @@ -352,12 +352,12 @@ var sharedListTestCases = []struct { } var sharedMapTestCases = []struct { - in map[string]dynamodb.AttributeValue + in map[string]types.AttributeValue actual, expected interface{} err error }{ { - in: map[string]dynamodb.AttributeValue{ + in: map[string]types.AttributeValue{ "B": {B: []byte{48, 49}}, "BOOL": {BOOL: aws.Bool(true)}, "N": {N: aws.String("123")}, diff --git a/service/dynamodb/expression/condition_test.go b/service/dynamodb/expression/condition_test.go index 5356961d5b5..9365345f0f6 100644 --- a/service/dynamodb/expression/condition_test.go +++ b/service/dynamodb/expression/condition_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // condErrorMode will help with error cases and checking error types @@ -24,7 +24,6 @@ const ( invalidConditionOperand = "BuildOperand error" ) -//Compare func TestCompare(t *testing.T) { cases := []struct { name string @@ -55,7 +54,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -63,7 +62,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -114,7 +113,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -122,7 +121,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -173,7 +172,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -181,7 +180,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -232,7 +231,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -240,7 +239,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -291,7 +290,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -299,7 +298,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -350,7 +349,7 @@ func TestCompare(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -358,7 +357,7 @@ func TestCompare(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -497,7 +496,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -514,7 +513,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("baz"), }, @@ -540,7 +539,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -557,7 +556,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("baz"), }, @@ -583,7 +582,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -600,7 +599,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("baz"), }, @@ -617,7 +616,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { BOOL: aws.Bool(true), }, @@ -643,7 +642,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -660,7 +659,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("baz"), }, @@ -677,7 +676,7 @@ func TestBoolCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { BOOL: aws.Bool(true), }, @@ -745,7 +744,7 @@ func TestNotCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -771,7 +770,7 @@ func TestNotCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -832,7 +831,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -840,7 +839,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -857,7 +856,7 @@ func TestBetweenCondition(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("6"), }, @@ -865,7 +864,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -873,7 +872,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -894,7 +893,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "size ($n)", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -902,7 +901,7 @@ func TestBetweenCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -960,7 +959,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -968,7 +967,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -985,7 +984,7 @@ func TestInCondition(t *testing.T) { expectedNode: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("6"), }, @@ -993,7 +992,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -1001,7 +1000,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -1022,7 +1021,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "size ($n)", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -1030,7 +1029,7 @@ func TestInCondition(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -1156,7 +1155,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("S"), }, @@ -1177,7 +1176,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("S"), }, @@ -1198,7 +1197,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("SS"), }, @@ -1219,7 +1218,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("N"), }, @@ -1240,7 +1239,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("NS"), }, @@ -1261,7 +1260,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("B"), }, @@ -1282,7 +1281,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("BS"), }, @@ -1303,7 +1302,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("BOOL"), }, @@ -1324,7 +1323,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("NULL"), }, @@ -1345,7 +1344,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("L"), }, @@ -1366,7 +1365,7 @@ func TestAttrTypeCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("M"), }, @@ -1424,7 +1423,7 @@ func TestBeginsWithCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -1482,7 +1481,7 @@ func TestContainsCondition(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, diff --git a/service/dynamodb/expression/examples_test.go b/service/dynamodb/expression/examples_test.go index 2632f948bab..2f74338ef37 100644 --- a/service/dynamodb/expression/examples_test.go +++ b/service/dynamodb/expression/examples_test.go @@ -8,7 +8,9 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/external" "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/enums" "github.com/aws/aws-sdk-go-v2/service/dynamodb/expression" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // Using Projection Expression @@ -42,7 +44,7 @@ func ExampleBuilder_WithProjection() { // Use the built expression to populate the DynamoDB Query's API input // parameters. - input := &dynamodb.QueryInput{ + input := &types.QueryInput{ ExpressionAttributeValues: expr.Values(), KeyConditionExpression: expr.KeyCondition(), ProjectionExpression: expr.Projection(), @@ -105,7 +107,7 @@ func ExampleBuilder_WithKeyCondition() { // Use the built expression to populate the DynamoDB Query's API input // parameters. - input := &dynamodb.QueryInput{ + input := &types.QueryInput{ ExpressionAttributeNames: expr.Names(), ExpressionAttributeValues: expr.Values(), KeyConditionExpression: expr.KeyCondition(), @@ -170,7 +172,7 @@ func ExampleBuilder_WithFilter() { } // Use the built expression to populate the DynamoDB Scan API input parameters. - input := &dynamodb.ScanInput{ + input := &types.ScanInput{ ExpressionAttributeNames: expr.Names(), ExpressionAttributeValues: expr.Values(), FilterExpression: expr.Filter(), @@ -232,10 +234,10 @@ func ExampleBuilder_WithUpdate() { // Use the built expression to populate the DynamoDB UpdateItem API // input parameters. - input := &dynamodb.UpdateItemInput{ + input := &types.UpdateItemInput{ ExpressionAttributeNames: expr.Names(), ExpressionAttributeValues: expr.Values(), - Key: map[string]dynamodb.AttributeValue{ + Key: map[string]types.AttributeValue{ "Artist": { S: aws.String("Acme Band"), }, @@ -243,7 +245,7 @@ func ExampleBuilder_WithUpdate() { S: aws.String("Happy Day"), }, }, - ReturnValues: dynamodb.ReturnValueAllNew, + ReturnValues: enums.ReturnValueAllNew, TableName: aws.String("Music"), UpdateExpression: expr.Update(), } @@ -302,8 +304,8 @@ func ExampleBuilder_WithCondition() { // Use the built expression to populate the DeleteItem API operation with the // condition expression. - input := &dynamodb.DeleteItemInput{ - Key: map[string]dynamodb.AttributeValue{ + input := &types.DeleteItemInput{ + Key: map[string]types.AttributeValue{ "Artist": { S: aws.String("No One You Know"), }, diff --git a/service/dynamodb/expression/expression.go b/service/dynamodb/expression/expression.go index 5e980b28e81..9b8367b5bf7 100644 --- a/service/dynamodb/expression/expression.go +++ b/service/dynamodb/expression/expression.go @@ -5,7 +5,7 @@ import ( "sort" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // expressionType specifies the type of Expression. Declaring this type is used @@ -48,7 +48,7 @@ func (l typeList) Swap(i, j int) { // builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj) // expression := builder.Build() // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -91,7 +91,7 @@ func NewBuilder() Builder { // builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj) // expression := builder.Build() // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -121,7 +121,7 @@ func (b Builder) Build() (Expression, error) { } if len(aliasList.valuesList) != 0 { - valuesMap := map[string]dynamodb.AttributeValue{} + valuesMap := map[string]types.AttributeValue{} for i := 0; i < len(aliasList.valuesList); i++ { valuesMap[fmt.Sprintf(":%v", i)] = aliasList.valuesList[i] } @@ -298,7 +298,7 @@ func (b Builder) WithUpdate(updateBuilder UpdateBuilder) Builder { // builder := expression.NewBuilder().WithKeyCondition(keyCond).WithProjection(proj) // expression := builder.Build() // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -308,7 +308,7 @@ func (b Builder) WithUpdate(updateBuilder UpdateBuilder) Builder { type Expression struct { expressionMap map[expressionType]string namesMap map[string]string - valuesMap map[string]dynamodb.AttributeValue + valuesMap map[string]types.AttributeValue } // treeBuilder interface is fulfilled by builder structs that represent @@ -330,12 +330,12 @@ type treeBuilder interface { // // // let expression be an instance of Expression{} // -// deleteInput := dynamodb.DeleteItemInput{ +// deleteInput := types.DeleteItemInput{ // ConditionExpression: expression.Condition(), // ExpressionAttributeNames: expression.Names(), // ExpressionAttributeValues: expression.Values(), -// Key: map[string]dynamodb.AttributeValue{ -// "PartitionKey": &dynamodb.AttributeValue{ +// Key: map[string]types.AttributeValue{ +// "PartitionKey": &types.AttributeValue{ // S: aws.String("SomeKey"), // }, // }, @@ -354,7 +354,7 @@ func (e Expression) Condition() *string { // // // let expression be an instance of Expression{} // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // FilterExpression: expression.Filter(), // ExpressionAttributeNames: expression.Names(), @@ -374,7 +374,7 @@ func (e Expression) Filter() *string { // // // let expression be an instance of Expression{} // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -394,7 +394,7 @@ func (e Expression) Projection() *string { // // // let expression be an instance of Expression{} // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -414,8 +414,8 @@ func (e Expression) KeyCondition() *string { // // // let expression be an instance of Expression{} // -// updateInput := dynamodb.UpdateInput{ -// Key: map[string]dynamodb.AttributeValue{ +// updateInput := types.UpdateInput{ +// Key: map[string]types.AttributeValue{ // "PartitionKey": { // S: aws.String("someKey"), // }, @@ -444,7 +444,7 @@ func (e Expression) Update() *string { // // // let expression be an instance of Expression{} // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), @@ -470,14 +470,14 @@ func (e Expression) Names() map[string]string { // // // let expression be an instance of Expression{} // -// queryInput := dynamodb.QueryInput{ +// queryInput := types.QueryInput{ // KeyConditionExpression: expression.KeyCondition(), // ProjectionExpression: expression.Projection(), // ExpressionAttributeNames: expression.Names(), // ExpressionAttributeValues: expression.Values(), // TableName: aws.String("SomeTable"), // } -func (e Expression) Values() map[string]dynamodb.AttributeValue { +func (e Expression) Values() map[string]types.AttributeValue { return e.valuesMap } @@ -506,7 +506,7 @@ func (e Expression) returnExpression(expressionType expressionType) *string { // The corresponding child node is in the []children slice. type exprNode struct { names []string - values []dynamodb.AttributeValue + values []types.AttributeValue children []exprNode fmtExpr string } @@ -517,7 +517,7 @@ type exprNode struct { // order to deduplicate all names within the tree strcuture of the exprNodes. type aliasList struct { namesList []string - valuesList []dynamodb.AttributeValue + valuesList []types.AttributeValue } // buildExpressionString returns a string with aliasing for names/values @@ -616,7 +616,7 @@ func substituteChild(index int, node exprNode, aliasList *aliasList) (string, er // aliasValue returns the corresponding alias to the dav value argument. Since // values are not deduplicated as of now, all values are just appended to the // aliasList and given the index as the alias. -func (al *aliasList) aliasValue(dav dynamodb.AttributeValue) (string, error) { +func (al *aliasList) aliasValue(dav types.AttributeValue) (string, error) { al.valuesList = append(al.valuesList, dav) return fmt.Sprintf(":%d", len(al.valuesList)-1), nil } diff --git a/service/dynamodb/expression/expression_test.go b/service/dynamodb/expression/expression_test.go index 81955696aee..2d52726e1ca 100644 --- a/service/dynamodb/expression/expression_test.go +++ b/service/dynamodb/expression/expression_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) type exprErrorMode string @@ -48,7 +48,7 @@ func TestBuild(t *testing.T) { namesMap: map[string]string{ "#0": "foo", }, - valuesMap: map[string]dynamodb.AttributeValue{ + valuesMap: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -79,7 +79,7 @@ func TestBuild(t *testing.T) { namesMap: map[string]string{ "#0": "foo", }, - valuesMap: map[string]dynamodb.AttributeValue{ + valuesMap: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -96,7 +96,7 @@ func TestBuild(t *testing.T) { namesMap: map[string]string{ "#0": "foo", }, - valuesMap: map[string]dynamodb.AttributeValue{ + valuesMap: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -113,7 +113,7 @@ func TestBuild(t *testing.T) { namesMap: map[string]string{ "#0": "foo", }, - valuesMap: map[string]dynamodb.AttributeValue{ + valuesMap: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -141,7 +141,7 @@ func TestBuild(t *testing.T) { "#1": "bar", "#2": "baz", }, - valuesMap: map[string]dynamodb.AttributeValue{ + valuesMap: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -593,7 +593,7 @@ func TestValues(t *testing.T) { cases := []struct { name string input Builder - expected map[string]dynamodb.AttributeValue + expected map[string]types.AttributeValue err exprErrorMode }{ { @@ -603,7 +603,7 @@ func TestValues(t *testing.T) { condition: Name("foo").Equal(Value(5)), }, }, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -650,7 +650,7 @@ func TestValues(t *testing.T) { }, }, }, - expected: map[string]dynamodb.AttributeValue{ + expected: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -740,7 +740,7 @@ func TestBuildChildTrees(t *testing.T) { }, expectedaliasList: aliasList{ namesList: []string{"foo", "bar", "baz"}, - valuesList: []dynamodb.AttributeValue{ + valuesList: []types.AttributeValue{ { N: aws.String("5"), }, @@ -793,7 +793,7 @@ func TestBuildExpressionString(t *testing.T) { name string input exprNode expectedNames map[string]string - expectedValues map[string]dynamodb.AttributeValue + expectedValues map[string]types.AttributeValue expectedExpression string err exprErrorMode }{ @@ -804,7 +804,7 @@ func TestBuildExpressionString(t *testing.T) { fmtExpr: "$n", }, - expectedValues: map[string]dynamodb.AttributeValue{}, + expectedValues: map[string]types.AttributeValue{}, expectedNames: map[string]string{ "#0": "foo", }, @@ -813,7 +813,7 @@ func TestBuildExpressionString(t *testing.T) { { name: "basic value", input: exprNode{ - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -821,7 +821,7 @@ func TestBuildExpressionString(t *testing.T) { fmtExpr: "$v", }, expectedNames: map[string]string{}, - expectedValues: map[string]dynamodb.AttributeValue{ + expectedValues: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -835,7 +835,7 @@ func TestBuildExpressionString(t *testing.T) { fmtExpr: "$n.$n", }, - expectedValues: map[string]dynamodb.AttributeValue{}, + expectedValues: map[string]types.AttributeValue{}, expectedNames: map[string]string{ "#0": "foo", "#1": "bar", @@ -848,7 +848,7 @@ func TestBuildExpressionString(t *testing.T) { names: []string{"foo", "bar", "baz"}, fmtExpr: "$n.$n[0].$n", }, - expectedValues: map[string]dynamodb.AttributeValue{}, + expectedValues: map[string]types.AttributeValue{}, expectedNames: map[string]string{ "#0": "foo", "#1": "bar", @@ -862,7 +862,7 @@ func TestBuildExpressionString(t *testing.T) { names: []string{"foo"}, fmtExpr: "size ($n)", }, - expectedValues: map[string]dynamodb.AttributeValue{}, + expectedValues: map[string]types.AttributeValue{}, expectedNames: map[string]string{ "#0": "foo", }, @@ -874,7 +874,7 @@ func TestBuildExpressionString(t *testing.T) { names: []string{"foo", "foo"}, fmtExpr: "$n.$n", }, - expectedValues: map[string]dynamodb.AttributeValue{}, + expectedValues: map[string]types.AttributeValue{}, expectedNames: map[string]string{ "#0": "foo", }, @@ -889,7 +889,7 @@ func TestBuildExpressionString(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -903,7 +903,7 @@ func TestBuildExpressionString(t *testing.T) { expectedNames: map[string]string{ "#0": "foo", }, - expectedValues: map[string]dynamodb.AttributeValue{ + expectedValues: map[string]types.AttributeValue{ ":0": { N: aws.String("5"), }, @@ -993,7 +993,7 @@ func TestAliasValue(t *testing.T) { { name: "fifth item", input: &aliasList{ - valuesList: []dynamodb.AttributeValue{ + valuesList: []types.AttributeValue{ {}, {}, {}, @@ -1006,7 +1006,7 @@ func TestAliasValue(t *testing.T) { for _, c := range cases { t.Run(c.name, func(t *testing.T) { - str, err := c.input.aliasValue(dynamodb.AttributeValue{}) + str, err := c.input.aliasValue(types.AttributeValue{}) if c.err != noExpressionError { if err == nil { diff --git a/service/dynamodb/expression/key_condition_test.go b/service/dynamodb/expression/key_condition_test.go index ff7daa67633..d1cc5c1ed59 100644 --- a/service/dynamodb/expression/key_condition_test.go +++ b/service/dynamodb/expression/key_condition_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // keyCondErrorMode will help with error cases and checking error types @@ -44,7 +44,7 @@ func TestKeyCompare(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -65,7 +65,7 @@ func TestKeyCompare(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -86,7 +86,7 @@ func TestKeyCompare(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -107,7 +107,7 @@ func TestKeyCompare(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -128,7 +128,7 @@ func TestKeyCompare(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -186,7 +186,7 @@ func TestKeyBetween(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -194,7 +194,7 @@ func TestKeyBetween(t *testing.T) { fmtExpr: "$v", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("10"), }, @@ -247,7 +247,7 @@ func TestKeyBeginsWith(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -302,7 +302,7 @@ func TestKeyAnd(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -319,7 +319,7 @@ func TestKeyAnd(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("baz"), }, @@ -391,7 +391,7 @@ func TestKeyConditionBuildChildNodes(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { S: aws.String("bar"), }, @@ -408,7 +408,7 @@ func TestKeyConditionBuildChildNodes(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("10"), }, diff --git a/service/dynamodb/expression/operand.go b/service/dynamodb/expression/operand.go index b4b1a2ef305..04f576a712a 100644 --- a/service/dynamodb/expression/operand.go +++ b/service/dynamodb/expression/operand.go @@ -4,8 +4,8 @@ import ( "fmt" "strings" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" "github.com/aws/aws-sdk-go-v2/service/dynamodb/dynamodbattribute" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // ValueBuilder represents an item attribute value operand and implements the @@ -527,7 +527,7 @@ func (vb ValueBuilder) BuildOperand() (Operand, error) { // Create a string with special characters that can be substituted later: $v operand := Operand{ exprNode: exprNode{ - values: []dynamodb.AttributeValue{*expr}, + values: []types.AttributeValue{*expr}, fmtExpr: "$v", }, } diff --git a/service/dynamodb/expression/operand_test.go b/service/dynamodb/expression/operand_test.go index 1d97afb3518..26aab6ba3f5 100644 --- a/service/dynamodb/expression/operand_test.go +++ b/service/dynamodb/expression/operand_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // opeErrorMode will help with error cases and checking error types @@ -52,7 +52,7 @@ func TestBuildOperand(t *testing.T) { name: "basic value", input: Value(5), expected: exprNode{ - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, diff --git a/service/dynamodb/expression/update_test.go b/service/dynamodb/expression/update_test.go index 008f52a911c..b8c47f3f24d 100644 --- a/service/dynamodb/expression/update_test.go +++ b/service/dynamodb/expression/update_test.go @@ -8,7 +8,7 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/dynamodb" + "github.com/aws/aws-sdk-go-v2/service/dynamodb/types" ) // updateErrorMode will help with error cases and checking error types @@ -43,7 +43,7 @@ func TestBuildOperation(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -68,7 +68,7 @@ func TestBuildOperation(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -149,7 +149,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -203,7 +203,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -234,7 +234,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -269,7 +269,7 @@ func TestUpdateTree(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -286,7 +286,7 @@ func TestUpdateTree(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("6"), }, @@ -326,7 +326,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -348,7 +348,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -384,7 +384,7 @@ func TestUpdateTree(t *testing.T) { fmtExpr: "$n", }, { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -512,7 +512,7 @@ func TestSetValueBuilder(t *testing.T) { expected: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -533,7 +533,7 @@ func TestSetValueBuilder(t *testing.T) { expected: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -554,9 +554,9 @@ func TestSetValueBuilder(t *testing.T) { expected: exprNode{ children: []exprNode{ { - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { - L: []dynamodb.AttributeValue{ + L: []types.AttributeValue{ { N: aws.String("1"), }, @@ -678,7 +678,7 @@ func TestUpdateBuildChildNodes(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("5"), }, @@ -695,7 +695,7 @@ func TestUpdateBuildChildNodes(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("6"), }, @@ -712,7 +712,7 @@ func TestUpdateBuildChildNodes(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("7"), }, @@ -729,7 +729,7 @@ func TestUpdateBuildChildNodes(t *testing.T) { }, { fmtExpr: "$v", - values: []dynamodb.AttributeValue{ + values: []types.AttributeValue{ { N: aws.String("8"), }, diff --git a/service/ec2/customizations.go b/service/ec2/customizations.go index 6830c59a9fe..89962a91bff 100644 --- a/service/ec2/customizations.go +++ b/service/ec2/customizations.go @@ -5,6 +5,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) const ( @@ -43,7 +44,7 @@ func fillPresignedURL(r *aws.Request) { return } - origParams := r.Params.(*CopySnapshotInput) + origParams := r.Params.(*types.CopySnapshotInput) // Stop if PresignedURL/DestinationRegion is set if origParams.PresignedUrl != nil || origParams.DestinationRegion != nil { @@ -51,7 +52,7 @@ func fillPresignedURL(r *aws.Request) { } origParams.DestinationRegion = aws.String(r.Config.Region) - newParams := awsutil.CopyOf(r.Params).(*CopySnapshotInput) + newParams := awsutil.CopyOf(r.Params).(*types.CopySnapshotInput) // Create a new request based on the existing request. We will use this to // presign the CopySnapshot request against the source region. diff --git a/service/ec2/customizations_test.go b/service/ec2/customizations_test.go index 021e344933e..44553e4d779 100644 --- a/service/ec2/customizations_test.go +++ b/service/ec2/customizations_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/ec2" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) func TestCopySnapshotPresignedURL(t *testing.T) { @@ -30,7 +31,7 @@ func TestCopySnapshotPresignedURL(t *testing.T) { req.Sign() }() - req := svc.CopySnapshotRequest(&ec2.CopySnapshotInput{ + req := svc.CopySnapshotRequest(&types.CopySnapshotInput{ SourceRegion: aws.String("us-west-1"), SourceSnapshotId: aws.String("snap-id"), }) diff --git a/service/ec2/retryer_test.go b/service/ec2/retryer_test.go index a7a8389c106..e1622ef9663 100644 --- a/service/ec2/retryer_test.go +++ b/service/ec2/retryer_test.go @@ -6,6 +6,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" + "github.com/aws/aws-sdk-go-v2/service/ec2/types" ) func TestCustomRetryRules(t *testing.T) { @@ -13,7 +14,7 @@ func TestCustomRetryRules(t *testing.T) { cfg := unit.Config() svc := New(cfg) - req := svc.ModifyNetworkInterfaceAttributeRequest(&ModifyNetworkInterfaceAttributeInput{ + req := svc.ModifyNetworkInterfaceAttributeRequest(&types.ModifyNetworkInterfaceAttributeInput{ NetworkInterfaceId: aws.String("foo"), }) @@ -48,7 +49,7 @@ func TestCustomRetryer_WhenRetrierSpecified(t *testing.T) { t.Error("expected default retryer, but received otherwise") } - req := svc.AssignPrivateIpAddressesRequest(&AssignPrivateIpAddressesInput{ + req := svc.AssignPrivateIpAddressesRequest(&types.AssignPrivateIpAddressesInput{ NetworkInterfaceId: aws.String("foo"), }) @@ -80,7 +81,7 @@ func TestCustomRetryer(t *testing.T) { cfg := unit.Config() svc := New(cfg) - req := svc.AssignPrivateIpAddressesRequest(&AssignPrivateIpAddressesInput{ + req := svc.AssignPrivateIpAddressesRequest(&types.AssignPrivateIpAddressesInput{ NetworkInterfaceId: aws.String("foo"), }) diff --git a/service/glacier/customizations_test.go b/service/glacier/customizations_test.go index 39ccd6c9deb..d93254f2502 100644 --- a/service/glacier/customizations_test.go +++ b/service/glacier/customizations_test.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/service/glacier" + "github.com/aws/aws-sdk-go-v2/service/glacier/types" ) var ( @@ -25,7 +26,7 @@ var ( ) func TestCustomizations(t *testing.T) { - req := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{ + req := svc.UploadArchiveRequest(&types.UploadArchiveInput{ VaultName: aws.String("vault"), Body: payloadBuf, }) @@ -57,7 +58,7 @@ func TestCustomizations(t *testing.T) { } func TestShortcircuitTreehash(t *testing.T) { - req := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{ + req := svc.UploadArchiveRequest(&types.UploadArchiveInput{ VaultName: aws.String("vault"), Body: payloadBuf, Checksum: aws.String("000"), @@ -97,7 +98,7 @@ func TestFillAccountIDWithNilStruct(t *testing.T) { } func TestHashOnce(t *testing.T) { - req := svc.UploadArchiveRequest(&glacier.UploadArchiveInput{ + req := svc.UploadArchiveRequest(&types.UploadArchiveInput{ VaultName: aws.String("vault"), Body: payloadBuf, }) diff --git a/service/kinesis/customizations_test.go b/service/kinesis/customizations_test.go index 5228f8ecdbb..d41b6fe6a8b 100644 --- a/service/kinesis/customizations_test.go +++ b/service/kinesis/customizations_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" + "github.com/aws/aws-sdk-go-v2/service/kinesis/types" ) type testReader struct { @@ -41,7 +42,7 @@ func TestKinesisGetRecordsCustomization(t *testing.T) { }) svc := New(cfg) - req := svc.GetRecordsRequest(&GetRecordsInput{ + req := svc.GetRecordsRequest(&types.GetRecordsInput{ ShardIterator: aws.String("foo"), }) req.Handlers.Send.Clear() @@ -74,7 +75,7 @@ func TestKinesisGetRecordsCustomization(t *testing.T) { func TestKinesisGetRecordsNoTimeout(t *testing.T) { readDuration = time.Second svc := New(unit.Config()) - req := svc.GetRecordsRequest(&GetRecordsInput{ + req := svc.GetRecordsRequest(&types.GetRecordsInput{ ShardIterator: aws.String("foo"), }) req.Handlers.Send.Clear() @@ -124,7 +125,7 @@ func TestKinesisCustomRetryErrorCodes(t *testing.T) { }, } - req := svc.GetRecordsRequest(&GetRecordsInput{}) + req := svc.GetRecordsRequest(&types.GetRecordsInput{}) req.Handlers.Send.Swap(defaults.SendHandler.Name, aws.NamedHandler{ Name: "custom send handler", Fn: func(r *aws.Request) { diff --git a/service/machinelearning/customizations.go b/service/machinelearning/customizations.go index 4179f422860..f805c50319f 100644 --- a/service/machinelearning/customizations.go +++ b/service/machinelearning/customizations.go @@ -4,6 +4,7 @@ import ( "net/url" "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/service/machinelearning/types" ) func init() { @@ -22,7 +23,7 @@ func updatePredictEndpoint(r *aws.Request) { return } - r.Metadata.Endpoint = *r.Params.(*PredictInput).PredictEndpoint + r.Metadata.Endpoint = *r.Params.(*types.PredictInput).PredictEndpoint uri, err := url.Parse(r.Metadata.Endpoint) if err != nil { diff --git a/service/machinelearning/customizations_test.go b/service/machinelearning/customizations_test.go index 32d70c73ba5..5d1dc1bc126 100644 --- a/service/machinelearning/customizations_test.go +++ b/service/machinelearning/customizations_test.go @@ -11,6 +11,7 @@ import ( request "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/machinelearning" + "github.com/aws/aws-sdk-go-v2/service/machinelearning/types" ) func TestPredictEndpoint(t *testing.T) { @@ -24,7 +25,7 @@ func TestPredictEndpoint(t *testing.T) { } }) - req := ml.PredictRequest(&machinelearning.PredictInput{ + req := ml.PredictRequest(&types.PredictInput{ PredictEndpoint: aws.String("https://localhost/endpoint"), MLModelId: aws.String("id"), Record: map[string]string{}, diff --git a/service/polly/customizations_test.go b/service/polly/customizations_test.go index 761b4e40561..2c1fc3efc94 100644 --- a/service/polly/customizations_test.go +++ b/service/polly/customizations_test.go @@ -8,6 +8,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" + "github.com/aws/aws-sdk-go-v2/service/polly/enums" + "github.com/aws/aws-sdk-go-v2/service/polly/types" ) func TestRestGETStrategy(t *testing.T) { @@ -34,10 +36,10 @@ func TestPresign(t *testing.T) { cfg.EndpointResolver = endpoints.NewDefaultResolver() svc := New(cfg) - r := svc.SynthesizeSpeechRequest(&SynthesizeSpeechInput{ + r := svc.SynthesizeSpeechRequest(&types.SynthesizeSpeechInput{ Text: aws.String("Moo"), - OutputFormat: OutputFormatMp3, - VoiceId: VoiceIdGeraint, + OutputFormat: enums.OutputFormatMp3, + VoiceId: enums.VoiceIdGeraint, }) url, err := r.Presign(time.Second) diff --git a/service/rds/customizations.go b/service/rds/customizations.go index aea8fe6b4dd..06edafee23e 100644 --- a/service/rds/customizations.go +++ b/service/rds/customizations.go @@ -3,6 +3,8 @@ package rds import ( "time" + "github.com/aws/aws-sdk-go-v2/service/rds/types" + "github.com/aws/aws-sdk-go-v2/aws" request "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awsutil" @@ -40,7 +42,7 @@ func fillPresignedURL(r *request.Request) { } func copyDBSnapshotPresign(r *request.Request) { - originParams := r.Params.(*CopyDBSnapshotInput) + originParams := r.Params.(*types.CopyDBSnapshotInput) if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil { return @@ -51,12 +53,12 @@ func copyDBSnapshotPresign(r *request.Request) { if *originParams.SourceRegion == *originParams.DestinationRegion { return } - newParams := awsutil.CopyOf(r.Params).(*CopyDBSnapshotInput) + newParams := awsutil.CopyOf(r.Params).(*types.CopyDBSnapshotInput) originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) } func createDBInstanceReadReplicaPresign(r *request.Request) { - originParams := r.Params.(*CreateDBInstanceReadReplicaInput) + originParams := r.Params.(*types.CreateDBInstanceReadReplicaInput) if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil { return @@ -67,12 +69,12 @@ func createDBInstanceReadReplicaPresign(r *request.Request) { if *originParams.SourceRegion == *originParams.DestinationRegion { return } - newParams := awsutil.CopyOf(r.Params).(*CreateDBInstanceReadReplicaInput) + newParams := awsutil.CopyOf(r.Params).(*types.CreateDBInstanceReadReplicaInput) originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) } func copyDBClusterSnapshotPresign(r *request.Request) { - originParams := r.Params.(*CopyDBClusterSnapshotInput) + originParams := r.Params.(*types.CopyDBClusterSnapshotInput) if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil { return @@ -83,12 +85,12 @@ func copyDBClusterSnapshotPresign(r *request.Request) { if *originParams.SourceRegion == *originParams.DestinationRegion { return } - newParams := awsutil.CopyOf(r.Params).(*CopyDBClusterSnapshotInput) + newParams := awsutil.CopyOf(r.Params).(*types.CopyDBClusterSnapshotInput) originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) } func createDBClusterPresign(r *request.Request) { - originParams := r.Params.(*CreateDBClusterInput) + originParams := r.Params.(*types.CreateDBClusterInput) if originParams.SourceRegion == nil || originParams.PreSignedUrl != nil || originParams.DestinationRegion != nil { return @@ -99,7 +101,7 @@ func createDBClusterPresign(r *request.Request) { if *originParams.SourceRegion == *originParams.DestinationRegion { return } - newParams := awsutil.CopyOf(r.Params).(*CreateDBClusterInput) + newParams := awsutil.CopyOf(r.Params).(*types.CreateDBClusterInput) originParams.PreSignedUrl = presignURL(r, originParams.SourceRegion, newParams) } diff --git a/service/rds/customizations_test.go b/service/rds/customizations_test.go index f4e209cef73..96d9326ebfc 100644 --- a/service/rds/customizations_test.go +++ b/service/rds/customizations_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" + "github.com/aws/aws-sdk-go-v2/service/rds/types" ) func TestCopyDBSnapshotNoPanic(t *testing.T) { @@ -49,7 +50,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { }{ opCopyDBSnapshot: { Req: func() *request.Request { - req := svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ + req := svc.CopyDBSnapshotRequest(&types.CopyDBSnapshotInput{ SourceRegion: aws.String("us-west-1"), SourceDBSnapshotIdentifier: aws.String("foo"), TargetDBSnapshotIdentifier: aws.String("bar"), @@ -63,7 +64,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCreateDBInstanceReadReplica: { Req: func() *request.Request { req := svc.CreateDBInstanceReadReplicaRequest( - &CreateDBInstanceReadReplicaInput{ + &types.CreateDBInstanceReadReplicaInput{ SourceRegion: aws.String("us-west-1"), SourceDBInstanceIdentifier: aws.String("foo"), DBInstanceIdentifier: aws.String("bar"), @@ -76,7 +77,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCopyDBClusterSnapshot: { Req: func() *request.Request { req := svc.CopyDBClusterSnapshotRequest( - &CopyDBClusterSnapshotInput{ + &types.CopyDBClusterSnapshotInput{ SourceRegion: aws.String("us-west-1"), SourceDBClusterSnapshotIdentifier: aws.String("foo"), TargetDBClusterSnapshotIdentifier: aws.String("bar"), @@ -89,7 +90,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCreateDBCluster: { Req: func() *request.Request { req := svc.CreateDBClusterRequest( - &CreateDBClusterInput{ + &types.CreateDBClusterInput{ SourceRegion: aws.String("us-west-1"), DBClusterIdentifier: aws.String("foo"), Engine: aws.String("bar"), @@ -101,7 +102,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { }, opCopyDBSnapshot + " same region": { Req: func() *request.Request { - req := svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ + req := svc.CopyDBSnapshotRequest(&types.CopyDBSnapshotInput{ SourceRegion: aws.String("us-west-2"), SourceDBSnapshotIdentifier: aws.String("foo"), TargetDBSnapshotIdentifier: aws.String("bar"), @@ -112,7 +113,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { }, opCreateDBInstanceReadReplica + " same region": { Req: func() *request.Request { - req := svc.CreateDBInstanceReadReplicaRequest(&CreateDBInstanceReadReplicaInput{ + req := svc.CreateDBInstanceReadReplicaRequest(&types.CreateDBInstanceReadReplicaInput{ SourceRegion: aws.String("us-west-2"), SourceDBInstanceIdentifier: aws.String("foo"), DBInstanceIdentifier: aws.String("bar"), @@ -124,7 +125,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCopyDBClusterSnapshot + " same region": { Req: func() *request.Request { req := svc.CopyDBClusterSnapshotRequest( - &CopyDBClusterSnapshotInput{ + &types.CopyDBClusterSnapshotInput{ SourceRegion: aws.String("us-west-2"), SourceDBClusterSnapshotIdentifier: aws.String("foo"), TargetDBClusterSnapshotIdentifier: aws.String("bar"), @@ -136,7 +137,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCreateDBCluster + " same region": { Req: func() *request.Request { req := svc.CreateDBClusterRequest( - &CreateDBClusterInput{ + &types.CreateDBClusterInput{ SourceRegion: aws.String("us-west-2"), DBClusterIdentifier: aws.String("foo"), Engine: aws.String("bar"), @@ -147,7 +148,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { }, opCopyDBSnapshot + " presignURL set": { Req: func() *request.Request { - req := svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ + req := svc.CopyDBSnapshotRequest(&types.CopyDBSnapshotInput{ SourceRegion: aws.String("us-west-1"), SourceDBSnapshotIdentifier: aws.String("foo"), TargetDBSnapshotIdentifier: aws.String("bar"), @@ -159,7 +160,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { }, opCreateDBInstanceReadReplica + " presignURL set": { Req: func() *request.Request { - req := svc.CreateDBInstanceReadReplicaRequest(&CreateDBInstanceReadReplicaInput{ + req := svc.CreateDBInstanceReadReplicaRequest(&types.CreateDBInstanceReadReplicaInput{ SourceRegion: aws.String("us-west-1"), SourceDBInstanceIdentifier: aws.String("foo"), DBInstanceIdentifier: aws.String("bar"), @@ -172,7 +173,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCopyDBClusterSnapshot + " presignURL set": { Req: func() *request.Request { req := svc.CopyDBClusterSnapshotRequest( - &CopyDBClusterSnapshotInput{ + &types.CopyDBClusterSnapshotInput{ SourceRegion: aws.String("us-west-1"), SourceDBClusterSnapshotIdentifier: aws.String("foo"), TargetDBClusterSnapshotIdentifier: aws.String("bar"), @@ -185,7 +186,7 @@ func TestPresignCrossRegionRequest(t *testing.T) { opCreateDBCluster + " presignURL set": { Req: func() *request.Request { req := svc.CreateDBClusterRequest( - &CreateDBClusterInput{ + &types.CreateDBClusterInput{ SourceRegion: aws.String("us-west-1"), DBClusterIdentifier: aws.String("foo"), Engine: aws.String("bar"), @@ -221,7 +222,7 @@ func TestPresignWithSourceNotSet(t *testing.T) { svc := New(cfg) - reqs[opCopyDBSnapshot] = svc.CopyDBSnapshotRequest(&CopyDBSnapshotInput{ + reqs[opCopyDBSnapshot] = svc.CopyDBSnapshotRequest(&types.CopyDBSnapshotInput{ SourceDBSnapshotIdentifier: aws.String("foo"), TargetDBSnapshotIdentifier: aws.String("bar"), }).Request diff --git a/service/route53/customizations_test.go b/service/route53/customizations_test.go index 090eb47cde5..63a807cca58 100644 --- a/service/route53/customizations_test.go +++ b/service/route53/customizations_test.go @@ -6,6 +6,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/route53" + "github.com/aws/aws-sdk-go-v2/service/route53/types" ) func TestBuildCorrectURI(t *testing.T) { @@ -14,7 +15,7 @@ func TestBuildCorrectURI(t *testing.T) { svc := route53.New(unit.Config()) svc.Handlers.Validate.Clear() - req := svc.GetHostedZoneRequest(&route53.GetHostedZoneInput{ + req := svc.GetHostedZoneRequest(&types.GetHostedZoneInput{ Id: aws.String("/hostedzone/ABCDEFG"), }) diff --git a/service/route53/unmarshal_error_test.go b/service/route53/unmarshal_error_test.go index 8e925c404e9..9cbb9ebdec6 100644 --- a/service/route53/unmarshal_error_test.go +++ b/service/route53/unmarshal_error_test.go @@ -12,6 +12,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/route53" + "github.com/aws/aws-sdk-go-v2/service/route53/enums" + "github.com/aws/aws-sdk-go-v2/service/route53/types" ) func makeClientWithResponse(response string) *route53.Client { @@ -43,7 +45,7 @@ func TestUnmarshalStandardError(t *testing.T) { r := makeClientWithResponse(errorResponse) - req := r.CreateHostedZoneRequest(&route53.CreateHostedZoneInput{ + req := r.CreateHostedZoneRequest(&types.CreateHostedZoneInput{ CallerReference: aws.String("test"), Name: aws.String("test_zone"), }) @@ -77,17 +79,17 @@ but it already exists r := makeClientWithResponse(errorResponse) - params := &route53.ChangeResourceRecordSetsInput{ + params := &types.ChangeResourceRecordSetsInput{ HostedZoneId: aws.String("zoneId"), - ChangeBatch: &route53.ChangeBatch{ - Changes: []route53.Change{ + ChangeBatch: &types.ChangeBatch{ + Changes: []types.Change{ { - Action: route53.ChangeActionCreate, - ResourceRecordSet: &route53.ResourceRecordSet{ + Action: enums.ChangeActionCreate, + ResourceRecordSet: &types.ResourceRecordSet{ Name: aws.String("domain"), - Type: route53.RRTypeCname, + Type: enums.RRTypeCname, TTL: aws.Int64(120), - ResourceRecords: []route53.ResourceRecord{ + ResourceRecords: []types.ResourceRecord{ { Value: aws.String("cname"), }, diff --git a/service/s3/bucket_location.go b/service/s3/bucket_location.go index f8086c07e93..f34529eed70 100644 --- a/service/s3/bucket_location.go +++ b/service/s3/bucket_location.go @@ -7,6 +7,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var reBucketLocation = regexp.MustCompile(`>([^<>]+)<\/Location`) @@ -19,7 +21,7 @@ var reBucketLocation = regexp.MustCompile(`>([^<>]+)<\/Location`) // // See http://docs.aws.amazon.com/AmazonS3/latest/API/RESTBucketGETlocation.html // for more information on the values that can be returned. -func NormalizeBucketLocation(loc BucketLocationConstraint) BucketLocationConstraint { +func NormalizeBucketLocation(loc enums.BucketLocationConstraint) enums.BucketLocationConstraint { switch loc { case "": loc = "us-east-1" @@ -50,7 +52,7 @@ var NormalizeBucketLocationHandler = aws.NamedHandler{ return } - out := req.Data.(*GetBucketLocationOutput) + out := req.Data.(*types.GetBucketLocationOutput) loc := NormalizeBucketLocation(out.LocationConstraint) out.LocationConstraint = loc }, @@ -65,7 +67,7 @@ var NormalizeBucketLocationHandler = aws.NamedHandler{ // for more information on the values that can be returned. // // result, err := svc.GetBucketLocationWithContext(ctx, -// &s3.GetBucketLocationInput{ +// &types.GetBucketLocationInput{ // Bucket: aws.String(bucket), // }, // s3.WithNormalizeBucketLocation, @@ -75,7 +77,7 @@ func WithNormalizeBucketLocation(r *aws.Request) { } func buildGetBucketLocation(r *aws.Request) { - out := r.Data.(*GetBucketLocationOutput) + out := r.Data.(*types.GetBucketLocationOutput) b, err := ioutil.ReadAll(r.HTTPResponse.Body) if err != nil { r.Error = awserr.New("SerializationError", "failed reading response body", err) @@ -84,19 +86,19 @@ func buildGetBucketLocation(r *aws.Request) { match := reBucketLocation.FindSubmatch(b) if len(match) > 1 { - loc := BucketLocationConstraint(match[1]) + loc := enums.BucketLocationConstraint(match[1]) out.LocationConstraint = loc } } func populateLocationConstraint(r *aws.Request) { if r.ParamsFilled() && r.Config.Region != "us-east-1" { - in := r.Params.(*CreateBucketInput) + in := r.Params.(*types.CreateBucketInput) if in.CreateBucketConfiguration == nil { r.Params = awsutil.CopyOf(r.Params) - in = r.Params.(*CreateBucketInput) - in.CreateBucketConfiguration = &CreateBucketConfiguration{ - LocationConstraint: BucketLocationConstraint(r.Config.Region), + in = r.Params.(*types.CreateBucketInput) + in.CreateBucketConfiguration = &types.CreateBucketConfiguration{ + LocationConstraint: enums.BucketLocationConstraint(r.Config.Region), } } } diff --git a/service/s3/bucket_location_test.go b/service/s3/bucket_location_test.go index 2dc0b714665..6267626c519 100644 --- a/service/s3/bucket_location_test.go +++ b/service/s3/bucket_location_test.go @@ -12,6 +12,8 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var s3LocationTests = []struct { @@ -31,7 +33,7 @@ func TestGetBucketLocation(t *testing.T) { r.HTTPResponse = &http.Response{StatusCode: 200, Body: reader} }) - req := s.GetBucketLocationRequest(&s3.GetBucketLocationInput{Bucket: aws.String("bucket")}) + req := s.GetBucketLocationRequest(&types.GetBucketLocationInput{Bucket: aws.String("bucket")}) resp, err := req.Send(context.Background()) if err != nil { t.Errorf("expected no error, but received %v", err) @@ -60,7 +62,7 @@ func TestNormalizeBucketLocation(t *testing.T) { } for i, c := range cases { - actual := s3.NormalizeBucketLocation(s3.BucketLocationConstraint(c.In)) + actual := s3.NormalizeBucketLocation(enums.BucketLocationConstraint(c.In)) if e, a := c.Out, string(actual); e != a { t.Errorf("%d, expect %s bucket location, got %s", i, e, a) } @@ -81,12 +83,12 @@ func TestWithNormalizeBucketLocation(t *testing.T) { } for i, c := range cases { - req.Data = &s3.GetBucketLocationOutput{ - LocationConstraint: s3.BucketLocationConstraint(c.In), + req.Data = &types.GetBucketLocationOutput{ + LocationConstraint: enums.BucketLocationConstraint(c.In), } req.Handlers.Unmarshal.Run(req) - v := req.Data.(*s3.GetBucketLocationOutput).LocationConstraint + v := req.Data.(*types.GetBucketLocationOutput).LocationConstraint if e, a := c.Out, string(v); e != a { t.Errorf("%d, expect %s bucket location, got %s", i, e, a) } @@ -95,7 +97,7 @@ func TestWithNormalizeBucketLocation(t *testing.T) { func TestPopulateLocationConstraint(t *testing.T) { s := s3.New(unit.Config()) - in := &s3.CreateBucketInput{ + in := &types.CreateBucketInput{ Bucket: aws.String("bucket"), } req := s.CreateBucketRequest(in) @@ -104,7 +106,7 @@ func TestPopulateLocationConstraint(t *testing.T) { } v, _ := awsutil.ValuesAtPath(req.Params, "CreateBucketConfiguration.LocationConstraint") - if e, a := "mock-region", string(v[0].(s3.BucketLocationConstraint)); e != a { + if e, a := "mock-region", string(v[0].(enums.BucketLocationConstraint)); e != a { t.Errorf("expect %s location constraint, got %s", e, a) } if v := in.CreateBucketConfiguration; v != nil { @@ -115,9 +117,9 @@ func TestPopulateLocationConstraint(t *testing.T) { func TestNoPopulateLocationConstraintIfProvided(t *testing.T) { s := s3.New(unit.Config()) - req := s.CreateBucketRequest(&s3.CreateBucketInput{ + req := s.CreateBucketRequest(&types.CreateBucketInput{ Bucket: aws.String("bucket"), - CreateBucketConfiguration: &s3.CreateBucketConfiguration{}, + CreateBucketConfiguration: &types.CreateBucketConfiguration{}, }) if err := req.Build(); err != nil { t.Fatalf("expect no error, got %v", err) @@ -126,7 +128,7 @@ func TestNoPopulateLocationConstraintIfProvided(t *testing.T) { if l := len(v); l != 1 { t.Errorf("expect empty string only, got %d elements", l) } - if v[0].(s3.BucketLocationConstraint) != s3.BucketLocationConstraint("") { + if v[0].(enums.BucketLocationConstraint) != enums.BucketLocationConstraint("") { t.Errorf("expected empty string, but received %v", v[0]) } } @@ -136,7 +138,7 @@ func TestNoPopulateLocationConstraintIfClassic(t *testing.T) { cfg.Region = "us-east-1" s := s3.New(cfg) - req := s.CreateBucketRequest(&s3.CreateBucketInput{ + req := s.CreateBucketRequest(&types.CreateBucketInput{ Bucket: aws.String("bucket"), }) if err := req.Build(); err != nil { diff --git a/service/s3/cust_integ_shared_test.go b/service/s3/cust_integ_shared_test.go index 6ceda050747..e8ace6412a7 100644 --- a/service/s3/cust_integ_shared_test.go +++ b/service/s3/cust_integ_shared_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration/s3integ" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) const integBucketPrefix = "aws-sdk-go-v2-integration" @@ -57,7 +58,7 @@ func putTestFile(ctx context.Context, t *testing.T, filename, key string) { func putTestContent(ctx context.Context, t *testing.T, reader io.ReadSeeker, key string) { fmt.Println(bucketName, key, svc) - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: bucketName, Key: aws.String(key), Body: reader, diff --git a/service/s3/cust_integ_test.go b/service/s3/cust_integ_test.go index 9b4b7686c6b..0257a43bd26 100644 --- a/service/s3/cust_integ_test.go +++ b/service/s3/cust_integ_test.go @@ -12,11 +12,11 @@ import ( "time" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestInteg_WriteToObject(t *testing.T) { - _, err := svc.PutObjectRequest(&s3.PutObjectInput{ + _, err := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: bucketName, Key: aws.String("key name"), Body: bytes.NewReader([]byte("hello world")), @@ -25,7 +25,7 @@ func TestInteg_WriteToObject(t *testing.T) { t.Errorf("expect no error, got %v", err) } - getResp, err := svc.GetObjectRequest(&s3.GetObjectInput{ + getResp, err := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: bucketName, Key: aws.String("key name"), }).Send(context.Background()) @@ -40,7 +40,7 @@ func TestInteg_WriteToObject(t *testing.T) { } func TestInteg_PresignedGetPut(t *testing.T) { - putReq := svc.PutObjectRequest(&s3.PutObjectInput{ + putReq := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: bucketName, Key: aws.String("presigned-key"), }) @@ -71,7 +71,7 @@ func TestInteg_PresignedGetPut(t *testing.T) { } // Presign a GET on the same URL - getReq := svc.GetObjectRequest(&s3.GetObjectInput{ + getReq := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: bucketName, Key: aws.String("presigned-key"), }) diff --git a/service/s3/customizations.go b/service/s3/customizations.go index 9e1f174076a..856e3c9cd74 100644 --- a/service/s3/customizations.go +++ b/service/s3/customizations.go @@ -48,17 +48,17 @@ func defaultInitRequestFn(c *Client, r *aws.Request) { // bucketGetter is an accessor interface to grab the "Bucket" field from // an S3 type. type bucketGetter interface { - getBucket() string + GetBucket() string } // sseCustomerKeyGetter is an accessor interface to grab the "SSECustomerKey" // field from an S3 type. type sseCustomerKeyGetter interface { - getSSECustomerKey() string + GetSSECustomerKey() string } // copySourceSSECustomerKeyGetter is an accessor interface to grab the // "CopySourceSSECustomerKey" field from an S3 type. type copySourceSSECustomerKeyGetter interface { - getCopySourceSSECustomerKey() string + GetCopySourceSSECustomerKey() string } diff --git a/service/s3/customizations_test.go b/service/s3/customizations_test.go index 4f94a405405..962e6cfbe38 100644 --- a/service/s3/customizations_test.go +++ b/service/s3/customizations_test.go @@ -14,6 +14,8 @@ import ( request "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func assertMD5(t *testing.T, req *request.Request) { @@ -34,10 +36,10 @@ func assertMD5(t *testing.T, req *request.Request) { func TestMD5InPutBucketCors(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.PutBucketCorsRequest(&s3.PutBucketCorsInput{ + req := svc.PutBucketCorsRequest(&types.PutBucketCorsInput{ Bucket: aws.String("bucketname"), - CORSConfiguration: &s3.CORSConfiguration{ - CORSRules: []s3.CORSRule{ + CORSConfiguration: &types.CORSConfiguration{ + CORSRules: []types.CORSRule{ { AllowedMethods: []string{"GET"}, AllowedOrigins: []string{"*"}, @@ -50,14 +52,14 @@ func TestMD5InPutBucketCors(t *testing.T) { func TestMD5InPutBucketLifecycle(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.PutBucketLifecycleRequest(&s3.PutBucketLifecycleInput{ + req := svc.PutBucketLifecycleRequest(&types.PutBucketLifecycleInput{ Bucket: aws.String("bucketname"), - LifecycleConfiguration: &s3.LifecycleConfiguration{ - Rules: []s3.Rule{ + LifecycleConfiguration: &types.LifecycleConfiguration{ + Rules: []types.Rule{ { ID: aws.String("ID"), Prefix: aws.String("Prefix"), - Status: s3.ExpirationStatusEnabled, + Status: enums.ExpirationStatusEnabled, }, }, }, @@ -67,7 +69,7 @@ func TestMD5InPutBucketLifecycle(t *testing.T) { func TestMD5InPutBucketPolicy(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.PutBucketPolicyRequest(&s3.PutBucketPolicyInput{ + req := svc.PutBucketPolicyRequest(&types.PutBucketPolicyInput{ Bucket: aws.String("bucketname"), Policy: aws.String("{}"), }) @@ -76,10 +78,10 @@ func TestMD5InPutBucketPolicy(t *testing.T) { func TestMD5InPutBucketTagging(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.PutBucketTaggingRequest(&s3.PutBucketTaggingInput{ + req := svc.PutBucketTaggingRequest(&types.PutBucketTaggingInput{ Bucket: aws.String("bucketname"), - Tagging: &s3.Tagging{ - TagSet: []s3.Tag{ + Tagging: &types.Tagging{ + TagSet: []types.Tag{ {Key: aws.String("KEY"), Value: aws.String("VALUE")}, }, }, @@ -89,10 +91,10 @@ func TestMD5InPutBucketTagging(t *testing.T) { func TestMD5InDeleteObjects(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.DeleteObjectsRequest(&s3.DeleteObjectsInput{ + req := svc.DeleteObjectsRequest(&types.DeleteObjectsInput{ Bucket: aws.String("bucketname"), - Delete: &s3.Delete{ - Objects: []s3.ObjectIdentifier{ + Delete: &types.Delete{ + Objects: []types.ObjectIdentifier{ {Key: aws.String("key")}, }, }, @@ -102,11 +104,11 @@ func TestMD5InDeleteObjects(t *testing.T) { func TestMD5InPutBucketLifecycleConfiguration(t *testing.T) { svc := s3.New(unit.Config()) - req := svc.PutBucketLifecycleConfigurationRequest(&s3.PutBucketLifecycleConfigurationInput{ + req := svc.PutBucketLifecycleConfigurationRequest(&types.PutBucketLifecycleConfigurationInput{ Bucket: aws.String("bucketname"), - LifecycleConfiguration: &s3.BucketLifecycleConfiguration{ - Rules: []s3.LifecycleRule{ - {Prefix: aws.String("prefix"), Status: s3.ExpirationStatusEnabled}, + LifecycleConfiguration: &types.BucketLifecycleConfiguration{ + Rules: []types.LifecycleRule{ + {Prefix: aws.String("prefix"), Status: enums.ExpirationStatusEnabled}, }, }, }) @@ -131,7 +133,7 @@ func TestPutObjectMetadataWithUnicode(t *testing.T) { svc := s3.New(cfg) - req := svc.PutObjectRequest(&s3.PutObjectInput{ + req := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("my_bucket"), Key: aws.String("my_key"), Body: strings.NewReader(""), @@ -157,7 +159,7 @@ func TestGetObjectMetadataWithUnicode(t *testing.T) { svc := s3.New(cfg) - req := svc.GetObjectRequest(&s3.GetObjectInput{ + req := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String("my_bucket"), Key: aws.String("my_key"), }) diff --git a/service/s3/host_style_bucket.go b/service/s3/host_style_bucket.go index 56ad3963d77..365881df1a5 100644 --- a/service/s3/host_style_bucket.go +++ b/service/s3/host_style_bucket.go @@ -114,7 +114,7 @@ func updateEndpointForAccelerate(r *aws.Request) { // If no bucket is found, or the field is empty "", false will be returned. func bucketNameFromReqParams(params interface{}) (string, bool) { if iface, ok := params.(bucketGetter); ok { - b := iface.getBucket() + b := iface.GetBucket() return b, len(b) > 0 } diff --git a/service/s3/host_style_bucket_test.go b/service/s3/host_style_bucket_test.go index 4ec27e49d57..b692463e869 100644 --- a/service/s3/host_style_bucket_test.go +++ b/service/s3/host_style_bucket_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) type s3BucketTest struct { @@ -65,7 +66,7 @@ func runTests(t *testing.T, svc *s3.Client, tests []s3BucketTest) { t.Helper() for i, test := range tests { - req := svc.ListObjectsRequest(&s3.ListObjectsInput{Bucket: &test.bucket}) + req := svc.ListObjectsRequest(&types.ListObjectsInput{Bucket: &test.bucket}) req.Build() if test.errCode != "" { @@ -149,7 +150,7 @@ func TestHostStyleBucketGetBucketLocation(t *testing.T) { cfg.EndpointResolver = endpoints.NewDefaultResolver() s := s3.New(cfg) - req := s.GetBucketLocationRequest(&s3.GetBucketLocationInput{ + req := s.GetBucketLocationRequest(&types.GetBucketLocationInput{ Bucket: aws.String("bucket"), }) @@ -171,7 +172,7 @@ func TestVirtualHostStyleSuite(t *testing.T) { t.Fatalf("expect no error, %v", err) } - cases := []struct { + var cases []struct { Bucket string Region string UseDualStack bool @@ -179,7 +180,7 @@ func TestVirtualHostStyleSuite(t *testing.T) { ConfiguredAddressingStyle string ExpectedURI string - }{} + } decoder := json.NewDecoder(f) if err := decoder.Decode(&cases); err != nil { @@ -199,7 +200,7 @@ func TestVirtualHostStyleSuite(t *testing.T) { svc.ForcePathStyle = c.ConfiguredAddressingStyle == testPathStyle svc.UseAccelerate = c.UseS3Accelerate - req := svc.HeadBucketRequest(&s3.HeadBucketInput{ + req := svc.HeadBucketRequest(&types.HeadBucketInput{ Bucket: &c.Bucket, }) req.Build() diff --git a/service/s3/internal/awsrestxml/marshal.go b/service/s3/internal/awsrestxml/marshal.go new file mode 100644 index 00000000000..f48482b758f --- /dev/null +++ b/service/s3/internal/awsrestxml/marshal.go @@ -0,0 +1,164 @@ +package awsrestxml + +import ( + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol" + restV2 "github.com/aws/aws-sdk-go-v2/private/protocol/rest/v2" + "github.com/aws/aws-sdk-go-v2/service/s3/types" +) + +// ProtoPutObjectMarshaler defines marshaler for ProtoPutObject operation +type ProtoPutObjectMarshaler struct { + Input *types.PutObjectInput +} + +// MarshalOperation is the top level method used within a handler stack to marshal an operation +// This method calls appropriate marshal shape functions as per the input shape and protocol used by the service. +func (m ProtoPutObjectMarshaler) MarshalOperation(r *aws.Request) { + var err error + encoder := restV2.NewEncoder(r.HTTPRequest) + + err = MarshalPutObjectInputShapeAWSREST(m.Input, encoder) + if err != nil { + r.Error = err + return + } + encoder.Encode() + + // Todo Instead of passing aws.Request directly to MarshalPutObjectInputShapeAWSXML; + // we should pass the payload as an argument + if err = MarshalPutObjectInputShapeAWSXML(m.Input, r); err != nil { + r.Error = err + return + } +} + +// MarshalPutObjectInputShapeAWSREST is a stand alone function used to marshal the HTTP bindings a input shape. +// This method uses the rest encoder utility +func MarshalPutObjectInputShapeAWSREST(input *types.PutObjectInput, encoder *restV2.Encoder) error { + // Encoding shapes with location `headers` + marshalShapeMapForHeaders(encoder, "x-amz-meta-", input.Metadata) + // Encoding shapes with location `header` + if input.CacheControl != nil { + encoder.AddHeader("Cache-Control").String(*input.CacheControl) + } + if input.ContentDisposition != nil { + encoder.AddHeader("Content-Disposition").String(*input.ContentDisposition) + } + if input.ContentLanguage != nil { + encoder.AddHeader("Content-Language").String(*input.ContentLanguage) + } + if input.ContentMD5 != nil { + encoder.AddHeader("Content-Md5").String(*input.ContentMD5) + } + if input.ContentLength != nil { + encoder.AddHeader("Content-Length").Integer(*input.ContentLength) + } + if input.ContentType != nil { + encoder.AddHeader("Content-Type").String(*input.ContentType) + } + if input.ACL != "" { + encoder.AddHeader("x-amz-acl").String(string(input.ACL)) + } + if input.GrantFullControl != nil { + encoder.AddHeader("x-amz-grant-full-control").String(*input.GrantFullControl) + } + if input.GrantRead != nil { + encoder.AddHeader("x-amz-grant-read").String(*input.GrantRead) + } + if input.GrantReadACP != nil { + encoder.AddHeader("x-amz-grant-read-acp").String(*input.GrantReadACP) + } + if input.GrantWriteACP != nil { + encoder.AddHeader("x-amz-grant-write-acp").String(*input.GrantWriteACP) + } + if input.ObjectLockLegalHoldStatus != "" { + encoder.AddHeader("x-amz-object-lock-legal-hold").String(string(input.ObjectLockLegalHoldStatus)) + } + if input.ObjectLockMode != "" { + encoder.AddHeader("x-amz-object-lock-mode").String(string(input.ObjectLockMode)) + } + if input.Tagging != nil { + encoder.AddHeader("x-amz-tagging").String(*input.Tagging) + } + if input.RequestPayer != "" { + encoder.AddHeader("x-amz-request-payer").String(string(input.RequestPayer)) + } + if input.SSEKMSEncryptionContext != nil { + encoder.AddHeader("x-amz-server-side-encryption-context").String(*input.SSEKMSEncryptionContext) + } + if input.SSEKMSKeyId != nil { + encoder.AddHeader("x-amz-server-side-encryption-aws-kms-key-id").String(*input.SSEKMSKeyId) + } + if input.SSECustomerKey != nil { + encoder.AddHeader("x-amz-server-side-encryption-customer-key-MD5").String(*input.SSECustomerKeyMD5) + } + if input.SSECustomerKeyMD5 != nil { + encoder.AddHeader("x-amz-server-side-encryption-customer-key-MD5").String(*input.SSECustomerKeyMD5) + } + if input.SSECustomerAlgorithm != nil { + encoder.AddHeader("x-amz-server-side-encryption-customer-algorithm").String(*input.SSECustomerAlgorithm) + } + if input.WebsiteRedirectLocation != nil { + encoder.AddHeader("x-amz-website-redirect-location").String(*input.WebsiteRedirectLocation) + } + if input.StorageClass != "" { + encoder.AddHeader("x-amz-storage-class").String(string(input.StorageClass)) + } + if input.ServerSideEncryption != "" { + encoder.AddHeader("x-amz-server-side-encryption").String(string(input.ServerSideEncryption)) + } + if input.Expires != nil { + if err := encoder.AddHeader("Expires").Time(*input.Expires, protocol.RFC822TimeFormatName); err != nil { + return fmt.Errorf("failed to encode header for shape Expires: \n \t %v", err) + } + } + if input.ObjectLockRetainUntilDate != nil { + if err := encoder.AddHeader("x-amz-object-lock-retain-until-date").Time(*input.ObjectLockRetainUntilDate, protocol.ISO8601TimeFormatName); err != nil { + return fmt.Errorf("failed to encode header for shape Expires: \n \t %v", err) + } + } + // Encoding shapes with location `uri` + if input.Bucket != nil { + if err := encoder.SetURI("Bucket").String(*input.Bucket); err != nil { + return fmt.Errorf("failed to encode URI, \n\t %v", err) + } + } + + if input.Key != nil { + if err := encoder.SetURI("Key").String(*input.Key); err != nil { + return fmt.Errorf("failed to encode URI, \n\t %v", err) + } + } + + return nil +} + +// MarshalPutObjectInputShapeAWSXML is a stand alone function used to marshal the xml payload +// This should be generated according to the payload type for rest-xml protocol +func MarshalPutObjectInputShapeAWSXML(input *types.PutObjectInput, r *aws.Request) error { + if input.Body != nil { + r.SetReaderBody(input.Body) + } + return r.Error +} + +// marshalShapeMapForHeaders is marshal function that takes in a map[string]string as an input along with an encoder +// and location Name which should be used to marshal the shape with location headers. +func marshalShapeMapForHeaders(encoder *restV2.Encoder, locationName string, input map[string]string) { + headerObject := encoder.Headers(locationName) + for k, v := range input { + headerObject.AddHeader(k).String(v) + } +} + +// GetNamedBuildHandler returns a Named Build Handler for an operation marshal function +func (m ProtoPutObjectMarshaler) GetNamedBuildHandler() aws.NamedHandler { + const BuildHandler = "ProtoPutBucket.BuildHandler" + return aws.NamedHandler{ + Name: BuildHandler, + Fn: m.MarshalOperation, + } +} diff --git a/service/s3/platform_handlers_go1.6_test.go b/service/s3/platform_handlers_go1.6_test.go index c3cc646b391..1c95227961f 100644 --- a/service/s3/platform_handlers_go1.6_test.go +++ b/service/s3/platform_handlers_go1.6_test.go @@ -9,11 +9,12 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestAdd100Continue_Added(t *testing.T) { svc := s3.New(unit.Config()) - r := svc.PutObjectRequest(&s3.PutObjectInput{ + r := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("dest"), Body: bytes.NewReader(make([]byte, 1024*1024*5)), @@ -34,7 +35,7 @@ func TestAdd100Continue_SkipDisabled(t *testing.T) { svc := s3.New(cfg) svc.Disable100Continue = true - r := svc.PutObjectRequest(&s3.PutObjectInput{ + r := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("dest"), Body: bytes.NewReader(make([]byte, 1024*1024*5)), @@ -52,7 +53,7 @@ func TestAdd100Continue_SkipDisabled(t *testing.T) { func TestAdd100Continue_SkipNonPUT(t *testing.T) { svc := s3.New(unit.Config()) - r := svc.GetObjectRequest(&s3.GetObjectInput{ + r := svc.GetObjectRequest(&types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("dest"), }) @@ -69,7 +70,7 @@ func TestAdd100Continue_SkipNonPUT(t *testing.T) { func TestAdd100Continue_SkipTooSmall(t *testing.T) { svc := s3.New(unit.Config()) - r := svc.PutObjectRequest(&s3.PutObjectInput{ + r := svc.PutObjectRequest(&types.PutObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("dest"), Body: bytes.NewReader(make([]byte, 1024*1024*1)), diff --git a/service/s3/proto_api_op_PutObject.go b/service/s3/proto_api_op_PutObject.go new file mode 100644 index 00000000000..f87128770fd --- /dev/null +++ b/service/s3/proto_api_op_PutObject.go @@ -0,0 +1,248 @@ +package s3 + +import ( + "context" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/private/protocol/restxml" + "github.com/aws/aws-sdk-go-v2/service/s3/internal/awsrestxml" + "github.com/aws/aws-sdk-go-v2/service/s3/types" +) + +const protoOpPutObject = "PutObject" + +// ProtoPutObjectRequest returns a request value for making API operation for +// Amazon Simple Storage Service. +// +// Adds an object to a bucket. You must have WRITE permissions on a bucket to +// add an object to it. +// +// Amazon S3 never adds partial objects; if you receive a success response, +// Amazon S3 added the entire object to the bucket. +// +// Amazon S3 is a distributed system. If it receives multiple write requests +// for the same object simultaneously, it overwrites all but the last object +// written. Amazon S3 does not provide object locking; if you need this, make +// sure to build it into your application layer or use versioning instead. +// +// To ensure that data is not corrupted traversing the network, use the Content-MD5 +// header. When you use this header, Amazon S3 checks the object against the +// provided MD5 value and, if they do not match, returns an error. Additionally, +// you can calculate the MD5 while putting an object to Amazon S3 and compare +// the returned ETag to the calculated MD5 value. +// +// To configure your application to send the request headers before sending +// the request body, use the 100-continue HTTP status code. For PUT operations, +// this helps you avoid sending the message body if the message is rejected +// based on the headers (for example, because authentication fails or a redirect +// occurs). For more information on the 100-continue HTTP status code, see Section +// 8.2.3 of http://www.ietf.org/rfc/rfc2616.txt (http://www.ietf.org/rfc/rfc2616.txt). +// +// You can optionally request server-side encryption. With server-side encryption, +// Amazon S3 encrypts your data as it writes it to disks in its data centers +// and decrypts the data when you access it. You have the option to provide +// your own encryption key or use AWS-managed encryption keys. For more information, +// see Using Server-Side Encryption (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingServerSideEncryption.html). +// +// Access Permissions +// +// You can optionally specify the accounts or groups that should be granted +// specific permissions on the new object. There are two ways to grant the permissions +// using the request headers: +// +// * Specify a canned ACL with the x-amz-acl request header. For more information, +// see Canned ACL (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL). +// +// * Specify access permissions explicitly with the x-amz-grant-read, x-amz-grant-read-acp, +// x-amz-grant-write-acp, and x-amz-grant-full-control headers. These parameters +// map to the set of permissions that Amazon S3 supports in an ACL. For more +// information, see Access Control List (ACL) Overview (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html). +// +// You can use either a canned ACL or specify access permissions explicitly. +// You cannot do both. +// +// Server-Side- Encryption-Specific Request Headers +// +// You can optionally tell Amazon S3 to encrypt data at rest using server-side +// encryption. Server-side encryption is for data encryption at rest. Amazon +// S3 encrypts your data as it writes it to disks in its data centers and decrypts +// it when you access it. The option you use depends on whether you want to +// use AWS-managed encryption keys or provide your own encryption key. +// +// * Use encryption keys managed Amazon S3 or customer master keys (CMKs) +// stored in AWS Key Management Service (KMS) – If you want AWS to manage +// the keys used to encrypt data, specify the following headers in the request. +// x-amz-server-side​-encryption x-amz-server-side-encryption-aws-kms-key-id +// x-amz-server-side-encryption-context If you specify x-amz-server-side-encryption:aws:kms, +// but don't provide x-amz-server-side- encryption-aws-kms-key-id, Amazon +// S3 uses the AWS managed CMK in AWS KMS to protect the data. All GET and +// PUT requests for an object protected by AWS KMS fail if you don't make +// them with SSL or by using SigV4. For more information on Server-Side Encryption +// with CMKs stored in AWS KMS (SSE-KMS), see Protecting Data Using Server-Side +// Encryption with CMKs stored in AWS (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html). +// +// * Use customer-provided encryption keys – If you want to manage your +// own encryption keys, provide all the following headers in the request. +// x-amz-server-side​-encryption​-customer-algorithm x-amz-server-side​-encryption​-customer-key +// x-amz-server-side​-encryption​-customer-key-MD5 For more information +// on Server-Side Encryption with CMKs stored in KMS (SSE-KMS), see Protecting +// Data Using Server-Side Encryption with CMKs stored in AWS KMS (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html). +// +// Access-Control-List (ACL)-Specific Request Headers +// +// You also can use the following access control–related headers with this +// operation. By default, all objects are private. Only the owner has full access +// control. When adding a new object, you can grant permissions to individual +// AWS accounts or to predefined groups defined by Amazon S3. These permissions +// are then added to the Access Control List (ACL) on the object. For more information, +// see Using ACLs (https://docs.aws.amazon.com/AmazonS3/latest/dev/S3_ACLs_UsingACLs.html). +// With this operation, you can grant access permissions using one of the following +// two methods: +// +// * Specify a canned ACL (x-amz-acl) — Amazon S3 supports a set of predefined +// ACLs, known as canned ACLs. Each canned ACL has a predefined set of grantees +// and permissions. For more information, see Canned ACL (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#CannedACL). +// +// * Specify access permissions explicitly — To explicitly grant access +// permissions to specific AWS accounts or groups, use the following headers. +// Each header maps to specific permissions that Amazon S3 supports in an +// ACL. For more information, see Access Control List (ACL) Overview (https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html). +// In the header, you specify a list of grantees who get the specific permission. +// To grant permissions explicitly use: x-amz-grant-read x-amz-grant-write +// x-amz-grant-read-acp x-amz-grant-write-acp x-amz-grant-full-control You +// specify each grantee as a type=value pair, where the type is one of the +// following: emailAddress – if the value specified is the email address +// of an AWS account Using email addresses to specify a grantee is only supported +// in the following AWS Regions: US East (N. Virginia) US West (N. California) +// US West (Oregon) Asia Pacific (Singapore) Asia Pacific (Sydney) Asia Pacific +// (Tokyo) EU (Ireland) South America (São Paulo) For a list of all the +// Amazon S3 supported regions and endpoints, see Regions and Endpoints (https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region) +// in the AWS General Reference id – if the value specified is the canonical +// user ID of an AWS account uri – if you are granting permissions to a +// predefined group For example, the following x-amz-grant-read header grants +// the AWS accounts identified by email addresses permissions to read object +// data and its metadata: x-amz-grant-read: emailAddress="xyz@amazon.com", +// emailAddress="abc@amazon.com" +// +// Server-Side- Encryption-Specific Request Headers +// +// You can optionally tell Amazon S3 to encrypt data at rest using server-side +// encryption. Server-side encryption is for data encryption at rest. Amazon +// S3 encrypts your data as it writes it to disks in its data centers and decrypts +// it when you access it. The option you use depends on whether you want to +// use AWS-managed encryption keys or provide your own encryption key. +// +// * Use encryption keys managed by Amazon S3 or customer master keys (CMKs) +// stored in AWS Key Management Service (KMS) – If you want AWS to manage +// the keys used to encrypt data, specify the following headers in the request. +// x-amz-server-side​-encryption x-amz-server-side-encryption-aws-kms-key-id +// x-amz-server-side-encryption-context If you specify x-amz-server-side-encryption:aws:kms, +// but don't provide x-amz-server-side- encryption-aws-kms-key-id, Amazon +// S3 uses the default AWS KMS CMK to protect the data. All GET and PUT requests +// for an object protected by AWS KMS fail if you don't make them with SSL +// or by using SigV4. For more information on Server-Side Encryption with +// CMKs stored in AWS KMS (SSE-KMS), see Protecting Data Using Server-Side +// Encryption with CMKs stored in AWS KMS (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html). +// +// * Use customer-provided encryption keys – If you want to manage your +// own encryption keys, provide all the following headers in the request. +// If you use this feature, the ETag value that Amazon S3 returns in the +// response is not the MD5 of the object. x-amz-server-side​-encryption​-customer-algorithm +// x-amz-server-side​-encryption​-customer-key x-amz-server-side​-encryption​-customer-key-MD5 +// For more information on Server-Side Encryption with CMKs stored in AWS +// KMS (SSE-KMS), see Protecting Data Using Server-Side Encryption with CMKs +// stored in AWS KMS (https://docs.aws.amazon.com/AmazonS3/latest/dev/UsingKMSEncryption.html). +// +// Storage Class Options +// +// By default, Amazon S3 uses the Standard storage class to store newly created +// objects. The Standard storage class provides high durability and high availability. +// You can specify other storage classes depending on the performance needs. +// For more information, see Storage Classes (https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html) +// in the Amazon Simple Storage Service Developer Guide. +// +// Versioning +// +// If you enable versioning for a bucket, Amazon S3 automatically generates +// a unique version ID for the object being stored. Amazon S3 returns this ID +// in the response using the x-amz-version-id response header. If versioning +// is suspended, Amazon S3 always uses null as the version ID for the object +// stored. For more information about returning the versioning state of a bucket, +// see GetBucketVersioning. If you enable versioning for a bucket, when Amazon +// S3 receives multiple write requests for the same object simultaneously, it +// stores all of the objects. +// +// Related Resources +// +// * CopyObject +// +// * DeleteObject +// +// // Example sending a request using PutObjectRequest. +// req := client.ProtoPutObjectRequest(params) +// resp, err := req.Send(context.TODO()) +// if err == nil { +// fmt.Println(resp) +// } +// +// Please also see https://docs.aws.amazon.com/goto/WebAPI/s3-2006-03-01/PutObject +func (c *Client) ProtoPutObjectRequest(input *types.PutObjectInput) ProtoPutObjectRequest { + op := &aws.Operation{ + Name: protoOpPutObject, + HTTPMethod: "PUT", + HTTPPath: "/{Bucket}/{Key+}", + } + + if input == nil { + input = &types.PutObjectInput{} + } + + req := c.newRequest(op, input, &types.PutObjectOutput{}) + + // swap existing build handler on svc, with a new named build handler + req.Handlers.Build.Swap(restxml.BuildHandler.Name, + awsrestxml.ProtoPutObjectMarshaler{ + Input: input, + }.GetNamedBuildHandler(), + ) + + return ProtoPutObjectRequest{Request: req, Input: input, Copy: c.ProtoPutObjectRequest} +} + +// ProtoPutObjectRequest is the request type for the +// ProtoPutObject API operation. +type ProtoPutObjectRequest struct { + *aws.Request + Input *types.PutObjectInput + Copy func(*types.PutObjectInput) ProtoPutObjectRequest +} + +// Send marshals and sends the PutObject API request. +func (r ProtoPutObjectRequest) Send(ctx context.Context) (*ProtoPutObjectResponse, error) { + r.Request.SetContext(ctx) + err := r.Request.Send() + if err != nil { + return nil, err + } + + resp := &ProtoPutObjectResponse{ + PutObjectOutput: r.Request.Data.(*types.PutObjectOutput), + response: &aws.Response{Request: r.Request}, + } + + return resp, nil +} + +// ProtoPutObjectResponse is the response type for the +// ProtoPutObject API operation. +type ProtoPutObjectResponse struct { + *types.PutObjectOutput + + response *aws.Response +} + +// SDKResponseMetdata returns the response metadata for the +// PutObject request. +func (r *ProtoPutObjectResponse) SDKResponseMetdata() *aws.Response { + return r.response +} diff --git a/service/s3/proto_api_op_PutObject_test.go b/service/s3/proto_api_op_PutObject_test.go new file mode 100644 index 00000000000..3b417141a05 --- /dev/null +++ b/service/s3/proto_api_op_PutObject_test.go @@ -0,0 +1,76 @@ +package s3_test + +import ( + "context" + "testing" + "time" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awstesting/mock" + "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" + "github.com/google/go-cmp/cmp" +) + +func TestProtoPutObjectRequest_Diff(t *testing.T) { + svc := s3.New(mock.Config()) + + input := types.PutObjectInput{ + ACL: enums.ObjectCannedACLAuthenticatedRead, + Body: nil, + ContentLength: aws.Int64(0), + Bucket: aws.String("mock bucket"), + CacheControl: aws.String("mock cache control"), + ContentDisposition: aws.String("mock content disposition"), + ContentLanguage: aws.String("english"), + ContentMD5: aws.String("mock MD5"), + ContentType: aws.String("mock content type"), + Expires: aws.Time(time.Now()), + GrantFullControl: aws.String("mock full control"), + GrantRead: aws.String("mock read grant"), + GrantReadACP: aws.String("mock acp read"), + GrantWriteACP: aws.String("mock write acp"), + Key: aws.String("mock key"), + Metadata: map[string]string{ + "mockMetaKey01": "mockMetaValue01", + "mockMetaKey02": "mockMetaValue02", + "mockMetaKey03": "mockMetaValue03", + }, + ObjectLockLegalHoldStatus: enums.ObjectLockLegalHoldStatusOn, + ObjectLockMode: enums.ObjectLockModeCompliance, + ObjectLockRetainUntilDate: aws.Time(time.Now()), + RequestPayer: enums.RequestPayerRequester, + SSECustomerAlgorithm: aws.String("mock sse cust Algo"), + SSECustomerKey: nil, + SSECustomerKeyMD5: aws.String("mock sse MD5"), + SSEKMSEncryptionContext: aws.String("mock encryption content"), + SSEKMSKeyId: aws.String("mock ssekmskey id"), + ServerSideEncryption: enums.ServerSideEncryptionAes256, + StorageClass: enums.StorageClassGlacier, + Tagging: aws.String("mock tagging"), + WebsiteRedirectLocation: aws.String("mock redirection"), + } + + // request created for existing put object request + request := svc.PutObjectRequest(&input) + _, err := request.Send(context.TODO()) + if err != nil { + t.Error(err) + } + + // request created for prototyped put object request + prototypeRequest := svc.ProtoPutObjectRequest(&input) + _, err = prototypeRequest.Send(context.TODO()) + if err != nil { + t.Error(err) + } + + if diff := cmp.Diff(request.HTTPRequest.Header, prototypeRequest.HTTPRequest.Header); diff != "" { + t.Errorf("Found diff: %v", diff) + } + + if diff := cmp.Diff(request.HTTPRequest.URL, prototypeRequest.HTTPRequest.URL); diff != "" { + t.Errorf("Found diff: %v", diff) + } +} diff --git a/service/s3/s3crypto/decryption_client.go b/service/s3/s3crypto/decryption_client.go index 75bc67be8eb..c1e146494fb 100644 --- a/service/s3/s3crypto/decryption_client.go +++ b/service/s3/s3crypto/decryption_client.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/kms" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // WrapEntry is builder that return a proper key decrypter and error @@ -84,9 +85,9 @@ func NewDecryptionClient(cfg aws.Config, options ...func(*DecryptionClient)) *De // Bucket: aws.String("testBucket"), // }) // err := req.Send() -func (c *DecryptionClient) GetObjectRequest(input *s3.GetObjectInput) s3.GetObjectRequest { +func (c *DecryptionClient) GetObjectRequest(input *types.GetObjectInput) s3.GetObjectRequest { req := c.S3Client.GetObjectRequest(input) - out := req.Data.(*s3.GetObjectOutput) + out := req.Data.(*types.GetObjectOutput) req.Handlers.Unmarshal.PushBack(func(r *request.Request) { env, err := c.LoadStrategy.Load(r) @@ -117,7 +118,7 @@ func (c *DecryptionClient) GetObjectRequest(input *s3.GetObjectInput) s3.GetObje } // GetObject is a wrapper for GetObjectRequest -func (c *DecryptionClient) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOutput, error) { +func (c *DecryptionClient) GetObject(input *types.GetObjectInput) (*types.GetObjectOutput, error) { req := c.GetObjectRequest(input) resp, err := req.Send(context.Background()) if err != nil { @@ -133,7 +134,7 @@ func (c *DecryptionClient) GetObject(input *s3.GetObjectInput) (*s3.GetObjectOut // Context input parameters. The Context must not be nil. A nil Context will // cause a panic. Use the Context to add deadlining, timeouts, ect. In the future // this may create sub-contexts for individual underlying requests. -func (c *DecryptionClient) GetObjectWithContext(ctx context.Context, input *s3.GetObjectInput, opts ...request.Option) (*s3.GetObjectOutput, error) { +func (c *DecryptionClient) GetObjectWithContext(ctx context.Context, input *types.GetObjectInput, opts ...request.Option) (*types.GetObjectOutput, error) { req := c.GetObjectRequest(input) req.ApplyOptions(opts...) resp, err := req.Send(ctx) diff --git a/service/s3/s3crypto/decryption_client_test.go b/service/s3/s3crypto/decryption_client_test.go index 2b1f5fa0411..c365223c203 100644 --- a/service/s3/s3crypto/decryption_client_test.go +++ b/service/s3/s3crypto/decryption_client_test.go @@ -18,6 +18,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3crypto" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestGetObjectGCM(t *testing.T) { @@ -40,12 +41,12 @@ func TestGetObjectGCM(t *testing.T) { } c.S3Client.(*s3.Client).ForcePathStyle = true - input := &s3.GetObjectInput{ + input := &types.GetObjectInput{ Key: aws.String("test"), Bucket: aws.String("test"), } req := c.GetObjectRequest(input) - out := req.Data.(*s3.GetObjectOutput) + out := req.Data.(*types.GetObjectOutput) req.Handlers.Send.Clear() req.Handlers.Send.PushBack(func(r *aws.Request) { iv, err := hex.DecodeString("0d18e06c7c725ac9e362e1ce") @@ -111,12 +112,12 @@ func TestGetObjectCBC(t *testing.T) { } c.S3Client.(*s3.Client).ForcePathStyle = true - input := &s3.GetObjectInput{ + input := &types.GetObjectInput{ Key: aws.String("test"), Bucket: aws.String("test"), } req := c.GetObjectRequest(input) - out := req.Data.(*s3.GetObjectOutput) + out := req.Data.(*types.GetObjectOutput) req.Handlers.Send.Clear() req.Handlers.Send.PushBack(func(r *aws.Request) { iv, err := hex.DecodeString("9dea7621945988f96491083849b068df") @@ -180,12 +181,12 @@ func TestGetObjectCBC2(t *testing.T) { } c.S3Client.(*s3.Client).ForcePathStyle = true - input := &s3.GetObjectInput{ + input := &types.GetObjectInput{ Key: aws.String("test"), Bucket: aws.String("test"), } req := c.GetObjectRequest(input) - out := req.Data.(*s3.GetObjectOutput) + out := req.Data.(*types.GetObjectOutput) req.Handlers.Send.Clear() req.Handlers.Send.PushBack(func(r *aws.Request) { b, err := hex.DecodeString("fd0c71ecb7ed16a9bf42ea5f75501d416df608f190890c3b4d8897f24744cd7f9ea4a0b212e60634302450e1c5378f047ff753ccefe365d411c36339bf22e301fae4c3a6226719a4b93dc74c1af79d0296659b5d56c0892315f2c7cc30190220db1eaafae3920d6d9c65d0aa366499afc17af493454e141c6e0fbdeb6a990cb4") @@ -232,7 +233,7 @@ func TestGetObjectWithContext(t *testing.T) { ctx.Error = fmt.Errorf("context canceled") close(ctx.DoneCh) - input := s3.GetObjectInput{ + input := types.GetObjectInput{ Key: aws.String("test"), Bucket: aws.String("test"), } diff --git a/service/s3/s3crypto/encryption_client.go b/service/s3/s3crypto/encryption_client.go index 4581488e4df..c6339a90a21 100644 --- a/service/s3/s3crypto/encryption_client.go +++ b/service/s3/s3crypto/encryption_client.go @@ -9,6 +9,7 @@ import ( request "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // DefaultMinFileSize is used to check whether we want to write to a temp file @@ -68,7 +69,7 @@ func NewEncryptionClient(cfg aws.Config, builder ContentCipherBuilder, options . // Body: strings.NewReader("test data"), // }) // err := req.Send(context.Background()) -func (c *EncryptionClient) PutObjectRequest(input *s3.PutObjectInput) s3.PutObjectRequest { +func (c *EncryptionClient) PutObjectRequest(input *types.PutObjectInput) s3.PutObjectRequest { req := c.S3Client.PutObjectRequest(input) // Get Size of file @@ -126,7 +127,7 @@ func (c *EncryptionClient) PutObjectRequest(input *s3.PutObjectInput) s3.PutObje } // PutObject is a wrapper for PutObjectRequest -func (c *EncryptionClient) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOutput, error) { +func (c *EncryptionClient) PutObject(input *types.PutObjectInput) (*types.PutObjectOutput, error) { req := c.PutObjectRequest(input) resp, err := req.Send(context.Background()) if err != nil { @@ -142,7 +143,7 @@ func (c *EncryptionClient) PutObject(input *s3.PutObjectInput) (*s3.PutObjectOut // Context input parameters. The Context must not be nil. A nil Context will // cause a panic. Use the Context to add deadlining, timeouts, ect. In the future // this may create sub-contexts for individual underlying requests. -func (c *EncryptionClient) PutObjectWithContext(ctx context.Context, input *s3.PutObjectInput, opts ...request.Option) (*s3.PutObjectOutput, error) { +func (c *EncryptionClient) PutObjectWithContext(ctx context.Context, input *types.PutObjectInput, opts ...request.Option) (*types.PutObjectOutput, error) { req := c.PutObjectRequest(input) req.ApplyOptions(opts...) resp, err := req.Send(ctx) diff --git a/service/s3/s3crypto/encryption_client_test.go b/service/s3/s3crypto/encryption_client_test.go index c12d6154060..6cee5cf2a7c 100644 --- a/service/s3/s3crypto/encryption_client_test.go +++ b/service/s3/s3crypto/encryption_client_test.go @@ -17,6 +17,7 @@ import ( "github.com/aws/aws-sdk-go-v2/service/kms" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3crypto" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestDefaultConfigValues(t *testing.T) { @@ -58,7 +59,7 @@ func TestPutObject(t *testing.T) { } c.S3Client.(*s3.Client).ForcePathStyle = true - input := &s3.PutObjectInput{ + input := &types.PutObjectInput{ Key: aws.String("test"), Bucket: aws.String("test"), Body: bytes.NewReader(data), @@ -94,7 +95,7 @@ func TestPutObjectWithContext(t *testing.T) { ctx.Error = fmt.Errorf("context canceled") close(ctx.DoneCh) - input := s3.PutObjectInput{ + input := types.PutObjectInput{ Bucket: aws.String("test"), Key: aws.String("test"), Body: bytes.NewReader([]byte{}), diff --git a/service/s3/s3crypto/kms_key_handler.go b/service/s3/s3crypto/kms_key_handler.go index 8be65d35f17..e7d341a3cc5 100644 --- a/service/s3/s3crypto/kms_key_handler.go +++ b/service/s3/s3crypto/kms_key_handler.go @@ -4,8 +4,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws/awserr" - "github.com/aws/aws-sdk-go-v2/service/kms" + "github.com/aws/aws-sdk-go-v2/service/kms/enums" "github.com/aws/aws-sdk-go-v2/service/kms/kmsiface" + "github.com/aws/aws-sdk-go-v2/service/kms/types" ) const ( @@ -80,8 +81,8 @@ func (kp kmsKeyHandler) decryptHandler(env Envelope) (CipherDataDecrypter, error // DecryptKey makes a call to KMS to decrypt the key. func (kp *kmsKeyHandler) DecryptKey(key []byte) ([]byte, error) { - req := kp.kms.DecryptRequest(&kms.DecryptInput{ - EncryptionContext: map[string]string(kp.CipherData.MaterialDescription), + req := kp.kms.DecryptRequest(&types.DecryptInput{ + EncryptionContext: kp.CipherData.MaterialDescription, CiphertextBlob: key, GrantTokens: []string{}, }) @@ -95,10 +96,10 @@ func (kp *kmsKeyHandler) DecryptKey(key []byte) ([]byte, error) { // GenerateCipherData makes a call to KMS to generate a data key, Upon making // the call, it also sets the encrypted key. func (kp *kmsKeyHandler) GenerateCipherData(keySize, ivSize int) (CipherData, error) { - req := kp.kms.GenerateDataKeyRequest(&kms.GenerateDataKeyInput{ + req := kp.kms.GenerateDataKeyRequest(&types.GenerateDataKeyInput{ EncryptionContext: kp.CipherData.MaterialDescription, KeyId: &kp.cmkID, - KeySpec: kms.DataKeySpecAes256, + KeySpec: enums.DataKeySpecAes256, }) resp, err := req.Send(context.Background()) if err != nil { diff --git a/service/s3/s3crypto/strategy.go b/service/s3/s3crypto/strategy.go index 8076e18a47c..84bf3692ac5 100644 --- a/service/s3/s3crypto/strategy.go +++ b/service/s3/s3crypto/strategy.go @@ -11,6 +11,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // SaveStrategy is how the data's metadata wants to be saved @@ -26,13 +27,13 @@ type S3SaveStrategy struct { // Save will save the envelope contents to s3. func (strat S3SaveStrategy) Save(env Envelope, req *aws.Request) error { - input := req.Params.(*s3.PutObjectInput) + input := req.Params.(*types.PutObjectInput) b, err := json.Marshal(env) if err != nil { return err } - instInput := s3.PutObjectInput{ + instInput := types.PutObjectInput{ Bucket: input.Bucket, Body: bytes.NewReader(b), } @@ -53,7 +54,7 @@ type HeaderV2SaveStrategy struct{} // Save will save the envelope to the request's header. func (strat HeaderV2SaveStrategy) Save(env Envelope, req *aws.Request) error { - input := req.Params.(*s3.PutObjectInput) + input := req.Params.(*types.PutObjectInput) if input.Metadata == nil { input.Metadata = map[string]string{} } @@ -90,8 +91,8 @@ func (load S3LoadStrategy) Load(req *aws.Request) (Envelope, error) { load.InstructionFileSuffix = DefaultInstructionKeySuffix } - input := req.Params.(*s3.GetObjectInput) - out, err := load.Client.GetObjectRequest(&s3.GetObjectInput{ + input := req.Params.(*types.GetObjectInput) + out, err := load.Client.GetObjectRequest(&types.GetObjectInput{ Key: aws.String(strings.Join([]string{*input.Key, load.InstructionFileSuffix}, "")), Bucket: input.Bucket, }).Send(context.Background()) diff --git a/service/s3/s3crypto/strategy_test.go b/service/s3/s3crypto/strategy_test.go index 49fba0afef6..44cbeebd0a5 100644 --- a/service/s3/s3crypto/strategy_test.go +++ b/service/s3/s3crypto/strategy_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3crypto" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestHeaderV2SaveStrategy(t *testing.T) { @@ -59,7 +59,7 @@ func TestHeaderV2SaveStrategy(t *testing.T) { } for _, c := range cases { - params := &s3.PutObjectInput{} + params := &types.PutObjectInput{} req := &aws.Request{ Params: params, } diff --git a/service/s3/s3manager/batch.go b/service/s3/s3manager/batch.go index 5b5609d3be4..df6883025df 100644 --- a/service/s3/s3manager/batch.go +++ b/service/s3/s3manager/batch.go @@ -10,6 +10,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) const ( @@ -137,11 +138,11 @@ type BatchDeleteIterator interface { type DeleteListIterator struct { Bucket *string Paginator s3.ListObjectsPaginator - objects []s3.Object + objects []types.Object } // NewDeleteListIterator will return a new DeleteListIterator. -func NewDeleteListIterator(svc s3iface.ClientAPI, input *s3.ListObjectsInput, opts ...func(*DeleteListIterator)) BatchDeleteIterator { +func NewDeleteListIterator(svc s3iface.ClientAPI, input *types.ListObjectsInput, opts ...func(*DeleteListIterator)) BatchDeleteIterator { req := svc.ListObjectsRequest(input) iter := &DeleteListIterator{ Bucket: input.Bucket, @@ -175,7 +176,7 @@ func (iter *DeleteListIterator) Err() error { // DeleteObject will return the current object to be deleted. func (iter *DeleteListIterator) DeleteObject() BatchDeleteObject { return BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Bucket: iter.Bucket, Key: iter.objects[0].Key, }, @@ -249,7 +250,7 @@ func NewBatchDelete(cfg aws.Config, options ...func(*BatchDelete)) *BatchDelete // BatchDeleteObject is a wrapper object for calling the batch delete operation. type BatchDeleteObject struct { - Object *s3.DeleteObjectInput + Object *types.DeleteObjectInput // After will run after each iteration during the batch process. This function will // be executed whether or not the request was successful. After func() error @@ -290,8 +291,8 @@ func (iter *DeleteObjectsIterator) DeleteObject() BatchDeleteObject { // Once the batch size is met, this will call the deleteBatch function. func (d *BatchDelete) Delete(ctx context.Context, iter BatchDeleteIterator) error { var errs []Error - objects := []BatchDeleteObject{} - var input *s3.DeleteObjectsInput + var objects []BatchDeleteObject + var input *types.DeleteObjectsInput for iter.Next() { o := iter.DeleteObject() @@ -302,7 +303,7 @@ func (d *BatchDelete) Delete(ctx context.Context, iter BatchDeleteIterator) erro parity := hasParity(input, o) if parity { - input.Delete.Objects = append(input.Delete.Objects, s3.ObjectIdentifier{ + input.Delete.Objects = append(input.Delete.Objects, types.ObjectIdentifier{ Key: o.Object.Key, VersionId: o.Object.VersionId, }) @@ -320,7 +321,7 @@ func (d *BatchDelete) Delete(ctx context.Context, iter BatchDeleteIterator) erro if !parity { objects = append(objects, o) input = initDeleteObjectsInput(o.Object) - input.Delete.Objects = append(input.Delete.Objects, s3.ObjectIdentifier{ + input.Delete.Objects = append(input.Delete.Objects, types.ObjectIdentifier{ Key: o.Object.Key, VersionId: o.Object.VersionId, }) @@ -340,12 +341,12 @@ func (d *BatchDelete) Delete(ctx context.Context, iter BatchDeleteIterator) erro return nil } -func initDeleteObjectsInput(o *s3.DeleteObjectInput) *s3.DeleteObjectsInput { - return &s3.DeleteObjectsInput{ +func initDeleteObjectsInput(o *types.DeleteObjectInput) *types.DeleteObjectsInput { + return &types.DeleteObjectsInput{ Bucket: o.Bucket, MFA: o.MFA, RequestPayer: o.RequestPayer, - Delete: &s3.Delete{}, + Delete: &types.Delete{}, } } @@ -357,8 +358,8 @@ const ( ) // deleteBatch will delete a batch of items in the objects parameters. -func deleteBatch(ctx context.Context, d *BatchDelete, input *s3.DeleteObjectsInput, objects []BatchDeleteObject) []Error { - errs := []Error{} +func deleteBatch(ctx context.Context, d *BatchDelete, input *types.DeleteObjectsInput, objects []BatchDeleteObject) []Error { + var errs []Error req := d.Client.DeleteObjectsRequest(input) if result, err := req.Send(ctx); err != nil { for i := 0; i < len(input.Delete.Objects); i++ { @@ -390,7 +391,7 @@ func deleteBatch(ctx context.Context, d *BatchDelete, input *s3.DeleteObjectsInp return errs } -func hasParity(o1 *s3.DeleteObjectsInput, o2 BatchDeleteObject) bool { +func hasParity(o1 *types.DeleteObjectsInput, o2 BatchDeleteObject) bool { if o1.Bucket != nil && o2.Object.Bucket != nil { if *o1.Bucket != *o2.Object.Bucket { return false @@ -424,7 +425,7 @@ type BatchDownloadIterator interface { // BatchDownloadObject contains all necessary information to run a batch operation once. type BatchDownloadObject struct { - Object *s3.GetObjectInput + Object *types.GetObjectInput Writer io.WriterAt // After will run after each iteration during the batch process. This function will // be executed whether or not the request was successful. diff --git a/service/s3/s3manager/batch_test.go b/service/s3/s3manager/batch_test.go index 3d0f4d0bc50..a577fb9bca7 100644 --- a/service/s3/s3manager/batch_test.go +++ b/service/s3/s3manager/batch_test.go @@ -4,6 +4,7 @@ import ( "bytes" "context" "errors" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" "io/ioutil" "net/http" "net/http/httptest" @@ -15,105 +16,106 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestHasParity(t *testing.T) { cases := []struct { - o1 *s3.DeleteObjectsInput + o1 *types.DeleteObjectsInput o2 BatchDeleteObject expected bool }{ { - &s3.DeleteObjectsInput{}, + &types.DeleteObjectsInput{}, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{}, + Object: &types.DeleteObjectInput{}, }, true, }, { - &s3.DeleteObjectsInput{ + &types.DeleteObjectsInput{ Bucket: aws.String("foo"), }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Bucket: aws.String("bar"), }, }, false, }, { - &s3.DeleteObjectsInput{}, + &types.DeleteObjectsInput{}, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Bucket: aws.String("foo"), }, }, false, }, { - &s3.DeleteObjectsInput{ + &types.DeleteObjectsInput{ Bucket: aws.String("foo"), }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{}, + Object: &types.DeleteObjectInput{}, }, false, }, { - &s3.DeleteObjectsInput{ + &types.DeleteObjectsInput{ MFA: aws.String("foo"), }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ MFA: aws.String("bar"), }, }, false, }, { - &s3.DeleteObjectsInput{}, + &types.DeleteObjectsInput{}, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ MFA: aws.String("foo"), }, }, false, }, { - &s3.DeleteObjectsInput{ + &types.DeleteObjectsInput{ MFA: aws.String("foo"), }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{}, + Object: &types.DeleteObjectInput{}, }, false, }, { - &s3.DeleteObjectsInput{ - RequestPayer: s3.RequestPayer("foo"), + &types.DeleteObjectsInput{ + RequestPayer: enums.RequestPayer("foo"), }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ - RequestPayer: s3.RequestPayerRequester, + Object: &types.DeleteObjectInput{ + RequestPayer: enums.RequestPayerRequester, }, }, false, }, { - &s3.DeleteObjectsInput{}, + &types.DeleteObjectsInput{}, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ - RequestPayer: s3.RequestPayerRequester, + Object: &types.DeleteObjectInput{ + RequestPayer: enums.RequestPayerRequester, }, }, false, }, { - &s3.DeleteObjectsInput{ - RequestPayer: s3.RequestPayerRequester, + &types.DeleteObjectsInput{ + RequestPayer: enums.RequestPayerRequester, }, BatchDeleteObject{ - Object: &s3.DeleteObjectInput{}, + Object: &types.DeleteObjectInput{}, }, false, }, @@ -135,25 +137,25 @@ func TestBatchDelete(t *testing.T) { { // 0 []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket2"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket3"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket4"), }, @@ -165,25 +167,25 @@ func TestBatchDelete(t *testing.T) { { // 1 []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket3"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket3"), }, @@ -195,25 +197,25 @@ func TestBatchDelete(t *testing.T) { { // 2 []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket3"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket3"), }, @@ -225,25 +227,25 @@ func TestBatchDelete(t *testing.T) { { // 3 []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket3"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket3"), }, @@ -255,25 +257,25 @@ func TestBatchDelete(t *testing.T) { { // 4 []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket1"), }, }, { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket3"), }, @@ -312,12 +314,12 @@ func TestBatchDelete(t *testing.T) { type mockS3Client struct { *s3.Client index int - objects []s3.ListObjectsOutput + objects []types.ListObjectsOutput } -func (client *mockS3Client) ListObjectsRequest(input *s3.ListObjectsInput) s3.ListObjectsRequest { +func (client *mockS3Client) ListObjectsRequest(input *types.ListObjectsInput) s3.ListObjectsRequest { req := client.Client.ListObjectsRequest(input) - req.Copy = func(v *s3.ListObjectsInput) s3.ListObjectsRequest { + req.Copy = func(v *types.ListObjectsInput) s3.ListObjectsRequest { r := client.Client.ListObjectsRequest(v) r.Handlers.Send.PushBack(func(r *aws.Request) { object := client.objects[client.index] @@ -338,9 +340,9 @@ func TestBatchDeleteList(t *testing.T) { count++ })) - objects := []s3.ListObjectsOutput{ + objects := []types.ListObjectsOutput{ { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("1"), }, @@ -349,7 +351,7 @@ func TestBatchDeleteList(t *testing.T) { IsTruncated: aws.Bool(true), }, { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("2"), }, @@ -358,7 +360,7 @@ func TestBatchDeleteList(t *testing.T) { IsTruncated: aws.Bool(true), }, { - Contents: []s3.Object{ + Contents: []types.Object{ { Key: aws.String("3"), }, @@ -374,7 +376,7 @@ func TestBatchDeleteList(t *testing.T) { BatchSize: 1, } - input := &s3.ListObjectsInput{ + input := &types.ListObjectsInput{ Bucket: aws.String("bucket"), } @@ -414,16 +416,16 @@ func TestBatchDeleteList_EmptyListObjects(t *testing.T) { svc := &mockS3Client{ Client: buildS3SvcClient(server.URL), - objects: []s3.ListObjectsOutput{ + objects: []types.ListObjectsOutput{ // Simulate empty listing - {Contents: []s3.Object{}}, + {Contents: []types.Object{}}, }, } batcher := BatchDelete{ Client: svc, } - input := &s3.ListObjectsInput{ + input := &types.ListObjectsInput{ Bucket: aws.String("bucket"), } @@ -470,9 +472,9 @@ func TestBatchDownload(t *testing.T) { }, } - received := []struct { + var received []struct { bucket, key string - }{} + } payload := []string{ "1", @@ -492,28 +494,28 @@ func TestBatchDownload(t *testing.T) { objects := []BatchDownloadObject{ { - Object: &s3.GetObjectInput{ + Object: &types.GetObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, Writer: aws.NewWriteAtBuffer(make([]byte, 128)), }, { - Object: &s3.GetObjectInput{ + Object: &types.GetObjectInput{ Key: aws.String("2"), Bucket: aws.String("bucket2"), }, Writer: aws.NewWriteAtBuffer(make([]byte, 128)), }, { - Object: &s3.GetObjectInput{ + Object: &types.GetObjectInput{ Key: aws.String("3"), Bucket: aws.String("bucket3"), }, Writer: aws.NewWriteAtBuffer(make([]byte, 128)), }, { - Object: &s3.GetObjectInput{ + Object: &types.GetObjectInput{ Key: aws.String("4"), Bucket: aws.String("bucket4"), }, @@ -582,9 +584,9 @@ func TestBatchUpload(t *testing.T) { }, } - received := []struct { + var received []struct { bucket, key, reqBody string - }{} + } payload := []string{ "a", @@ -670,10 +672,10 @@ func TestBatchUpload(t *testing.T) { type mockClient struct { s3iface.ClientAPI - Put func() (*s3.PutObjectOutput, error) - Get func() (*s3.GetObjectOutput, error) - List func() (*s3.ListObjectsOutput, error) - Deletes func() (*s3.DeleteObjectsOutput, error) + Put func() (*types.PutObjectOutput, error) + Get func() (*types.GetObjectOutput, error) + List func() (*types.ListObjectsOutput, error) + Deletes func() (*types.DeleteObjectsOutput, error) responses []response } @@ -682,7 +684,7 @@ type response struct { err error } -func (client *mockClient) DeleteObjectsRequest(input *s3.DeleteObjectsInput) s3.DeleteObjectsRequest { +func (client *mockClient) DeleteObjectsRequest(input *types.DeleteObjectsInput) s3.DeleteObjectsRequest { if client.Deletes == nil { return client.ClientAPI.DeleteObjectsRequest(input) } @@ -693,14 +695,14 @@ func (client *mockClient) DeleteObjectsRequest(input *s3.DeleteObjectsInput) s3. return req } -func (client *mockClient) PutObjectRequest(input *s3.PutObjectInput) s3.PutObjectRequest { +func (client *mockClient) PutObjectRequest(input *types.PutObjectInput) s3.PutObjectRequest { req := client.ClientAPI.PutObjectRequest(input) req.Handlers.Clear() req.Data, req.Error = client.Put() return req } -func (client *mockClient) ListObjectsRequest(input *s3.ListObjectsInput) s3.ListObjectsRequest { +func (client *mockClient) ListObjectsRequest(input *types.ListObjectsInput) s3.ListObjectsRequest { req := client.ClientAPI.ListObjectsRequest(input) req.Handlers.Clear() req.Data, req.Error = client.List() @@ -714,34 +716,34 @@ func TestBatchError(t *testing.T) { index := 0 responses := []response{ { - &s3.PutObjectOutput{}, + &types.PutObjectOutput{}, errors.New("Foo"), }, { - &s3.PutObjectOutput{}, + &types.PutObjectOutput{}, nil, }, { - &s3.PutObjectOutput{}, + &types.PutObjectOutput{}, nil, }, { - &s3.PutObjectOutput{}, + &types.PutObjectOutput{}, errors.New("Bar"), }, } svc := &mockClient{ ClientAPI: buildS3SvcClient(server.URL), - Put: func() (*s3.PutObjectOutput, error) { + Put: func() (*types.PutObjectOutput, error) { resp := responses[index] index++ - return resp.out.(*s3.PutObjectOutput), resp.err + return resp.out.(*types.PutObjectOutput), resp.err }, - List: func() (*s3.ListObjectsOutput, error) { + List: func() (*types.ListObjectsOutput, error) { resp := responses[index] index++ - return resp.out.(*s3.ListObjectsOutput), resp.err + return resp.out.(*types.ListObjectsOutput), resp.err }, } uploader := NewUploaderWithClient(svc) @@ -837,7 +839,7 @@ func (iter *testAfterDeleteIter) Err() error { func (iter *testAfterDeleteIter) DeleteObject() BatchDeleteObject { return BatchDeleteObject{ - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Bucket: aws.String("foo"), Key: aws.String("foo"), }, @@ -866,7 +868,7 @@ func (iter *testAfterDownloadIter) Err() error { func (iter *testAfterDownloadIter) DownloadObject() BatchDownloadObject { return BatchDownloadObject{ - Object: &s3.GetObjectInput{ + Object: &types.GetObjectInput{ Bucket: aws.String("foo"), Key: aws.String("foo"), }, @@ -914,35 +916,35 @@ func TestAfter(t *testing.T) { index := 0 responses := []response{ { - &s3.PutObjectOutput{}, + &types.PutObjectOutput{}, nil, }, { - &s3.GetObjectOutput{}, + &types.GetObjectOutput{}, nil, }, { - &s3.DeleteObjectOutput{}, + &types.DeleteObjectOutput{}, nil, }, } svc := &mockClient{ ClientAPI: buildS3SvcClient(server.URL), - Put: func() (*s3.PutObjectOutput, error) { + Put: func() (*types.PutObjectOutput, error) { resp := responses[index] index++ - return resp.out.(*s3.PutObjectOutput), resp.err + return resp.out.(*types.PutObjectOutput), resp.err }, - Get: func() (*s3.GetObjectOutput, error) { + Get: func() (*types.GetObjectOutput, error) { resp := responses[index] index++ - return resp.out.(*s3.GetObjectOutput), resp.err + return resp.out.(*types.GetObjectOutput), resp.err }, - List: func() (*s3.ListObjectsOutput, error) { + List: func() (*types.ListObjectsOutput, error) { resp := responses[index] index++ - return resp.out.(*s3.ListObjectsOutput), resp.err + return resp.out.(*types.ListObjectsOutput), resp.err }, } uploader := NewUploaderWithClient(svc) @@ -981,7 +983,7 @@ func TestAfter(t *testing.T) { func TestBatchDeleteError(t *testing.T) { cases := []struct { objects []BatchDeleteObject - output s3.DeleteObjectsOutput + output types.DeleteObjectsOutput size int expectedErrCode string expectedErrMessage string @@ -989,14 +991,14 @@ func TestBatchDeleteError(t *testing.T) { { []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, }, - s3.DeleteObjectsOutput{ - Errors: []s3.Error{ + types.DeleteObjectsOutput{ + Errors: []types.Error{ { Code: aws.String("foo code"), Message: aws.String("foo error"), @@ -1010,14 +1012,14 @@ func TestBatchDeleteError(t *testing.T) { { []BatchDeleteObject{ { - Object: &s3.DeleteObjectInput{ + Object: &types.DeleteObjectInput{ Key: aws.String("1"), Bucket: aws.String("bucket1"), }, }, }, - s3.DeleteObjectsOutput{ - Errors: []s3.Error{ + types.DeleteObjectsOutput{ + Errors: []types.Error{ {}, }, }, @@ -1034,7 +1036,7 @@ func TestBatchDeleteError(t *testing.T) { index := 0 svc := &mockClient{ ClientAPI: buildS3SvcClient(server.URL), - Deletes: func() (*s3.DeleteObjectsOutput, error) { + Deletes: func() (*types.DeleteObjectsOutput, error) { resp := cases[index].output index++ return &resp, nil diff --git a/service/s3/s3manager/bucket_region.go b/service/s3/s3manager/bucket_region.go index 5cf2e153b82..f7b58386e95 100644 --- a/service/s3/s3manager/bucket_region.go +++ b/service/s3/s3manager/bucket_region.go @@ -5,7 +5,9 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // GetBucketRegion will attempt to get the region for a bucket using the @@ -49,7 +51,7 @@ const bucketRegionHeader = "X-Amz-Bucket-Region" // // See GetBucketRegion for more information. func GetBucketRegionWithClient(ctx context.Context, svc s3iface.ClientAPI, bucket string, opts ...aws.Option) (string, error) { - req := svc.HeadBucketRequest(&s3.HeadBucketInput{ + req := svc.HeadBucketRequest(&types.HeadBucketInput{ Bucket: aws.String(bucket), }) @@ -70,7 +72,7 @@ func GetBucketRegionWithClient(ctx context.Context, svc s3iface.ClientAPI, bucke return "", err } - bucketRegion = string(s3.NormalizeBucketLocation(s3.BucketLocationConstraint(bucketRegion))) + bucketRegion = string(s3.NormalizeBucketLocation(enums.BucketLocationConstraint(bucketRegion))) return bucketRegion, nil } diff --git a/service/s3/s3manager/cust_integ_shared_test.go b/service/s3/s3manager/cust_integ_shared_test.go index 45c0d9dfdaa..0ef95baa9f2 100644 --- a/service/s3/s3manager/cust_integ_shared_test.go +++ b/service/s3/s3manager/cust_integ_shared_test.go @@ -15,6 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration/s3integ" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func init() { @@ -75,7 +76,7 @@ func (d dlwriter) WriteAt(p []byte, pos int64) (n int, err error) { func validate(t *testing.T, key string, md5value string) { mgr := s3manager.NewDownloader(integCfg) - params := &s3.GetObjectInput{Bucket: bucketName, Key: &key} + params := &types.GetObjectInput{Bucket: bucketName, Key: &key} w := newDLWriter(1024 * 1024 * 20) n, err := mgr.Download(w, params) diff --git a/service/s3/s3manager/cust_integ_upload_test.go b/service/s3/s3manager/cust_integ_upload_test.go index e16ade8ab22..685d7323db7 100644 --- a/service/s3/s3manager/cust_integ_upload_test.go +++ b/service/s3/s3manager/cust_integ_upload_test.go @@ -13,8 +13,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" - "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var integBuf12MB = make([]byte, 1024*1024*12) @@ -80,7 +80,7 @@ func TestInteg_UploadFailCleanup(t *testing.T) { t.Errorf("expect upload ID to not be empty, but was") } - _, err = svc.ListPartsRequest(&s3.ListPartsInput{ + _, err = svc.ListPartsRequest(&types.ListPartsInput{ Bucket: bucketName, Key: &key, UploadId: &uploadID, }).Send(context.Background()) if err == nil { diff --git a/service/s3/s3manager/download.go b/service/s3/s3manager/download.go index 749fb086a82..7eeb6b9b870 100644 --- a/service/s3/s3manager/download.go +++ b/service/s3/s3manager/download.go @@ -15,6 +15,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // DefaultDownloadPartSize is the default range of bytes to get at a time when @@ -166,7 +167,7 @@ func NewDownloaderWithClient(svc s3iface.ClientAPI, options ...func(*Downloader) // If the GetObjectInput's Range value is provided that will cause the downloader // to perform a single GetObjectInput request for that object's range. This will // caused the part size, and concurrency configurations to be ignored. -func (d Downloader) Download(w io.WriterAt, input *s3.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { +func (d Downloader) Download(w io.WriterAt, input *types.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { return d.DownloadWithContext(context.Background(), w, input, options...) } @@ -196,7 +197,7 @@ func (d Downloader) Download(w io.WriterAt, input *s3.GetObjectInput, options .. // If the GetObjectInput's Range value is provided that will cause the downloader // to perform a single GetObjectInput request for that object's range. This will // caused the part size, and concurrency configurations to be ignored. -func (d Downloader) DownloadWithContext(ctx context.Context, w io.WriterAt, input *s3.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { +func (d Downloader) DownloadWithContext(ctx context.Context, w io.WriterAt, input *types.GetObjectInput, options ...func(*Downloader)) (n int64, err error) { impl := downloader{w: w, in: input, cfg: d, ctx: ctx} for _, option := range options { @@ -245,7 +246,7 @@ func (d Downloader) DownloadWithContext(ctx context.Context, w io.WriterAt, inpu // Writer: fooFile, // }, // { -// Input: &s3.GetObjectInput { +// Input: &types.GetObjectInput { // Bucket: aws.String("bucket"), // Key: aws.String("bar"), // }, @@ -285,7 +286,7 @@ type downloader struct { ctx context.Context cfg Downloader - in *s3.GetObjectInput + in *types.GetObjectInput w io.WriterAt wg sync.WaitGroup @@ -417,7 +418,7 @@ func (d *downloader) downloadRange(rng string) { // downloadChunk downloads the chunk from s3 func (d *downloader) downloadChunk(chunk dlchunk) error { - in := &s3.GetObjectInput{} + in := &types.GetObjectInput{} awsutil.Copy(in, d.in) // Get the next byte range of data @@ -452,7 +453,7 @@ func (d *downloader) downloadChunk(chunk dlchunk) error { return err } -func (d *downloader) tryDownloadChunk(in *s3.GetObjectInput, w io.Writer) (int64, error) { +func (d *downloader) tryDownloadChunk(in *types.GetObjectInput, w io.Writer) (int64, error) { cleanup := func() {} if d.cfg.BufferProvider != nil { w, cleanup = d.cfg.BufferProvider.GetReadFrom(w) @@ -504,7 +505,7 @@ func (d *downloader) getTotalBytes() int64 { // will be chunked, or Content-Length. Content-Length is used when the response // does not include a Content-Range. Meaning the object was not chunked. This // occurs when the full file fits within the PartSize directive. -func (d *downloader) setTotalBytes(resp *s3.GetObjectOutput) { +func (d *downloader) setTotalBytes(resp *types.GetObjectOutput) { d.m.Lock() defer d.m.Unlock() diff --git a/service/s3/s3manager/download_test.go b/service/s3/s3manager/download_test.go index e29be063e90..622b3ec661e 100644 --- a/service/s3/s3manager/download_test.go +++ b/service/s3/s3manager/download_test.go @@ -22,12 +22,13 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/sdkio" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func dlLoggingSvc(data []byte) (*s3.Client, *[]string, *[]string) { var m sync.Mutex - names := []string{} - ranges := []string{} + var names []string + var ranges []string svc := s3.New(unit.Config()) svc.Handlers.Send.Clear() @@ -36,7 +37,7 @@ func dlLoggingSvc(data []byte) (*s3.Client, *[]string, *[]string) { defer m.Unlock() names = append(names, r.Operation.Name) - ranges = append(ranges, *r.Params.(*s3.GetObjectInput).Range) + ranges = append(ranges, *r.Params.(*types.GetObjectInput).Range) rerng := regexp.MustCompile(`bytes=(\d+)-(\d+)`) rng := rerng.FindStringSubmatch(r.HTTPRequest.Header.Get("Range")) @@ -64,7 +65,7 @@ func dlLoggingSvc(data []byte) (*s3.Client, *[]string, *[]string) { func dlLoggingSvcNoChunk(data []byte) (*s3.Client, *[]string) { var m sync.Mutex - names := []string{} + var names []string svc := s3.New(unit.Config()) svc.Handlers.Send.Clear() @@ -122,7 +123,7 @@ func dlLoggingSvcContentRangeTotalAny(data []byte, states []int) (*s3.Client, *[ defer m.Unlock() names = append(names, r.Operation.Name) - ranges = append(ranges, *r.Params.(*s3.GetObjectInput).Range) + ranges = append(ranges, *r.Params.(*types.GetObjectInput).Range) rerng := regexp.MustCompile(`bytes=(\d+)-(\d+)`) rng := rerng.FindStringSubmatch(r.HTTPRequest.Header.Get("Range")) @@ -203,7 +204,7 @@ func TestDownloadOrder(t *testing.T) { d.Concurrency = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -239,7 +240,7 @@ func TestDownloadZero(t *testing.T) { d := s3manager.NewDownloaderWithClient(s) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -269,7 +270,7 @@ func TestDownloadSetPartSize(t *testing.T) { d.PartSize = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -311,7 +312,7 @@ func TestDownloadError(t *testing.T) { d.PartSize = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -343,7 +344,7 @@ func TestDownloadNonChunk(t *testing.T) { d.Concurrency = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -375,7 +376,7 @@ func TestDownloadNoContentRangeLength(t *testing.T) { d.Concurrency = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -407,7 +408,7 @@ func TestDownloadContentRangeTotalAny(t *testing.T) { d.Concurrency = 1 }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -443,7 +444,7 @@ func TestDownloadPartBodyRetry_SuccessRetry(t *testing.T) { }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -473,7 +474,7 @@ func TestDownloadPartBodyRetry_SuccessNoRetry(t *testing.T) { }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -503,7 +504,7 @@ func TestDownloadPartBodyRetry_FailRetry(t *testing.T) { }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -529,7 +530,7 @@ func TestDownloadPartBodyRetry_FailRetry(t *testing.T) { func TestDownloadWithContextCanceled(t *testing.T) { d := s3manager.NewDownloader(unit.Config()) - params := s3.GetObjectInput{ + params := types.GetObjectInput{ Bucket: aws.String("Bucket"), Key: aws.String("Key"), } @@ -562,7 +563,7 @@ func TestDownload_WithRange(t *testing.T) { }) w := &aws.WriteAtBuffer{} - n, err := d.Download(w, &s3.GetObjectInput{ + n, err := d.Download(w, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), Range: aws.String("bytes=2-6"), @@ -627,7 +628,7 @@ func TestDownload_WithFailure(t *testing.T) { }) w := &aws.WriteAtBuffer{} - params := s3.GetObjectInput{ + params := types.GetObjectInput{ Bucket: aws.String("Bucket"), Key: aws.String("Key"), } @@ -687,7 +688,7 @@ func TestDownloadBufferStrategy(t *testing.T) { buffer := aws.NewWriteAtBuffer(make([]byte, len(expected))) - n, err := d.Download(buffer, &s3.GetObjectInput{ + n, err := d.Download(buffer, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) @@ -756,7 +757,7 @@ func TestDownloadBufferStrategy_Errors(t *testing.T) { return true } - input := r.Params.(*s3.GetObjectInput) + input := r.Params.(*types.GetObjectInput) fingerPrint := fmt.Sprintf("%s/%s/%s/%s", r.Operation.Name, *input.Bucket, *input.Key, *input.Range) if _, ok := seenOps[fingerPrint]; ok { @@ -781,7 +782,7 @@ func TestDownloadBufferStrategy_Errors(t *testing.T) { buffer := aws.NewWriteAtBuffer(make([]byte, len(expected))) - n, err := d.Download(buffer, &s3.GetObjectInput{ + n, err := d.Download(buffer, &types.GetObjectInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), }) diff --git a/service/s3/s3manager/s3manageriface/interface.go b/service/s3/s3manager/s3manageriface/interface.go index 482148ae191..e0eb1a08d05 100644 --- a/service/s3/s3manager/s3manageriface/interface.go +++ b/service/s3/s3manager/s3manageriface/interface.go @@ -5,14 +5,14 @@ import ( "context" "io" - "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // DownloaderAPI is the interface type for s3manager.Downloader. type DownloaderAPI interface { - Download(io.WriterAt, *s3.GetObjectInput, ...func(*s3manager.Downloader)) (int64, error) - DownloadWithContext(context.Context, io.WriterAt, *s3.GetObjectInput, ...func(*s3manager.Downloader)) (int64, error) + Download(io.WriterAt, *types.GetObjectInput, ...func(*s3manager.Downloader)) (int64, error) + DownloadWithContext(context.Context, io.WriterAt, *types.GetObjectInput, ...func(*s3manager.Downloader)) (int64, error) DownloadWithIterator(context.Context, s3manager.BatchDownloadIterator, ...func(*s3manager.Downloader)) error } diff --git a/service/s3/s3manager/upload.go b/service/s3/s3manager/upload.go index 1b5c4b7c11c..a2d6c2257fc 100644 --- a/service/s3/s3manager/upload.go +++ b/service/s3/s3manager/upload.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/service/s3" "github.com/aws/aws-sdk-go-v2/service/s3/s3iface" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) // MaxUploadParts is the maximum allowed number of parts in a multi-part upload @@ -502,7 +503,7 @@ func readFillBuf(r io.Reader, b []byte) (offset int, err error) { func (u *uploader) singlePart(buf io.ReadSeeker, cleanup func()) (*UploadOutput, error) { defer cleanup() - params := &s3.PutObjectInput{} + params := &types.PutObjectInput{} awsutil.Copy(params, u.in) params.Body = buf @@ -541,7 +542,7 @@ type chunk struct { // completedParts is a wrapper to make parts sortable by their part number, // since S3 required this list to be sent in sorted order. -type completedParts []s3.CompletedPart +type completedParts []types.CompletedPart func (a completedParts) Len() int { return len(a) } func (a completedParts) Swap(i, j int) { a[i], a[j] = a[j], a[i] } @@ -550,7 +551,7 @@ func (a completedParts) Less(i, j int) bool { return *a[i].PartNumber < *a[j].Pa // upload will perform a multipart upload using the firstBuf buffer containing // the first chunk of data. func (u *multiuploader) upload(firstBuf io.ReadSeeker, cleanup func()) (*UploadOutput, error) { - params := &s3.CreateMultipartUploadInput{} + params := &types.CreateMultipartUploadInput{} awsutil.Copy(params, u.in) // Create the multipart @@ -614,7 +615,7 @@ func (u *multiuploader) upload(firstBuf io.ReadSeeker, cleanup func()) (*UploadO // Create a presigned URL of the S3 Get Object in order to have parity with // single part upload. - getReq := u.cfg.S3.GetObjectRequest(&s3.GetObjectInput{ + getReq := u.cfg.S3.GetObjectRequest(&types.GetObjectInput{ Bucket: u.in.Bucket, Key: u.in.Key, }) @@ -679,7 +680,7 @@ func (u *multiuploader) readChunk(ch chan chunk) { // send performs an UploadPart request and keeps track of the completed // part information. func (u *multiuploader) send(c chunk) error { - params := &s3.UploadPartInput{ + params := &types.UploadPartInput{ Bucket: u.in.Bucket, Key: u.in.Key, Body: c.buf, @@ -697,7 +698,7 @@ func (u *multiuploader) send(c chunk) error { } n := c.num - completed := s3.CompletedPart{ETag: resp.ETag, PartNumber: &n} + completed := types.CompletedPart{ETag: resp.ETag, PartNumber: &n} u.m.Lock() u.parts = append(u.parts, completed) @@ -728,7 +729,7 @@ func (u *multiuploader) fail() { return } - params := &s3.AbortMultipartUploadInput{ + params := &types.AbortMultipartUploadInput{ Bucket: u.in.Bucket, Key: u.in.Key, UploadId: &u.uploadID, @@ -741,7 +742,7 @@ func (u *multiuploader) fail() { } // complete successfully completes a multipart upload and returns the response. -func (u *multiuploader) complete() *s3.CompleteMultipartUploadOutput { +func (u *multiuploader) complete() *types.CompleteMultipartUploadOutput { if u.geterr() != nil { u.fail() return nil @@ -750,11 +751,11 @@ func (u *multiuploader) complete() *s3.CompleteMultipartUploadOutput { // Parts must be sorted in PartNumber order. sort.Sort(u.parts) - params := &s3.CompleteMultipartUploadInput{ + params := &types.CompleteMultipartUploadInput{ Bucket: u.in.Bucket, Key: u.in.Key, UploadId: &u.uploadID, - MultipartUpload: &s3.CompletedMultipartUpload{Parts: u.parts}, + MultipartUpload: &types.CompletedMultipartUpload{Parts: u.parts}, } req := u.cfg.S3.CompleteMultipartUploadRequest(params) req.ApplyOptions(u.cfg.RequestOptions...) diff --git a/service/s3/s3manager/upload_test.go b/service/s3/s3manager/upload_test.go index 43a79276e08..e79088818df 100644 --- a/service/s3/s3manager/upload_test.go +++ b/service/s3/s3manager/upload_test.go @@ -21,7 +21,9 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" "github.com/aws/aws-sdk-go-v2/service/s3/s3manager" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) var emptyList []string @@ -54,8 +56,8 @@ func contains(src []string, s string) bool { func loggingSvc(ignoreOps []string) (*s3.Client, *[]string, *[]interface{}) { var m sync.Mutex partNum := 0 - names := []string{} - params := []interface{}{} + var names []string + var params []interface{} svc := s3.New(unit.Config()) svc.Handlers.Unmarshal.Clear() svc.Handlers.UnmarshalMeta.Clear() @@ -76,15 +78,15 @@ func loggingSvc(ignoreOps []string) (*s3.Client, *[]string, *[]interface{}) { } switch data := r.Data.(type) { - case *s3.CreateMultipartUploadOutput: + case *types.CreateMultipartUploadOutput: data.UploadId = aws.String("UPLOAD-ID") - case *s3.UploadPartOutput: + case *types.UploadPartOutput: partNum++ data.ETag = aws.String(fmt.Sprintf("ETAG%d", partNum)) - case *s3.CompleteMultipartUploadOutput: + case *types.CompleteMultipartUploadOutput: data.Location = aws.String("https://location") data.VersionId = aws.String("VERSION-ID") - case *s3.PutObjectOutput: + case *types.PutObjectOutput: data.VersionId = aws.String("VERSION-ID") } }) @@ -106,7 +108,7 @@ func TestUploadOrderMulti(t *testing.T) { Bucket: aws.String("Bucket"), Key: aws.String("Key - value"), Body: bytes.NewReader(buf12MB), - ServerSideEncryption: s3.ServerSideEncryptionAwsKms, + ServerSideEncryption: enums.ServerSideEncryptionAwsKms, SSEKMSKeyId: aws.String("KmsId"), ContentType: aws.String("content/type"), }) @@ -169,7 +171,7 @@ func TestUploadOrderMulti(t *testing.T) { // Custom headers e := val((*args)[0], "ServerSideEncryption") - if e.(s3.ServerSideEncryption) != s3.ServerSideEncryptionAwsKms { + if e.(enums.ServerSideEncryption) != enums.ServerSideEncryptionAwsKms { t.Errorf("Expected %q, but received %q", "aws:kms", e) } @@ -313,7 +315,7 @@ func TestUploadOrderSingle(t *testing.T) { Bucket: aws.String("Bucket"), Key: aws.String("Key - value"), Body: bytes.NewReader(buf2MB), - ServerSideEncryption: s3.ServerSideEncryptionAwsKms, + ServerSideEncryption: enums.ServerSideEncryptionAwsKms, SSEKMSKeyId: aws.String("KmsId"), ContentType: aws.String("content/type"), }) @@ -338,7 +340,7 @@ func TestUploadOrderSingle(t *testing.T) { t.Errorf("Expected empty string, but received %q", resp.UploadID) } - if e, a := s3.ServerSideEncryptionAwsKms, val((*args)[0], "ServerSideEncryption").(s3.ServerSideEncryption); e != a { + if e, a := enums.ServerSideEncryptionAwsKms, val((*args)[0], "ServerSideEncryption").(enums.ServerSideEncryption); e != a { t.Errorf("Expected %q, but received %q", e, a) } @@ -410,7 +412,7 @@ func TestUploadOrderMultiFailure(t *testing.T) { s, ops, _ := loggingSvc(emptyList) s.Handlers.Send.PushBack(func(r *aws.Request) { switch t := r.Data.(type) { - case *s3.UploadPartOutput: + case *types.UploadPartOutput: if *t.ETag == "ETAG2" { r.HTTPResponse.StatusCode = 400 } @@ -439,7 +441,7 @@ func TestUploadOrderMultiFailureOnComplete(t *testing.T) { s, ops, _ := loggingSvc(emptyList) s.Handlers.Send.PushBack(func(r *aws.Request) { switch r.Data.(type) { - case *s3.CompleteMultipartUploadOutput: + case *types.CompleteMultipartUploadOutput: r.HTTPResponse.StatusCode = 400 } }) @@ -467,7 +469,7 @@ func TestUploadOrderMultiFailureOnCreate(t *testing.T) { s, ops, _ := loggingSvc(emptyList) s.Handlers.Send.PushBack(func(r *aws.Request) { switch r.Data.(type) { - case *s3.CreateMultipartUploadOutput: + case *types.CreateMultipartUploadOutput: r.HTTPResponse.StatusCode = 400 } }) @@ -492,7 +494,7 @@ func TestUploadOrderMultiFailureLeaveParts(t *testing.T) { s, ops, _ := loggingSvc(emptyList) s.Handlers.Send.PushBack(func(r *aws.Request) { switch data := r.Data.(type) { - case *s3.UploadPartOutput: + case *types.UploadPartOutput: if *data.ETag == "ETAG2" { r.HTTPResponse.StatusCode = 400 } @@ -533,6 +535,7 @@ func (f *failreader) Read(b []byte) (int, error) { func TestUploadOrderReadFail1(t *testing.T) { s, ops, _ := loggingSvc(emptyList) + mgr := s3manager.NewUploaderWithClient(s) _, err := mgr.Upload(&s3manager.UploadInput{ Bucket: aws.String("Bucket"), @@ -548,7 +551,7 @@ func TestUploadOrderReadFail1(t *testing.T) { t.Errorf("Expected %q, but received %q", e, a) } - if e, a := []string{}, *ops; !reflect.DeepEqual(e, a) { + if e, a := []string(nil), *ops; !reflect.DeepEqual(e, a) { t.Errorf("Expected %v, but received %v", e, a) } } @@ -794,10 +797,10 @@ func TestUploadZeroLenObject(t *testing.T) { } func TestUploadInputS3PutObjectInputPairity(t *testing.T) { - matchings := compareStructType(reflect.TypeOf(s3.PutObjectInput{}), + matchings := compareStructType(reflect.TypeOf(types.PutObjectInput{}), reflect.TypeOf(s3manager.UploadInput{})) - aOnly := []string{} - bOnly := []string{} + var aOnly []string + var bOnly []string for k, c := range matchings { if strings.HasPrefix(k, "Body-") || strings.HasPrefix(k, "ContentLength-") { @@ -971,10 +974,10 @@ func TestSSE(t *testing.T) { Body: ioutil.NopCloser(bytes.NewReader([]byte{})), } switch data := r.Data.(type) { - case *s3.CreateMultipartUploadOutput: + case *types.CreateMultipartUploadOutput: data.UploadId = aws.String("UPLOAD-ID") - case *s3.UploadPartOutput: - input := r.Params.(*s3.UploadPartInput) + case *types.UploadPartOutput: + input := r.Params.(*types.UploadPartInput) if input.SSECustomerAlgorithm == nil { t.Fatal("SSECustomerAlgoritm should not be nil") } @@ -983,10 +986,10 @@ func TestSSE(t *testing.T) { } partNum++ data.ETag = aws.String(fmt.Sprintf("ETAG%d", partNum)) - case *s3.CompleteMultipartUploadOutput: + case *types.CompleteMultipartUploadOutput: data.Location = aws.String("https://location") data.VersionId = aws.String("VERSION-ID") - case *s3.PutObjectOutput: + case *types.PutObjectOutput: data.VersionId = aws.String("VERSION-ID") } @@ -1118,14 +1121,14 @@ func TestUploadBufferStrategy(t *testing.T) { } switch data := r.Data.(type) { - case *s3.CreateMultipartUploadOutput: + case *types.CreateMultipartUploadOutput: data.UploadId = aws.String("UPLOAD-ID") - case *s3.UploadPartOutput: + case *types.UploadPartOutput: data.ETag = aws.String(fmt.Sprintf("ETAG%d", atomic.AddInt64(&etag, 1))) - case *s3.CompleteMultipartUploadOutput: + case *types.CompleteMultipartUploadOutput: data.Location = aws.String("https://location") data.VersionId = aws.String("VERSION-ID") - case *s3.PutObjectOutput: + case *types.PutObjectOutput: data.VersionId = aws.String("VERSION-ID") } }) diff --git a/service/s3/sse.go b/service/s3/sse.go index 5ce2a5b4fd2..44ef288e83b 100644 --- a/service/s3/sse.go +++ b/service/s3/sse.go @@ -16,14 +16,14 @@ func validateSSERequiresSSL(r *request.Request) { } if iface, ok := r.Params.(sseCustomerKeyGetter); ok { - if len(iface.getSSECustomerKey()) > 0 { + if len(iface.GetSSECustomerKey()) > 0 { r.Error = errSSERequiresSSL return } } if iface, ok := r.Params.(copySourceSSECustomerKeyGetter); ok { - if len(iface.getCopySourceSSECustomerKey()) > 0 { + if len(iface.GetCopySourceSSECustomerKey()) > 0 { r.Error = errSSERequiresSSL return } diff --git a/service/s3/sse_test.go b/service/s3/sse_test.go index ee68d3665ff..b94d9133699 100644 --- a/service/s3/sse_test.go +++ b/service/s3/sse_test.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) func TestSSECustomerKeyOverHTTPError(t *testing.T) { @@ -19,7 +20,7 @@ func TestSSECustomerKeyOverHTTPError(t *testing.T) { cfg.EndpointResolver = resolver s := s3.New(cfg) - req := s.CopyObjectRequest(&s3.CopyObjectInput{ + req := s.CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucket"), CopySource: aws.String("bucket/source"), Key: aws.String("dest"), @@ -28,10 +29,10 @@ func TestSSECustomerKeyOverHTTPError(t *testing.T) { err := req.Build() if err == nil { - t.Error("expected an error") + t.Fatal("expected an error") } if e, a := "ConfigError", err.(awserr.Error).Code(); e != a { - t.Errorf("expected %s, but received %s", e, a) + t.Fatalf("expected %s, but received %s", e, a) } if !strings.Contains(err.(awserr.Error).Message(), "cannot send SSE keys over HTTP") { t.Errorf("expected error to contain 'cannot send SSE keys over HTTP', but received %s", err.(awserr.Error).Message()) @@ -46,7 +47,7 @@ func TestCopySourceSSECustomerKeyOverHTTPError(t *testing.T) { cfg.EndpointResolver = resolver s := s3.New(cfg) - req := s.CopyObjectRequest(&s3.CopyObjectInput{ + req := s.CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucket"), CopySource: aws.String("bucket/source"), Key: aws.String("dest"), @@ -67,7 +68,7 @@ func TestCopySourceSSECustomerKeyOverHTTPError(t *testing.T) { func TestComputeSSEKeys(t *testing.T) { s := s3.New(unit.Config()) - req := s.CopyObjectRequest(&s3.CopyObjectInput{ + req := s.CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucket"), CopySource: aws.String("bucket/source"), Key: aws.String("dest"), @@ -95,7 +96,7 @@ func TestComputeSSEKeys(t *testing.T) { func TestComputeSSEKeysShortcircuit(t *testing.T) { s := s3.New(unit.Config()) - req := s.CopyObjectRequest(&s3.CopyObjectInput{ + req := s.CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucket"), CopySource: aws.String("bucket/source"), Key: aws.String("dest"), diff --git a/service/s3/statusok_error_test.go b/service/s3/statusok_error_test.go index 34916837a1c..d72def00a32 100644 --- a/service/s3/statusok_error_test.go +++ b/service/s3/statusok_error_test.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) const errMsg = `ErrorCodemessage bodyrequestIDhostID=` @@ -23,7 +24,7 @@ func TestCopyObjectNoError(t *testing.T) { 2009-11-23T0:00:00Z"1da64c7f13d1e8dbeaea40b905fd586c"` - req := newCopyTestSvc(successMsg).CopyObjectRequest(&s3.CopyObjectInput{ + req := newCopyTestSvc(successMsg).CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucketname"), CopySource: aws.String("bucketname/exists.txt"), Key: aws.String("destination.txt"), @@ -42,7 +43,7 @@ func TestCopyObjectNoError(t *testing.T) { } func TestCopyObjectError(t *testing.T) { - req := newCopyTestSvc(errMsg).CopyObjectRequest(&s3.CopyObjectInput{ + req := newCopyTestSvc(errMsg).CopyObjectRequest(&types.CopyObjectInput{ Bucket: aws.String("bucketname"), CopySource: aws.String("bucketname/doesnotexist.txt"), Key: aws.String("destination.txt"), @@ -67,7 +68,7 @@ func TestUploadPartCopySuccess(t *testing.T) { 2009-11-23T0:00:00Z"1da64c7f13d1e8dbeaea40b905fd586c"` - req := newCopyTestSvc(successMsg).UploadPartCopyRequest(&s3.UploadPartCopyInput{ + req := newCopyTestSvc(successMsg).UploadPartCopyRequest(&types.UploadPartCopyInput{ Bucket: aws.String("bucketname"), CopySource: aws.String("bucketname/doesnotexist.txt"), Key: aws.String("destination.txt"), @@ -89,7 +90,7 @@ func TestUploadPartCopySuccess(t *testing.T) { } func TestUploadPartCopyError(t *testing.T) { - req := newCopyTestSvc(errMsg).UploadPartCopyRequest(&s3.UploadPartCopyInput{ + req := newCopyTestSvc(errMsg).UploadPartCopyRequest(&types.UploadPartCopyInput{ Bucket: aws.String("bucketname"), CopySource: aws.String("bucketname/doesnotexist.txt"), Key: aws.String("destination.txt"), @@ -115,7 +116,7 @@ func TestCompleteMultipartUploadSuccess(t *testing.T) { const successMsg = ` locationNamebucketNamekeyName"etagVal"` - req := newCopyTestSvc(successMsg).CompleteMultipartUploadRequest(&s3.CompleteMultipartUploadInput{ + req := newCopyTestSvc(successMsg).CompleteMultipartUploadRequest(&types.CompleteMultipartUploadInput{ Bucket: aws.String("bucketname"), Key: aws.String("key"), UploadId: aws.String("uploadID"), @@ -141,7 +142,7 @@ func TestCompleteMultipartUploadSuccess(t *testing.T) { } func TestCompleteMultipartUploadError(t *testing.T) { - req := newCopyTestSvc(errMsg).CompleteMultipartUploadRequest(&s3.CompleteMultipartUploadInput{ + req := newCopyTestSvc(errMsg).CompleteMultipartUploadRequest(&types.CompleteMultipartUploadInput{ Bucket: aws.String("bucketname"), Key: aws.String("key"), UploadId: aws.String("uploadID"), diff --git a/service/s3/unmarshal_error_test.go b/service/s3/unmarshal_error_test.go index d3b4b3bebd2..918361df321 100644 --- a/service/s3/unmarshal_error_test.go +++ b/service/s3/unmarshal_error_test.go @@ -14,6 +14,8 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/s3" + "github.com/aws/aws-sdk-go-v2/service/s3/enums" + "github.com/aws/aws-sdk-go-v2/service/s3/types" ) type testErrorCase struct { @@ -153,8 +155,8 @@ func TestUnmarshalError(t *testing.T) { http.StatusText(r.HTTPResponse.StatusCode)) } }) - req := s.PutBucketAclRequest(&s3.PutBucketAclInput{ - Bucket: aws.String("bucket"), ACL: s3.BucketCannedACLPublicRead, + req := s.PutBucketAclRequest(&types.PutBucketAclInput{ + Bucket: aws.String("bucket"), ACL: enums.BucketCannedACLPublicRead, }) _, err := req.Send(context.Background()) @@ -199,10 +201,10 @@ func Test200NoErrorUnmarshalError(t *testing.T) { } r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode) }) - req := s.CompleteMultipartUploadRequest(&s3.CompleteMultipartUploadInput{ + req := s.CompleteMultipartUploadRequest(&types.CompleteMultipartUploadInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), UploadId: aws.String("id"), - MultipartUpload: &s3.CompletedMultipartUpload{Parts: []s3.CompletedPart{ + MultipartUpload: &types.CompletedMultipartUpload{Parts: []types.CompletedPart{ {ETag: aws.String("etag"), PartNumber: aws.Int64(1)}, }}, }) @@ -230,10 +232,10 @@ func Test200WithErrorUnmarshalError(t *testing.T) { } r.HTTPResponse.Status = http.StatusText(r.HTTPResponse.StatusCode) }) - req := s.CompleteMultipartUploadRequest(&s3.CompleteMultipartUploadInput{ + req := s.CompleteMultipartUploadRequest(&types.CompleteMultipartUploadInput{ Bucket: aws.String("bucket"), Key: aws.String("key"), UploadId: aws.String("id"), - MultipartUpload: &s3.CompletedMultipartUpload{Parts: []s3.CompletedPart{ + MultipartUpload: &types.CompletedMultipartUpload{Parts: []types.CompletedPart{ {ETag: aws.String("etag"), PartNumber: aws.Int64(1)}, }}, }) diff --git a/service/s3control/cust_integ_public_lockdown_test.go b/service/s3control/cust_integ_public_lockdown_test.go index 4b74dabebac..2ef5915de2e 100644 --- a/service/s3control/cust_integ_public_lockdown_test.go +++ b/service/s3control/cust_integ_public_lockdown_test.go @@ -9,10 +9,11 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/service/s3control" + "github.com/aws/aws-sdk-go-v2/service/s3control/types" ) func TestInteg_PublicAccessBlock(t *testing.T) { - _, err := svc.GetPublicAccessBlockRequest(&s3control.GetPublicAccessBlockInput{ + _, err := svc.GetPublicAccessBlockRequest(&types.GetPublicAccessBlockInput{ AccountId: aws.String(accountID), }).Send(context.Background()) if err != nil { @@ -26,9 +27,9 @@ func TestInteg_PublicAccessBlock(t *testing.T) { } } - _, err = svc.PutPublicAccessBlockRequest(&s3control.PutPublicAccessBlockInput{ + _, err = svc.PutPublicAccessBlockRequest(&types.PutPublicAccessBlockInput{ AccountId: aws.String(accountID), - PublicAccessBlockConfiguration: &s3control.PublicAccessBlockConfiguration{ + PublicAccessBlockConfiguration: &types.PublicAccessBlockConfiguration{ IgnorePublicAcls: aws.Bool(true), }, }).Send(context.Background()) @@ -36,7 +37,7 @@ func TestInteg_PublicAccessBlock(t *testing.T) { t.Fatalf("expect no error, got %v", err) } - _, err = svc.DeletePublicAccessBlockRequest(&s3control.DeletePublicAccessBlockInput{ + _, err = svc.DeletePublicAccessBlockRequest(&types.DeletePublicAccessBlockInput{ AccountId: aws.String(accountID), }).Send(context.Background()) if err != nil { diff --git a/service/s3control/cust_integ_shared_test.go b/service/s3control/cust_integ_shared_test.go index ec0277db0e2..be022740b2b 100644 --- a/service/s3control/cust_integ_shared_test.go +++ b/service/s3control/cust_integ_shared_test.go @@ -16,6 +16,7 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/service/s3control" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/aws-sdk-go-v2/service/sts/types" ) var ( @@ -73,7 +74,7 @@ func setup() { } stsSvc := sts.New(stsCfg) - identity, err := stsSvc.GetCallerIdentityRequest(&sts.GetCallerIdentityInput{}).Send(context.Background()) + identity, err := stsSvc.GetCallerIdentityRequest(&types.GetCallerIdentityInput{}).Send(context.Background()) if err != nil { panic(fmt.Sprintf("failed to get accountID, %v", err)) } diff --git a/service/simpledb/unmarshall_error_test.go b/service/simpledb/unmarshall_error_test.go index afacaa155ab..a5519310b1a 100644 --- a/service/simpledb/unmarshall_error_test.go +++ b/service/simpledb/unmarshall_error_test.go @@ -12,6 +12,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/awserr" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/simpledb" + "github.com/aws/aws-sdk-go-v2/service/simpledb/types" ) var statusCodeErrorTests = []struct { @@ -40,7 +41,7 @@ func TestStatusCodeError(t *testing.T) { Body: body, } }) - req := s.CreateDomainRequest(&simpledb.CreateDomainInput{ + req := s.CreateDomainRequest(&types.CreateDomainInput{ DomainName: aws.String("test-domain"), }) _, err := req.Send(context.Background()) @@ -113,7 +114,7 @@ func TestResponseError(t *testing.T) { Body: body, } }) - req := s.CreateDomainRequest(&simpledb.CreateDomainInput{ + req := s.CreateDomainRequest(&types.CreateDomainInput{ DomainName: aws.String("test-domain"), }) _, err := req.Send(context.Background()) diff --git a/service/sqs/api_integ_test.go b/service/sqs/api_integ_test.go index 686a0723a41..66ef8f906c1 100644 --- a/service/sqs/api_integ_test.go +++ b/service/sqs/api_integ_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/internal/awstesting/integration" "github.com/aws/aws-sdk-go-v2/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var _ aws.Config @@ -25,7 +26,7 @@ func TestInteg_00_ListQueues(t *testing.T) { cfg := integration.ConfigWithDefaultRegion("us-west-2") svc := sqs.New(cfg) - params := &sqs.ListQueuesInput{} + params := &types.ListQueuesInput{} req := svc.ListQueuesRequest(params) req.Handlers.Validate.Remove(defaults.ValidateParametersHandler) @@ -40,7 +41,7 @@ func TestInteg_01_GetQueueUrl(t *testing.T) { cfg := integration.ConfigWithDefaultRegion("us-west-2") svc := sqs.New(cfg) - params := &sqs.GetQueueUrlInput{ + params := &types.GetQueueUrlInput{ QueueName: aws.String("fake_queue"), } diff --git a/service/sqs/api_op_AddPermission.go b/service/sqs/api_op_AddPermission.go index a139f6d4145..0a9fdc3bb5f 100644 --- a/service/sqs/api_op_AddPermission.go +++ b/service/sqs/api_op_AddPermission.go @@ -6,92 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type AddPermissionInput struct { - _ struct{} `type:"structure"` - - // The AWS account number of the principal (https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#P) - // who is given permission. The principal must have an AWS account, but does - // not need to be signed up for Amazon SQS. For information about locating the - // AWS account identification, see Your AWS Identifiers (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-making-api-requests.html#sqs-api-request-authentication) - // in the Amazon Simple Queue Service Developer Guide. - // - // AWSAccountIds is a required field - AWSAccountIds []string `locationNameList:"AWSAccountId" type:"list" flattened:"true" required:"true"` - - // The action the client wants to allow for the specified principal. Valid values: - // the name of any action or *. - // - // For more information about these actions, see Overview of Managing Access - // Permissions to Your Amazon Simple Queue Service Resource (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-overview-of-managing-access.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // Specifying SendMessage, DeleteMessage, or ChangeMessageVisibility for ActionName.n - // also grants permissions for the corresponding batch versions of those actions: - // SendMessageBatch, DeleteMessageBatch, and ChangeMessageVisibilityBatch. - // - // Actions is a required field - Actions []string `locationNameList:"ActionName" type:"list" flattened:"true" required:"true"` - - // The unique identification of the permission you're setting (for example, - // AliceSendMessage). Maximum 80 characters. Allowed characters include alphanumeric - // characters, hyphens (-), and underscores (_). - // - // Label is a required field - Label *string `type:"string" required:"true"` - - // The URL of the Amazon SQS queue to which permissions are added. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s AddPermissionInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *AddPermissionInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "AddPermissionInput"} - - if s.AWSAccountIds == nil { - invalidParams.Add(aws.NewErrParamRequired("AWSAccountIds")) - } - - if s.Actions == nil { - invalidParams.Add(aws.NewErrParamRequired("Actions")) - } - - if s.Label == nil { - invalidParams.Add(aws.NewErrParamRequired("Label")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type AddPermissionOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s AddPermissionOutput) String() string { - return awsutil.Prettify(s) -} - const opAddPermission = "AddPermission" // AddPermissionRequest returns a request value for making API operation for @@ -137,7 +56,7 @@ const opAddPermission = "AddPermission" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/AddPermission -func (c *Client) AddPermissionRequest(input *AddPermissionInput) AddPermissionRequest { +func (c *Client) AddPermissionRequest(input *types.AddPermissionInput) AddPermissionRequest { op := &aws.Operation{ Name: opAddPermission, HTTPMethod: "POST", @@ -145,10 +64,10 @@ func (c *Client) AddPermissionRequest(input *AddPermissionInput) AddPermissionRe } if input == nil { - input = &AddPermissionInput{} + input = &types.AddPermissionInput{} } - req := c.newRequest(op, input, &AddPermissionOutput{}) + req := c.newRequest(op, input, &types.AddPermissionOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return AddPermissionRequest{Request: req, Input: input, Copy: c.AddPermissionRequest} @@ -158,8 +77,8 @@ func (c *Client) AddPermissionRequest(input *AddPermissionInput) AddPermissionRe // AddPermission API operation. type AddPermissionRequest struct { *aws.Request - Input *AddPermissionInput - Copy func(*AddPermissionInput) AddPermissionRequest + Input *types.AddPermissionInput + Copy func(*types.AddPermissionInput) AddPermissionRequest } // Send marshals and sends the AddPermission API request. @@ -171,7 +90,7 @@ func (r AddPermissionRequest) Send(ctx context.Context) (*AddPermissionResponse, } resp := &AddPermissionResponse{ - AddPermissionOutput: r.Request.Data.(*AddPermissionOutput), + AddPermissionOutput: r.Request.Data.(*types.AddPermissionOutput), response: &aws.Response{Request: r.Request}, } @@ -181,7 +100,7 @@ func (r AddPermissionRequest) Send(ctx context.Context) (*AddPermissionResponse, // AddPermissionResponse is the response type for the // AddPermission API operation. type AddPermissionResponse struct { - *AddPermissionOutput + *types.AddPermissionOutput response *aws.Response } diff --git a/service/sqs/api_op_ChangeMessageVisibility.go b/service/sqs/api_op_ChangeMessageVisibility.go index 42ccec28081..c88da1470aa 100644 --- a/service/sqs/api_op_ChangeMessageVisibility.go +++ b/service/sqs/api_op_ChangeMessageVisibility.go @@ -6,70 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ChangeMessageVisibilityInput struct { - _ struct{} `type:"structure"` - - // The URL of the Amazon SQS queue whose message's visibility is changed. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` - - // The receipt handle associated with the message whose visibility timeout is - // changed. This parameter is returned by the ReceiveMessage action. - // - // ReceiptHandle is a required field - ReceiptHandle *string `type:"string" required:"true"` - - // The new value for the message's visibility timeout (in seconds). Values values: - // 0 to 43200. Maximum: 12 hours. - // - // VisibilityTimeout is a required field - VisibilityTimeout *int64 `type:"integer" required:"true"` -} - -// String returns the string representation -func (s ChangeMessageVisibilityInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *ChangeMessageVisibilityInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "ChangeMessageVisibilityInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if s.ReceiptHandle == nil { - invalidParams.Add(aws.NewErrParamRequired("ReceiptHandle")) - } - - if s.VisibilityTimeout == nil { - invalidParams.Add(aws.NewErrParamRequired("VisibilityTimeout")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type ChangeMessageVisibilityOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s ChangeMessageVisibilityOutput) String() string { - return awsutil.Prettify(s) -} - const opChangeMessageVisibility = "ChangeMessageVisibility" // ChangeMessageVisibilityRequest returns a request value for making API operation for @@ -136,7 +77,7 @@ const opChangeMessageVisibility = "ChangeMessageVisibility" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ChangeMessageVisibility -func (c *Client) ChangeMessageVisibilityRequest(input *ChangeMessageVisibilityInput) ChangeMessageVisibilityRequest { +func (c *Client) ChangeMessageVisibilityRequest(input *types.ChangeMessageVisibilityInput) ChangeMessageVisibilityRequest { op := &aws.Operation{ Name: opChangeMessageVisibility, HTTPMethod: "POST", @@ -144,10 +85,10 @@ func (c *Client) ChangeMessageVisibilityRequest(input *ChangeMessageVisibilityIn } if input == nil { - input = &ChangeMessageVisibilityInput{} + input = &types.ChangeMessageVisibilityInput{} } - req := c.newRequest(op, input, &ChangeMessageVisibilityOutput{}) + req := c.newRequest(op, input, &types.ChangeMessageVisibilityOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return ChangeMessageVisibilityRequest{Request: req, Input: input, Copy: c.ChangeMessageVisibilityRequest} @@ -157,8 +98,8 @@ func (c *Client) ChangeMessageVisibilityRequest(input *ChangeMessageVisibilityIn // ChangeMessageVisibility API operation. type ChangeMessageVisibilityRequest struct { *aws.Request - Input *ChangeMessageVisibilityInput - Copy func(*ChangeMessageVisibilityInput) ChangeMessageVisibilityRequest + Input *types.ChangeMessageVisibilityInput + Copy func(*types.ChangeMessageVisibilityInput) ChangeMessageVisibilityRequest } // Send marshals and sends the ChangeMessageVisibility API request. @@ -170,7 +111,7 @@ func (r ChangeMessageVisibilityRequest) Send(ctx context.Context) (*ChangeMessag } resp := &ChangeMessageVisibilityResponse{ - ChangeMessageVisibilityOutput: r.Request.Data.(*ChangeMessageVisibilityOutput), + ChangeMessageVisibilityOutput: r.Request.Data.(*types.ChangeMessageVisibilityOutput), response: &aws.Response{Request: r.Request}, } @@ -180,7 +121,7 @@ func (r ChangeMessageVisibilityRequest) Send(ctx context.Context) (*ChangeMessag // ChangeMessageVisibilityResponse is the response type for the // ChangeMessageVisibility API operation. type ChangeMessageVisibilityResponse struct { - *ChangeMessageVisibilityOutput + *types.ChangeMessageVisibilityOutput response *aws.Response } diff --git a/service/sqs/api_op_ChangeMessageVisibilityBatch.go b/service/sqs/api_op_ChangeMessageVisibilityBatch.go index 97047ebf072..c4ca4838dbf 100644 --- a/service/sqs/api_op_ChangeMessageVisibilityBatch.go +++ b/service/sqs/api_op_ChangeMessageVisibilityBatch.go @@ -4,81 +4,11 @@ package sqs import ( "context" - "fmt" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ChangeMessageVisibilityBatchInput struct { - _ struct{} `type:"structure"` - - // A list of receipt handles of the messages for which the visibility timeout - // must be changed. - // - // Entries is a required field - Entries []ChangeMessageVisibilityBatchRequestEntry `locationNameList:"ChangeMessageVisibilityBatchRequestEntry" type:"list" flattened:"true" required:"true"` - - // The URL of the Amazon SQS queue whose messages' visibility is changed. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s ChangeMessageVisibilityBatchInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *ChangeMessageVisibilityBatchInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "ChangeMessageVisibilityBatchInput"} - - if s.Entries == nil { - invalidParams.Add(aws.NewErrParamRequired("Entries")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - if s.Entries != nil { - for i, v := range s.Entries { - if err := v.Validate(); err != nil { - invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) - } - } - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// For each message in the batch, the response contains a ChangeMessageVisibilityBatchResultEntry -// tag if the message succeeds or a BatchResultErrorEntry tag if the message -// fails. -type ChangeMessageVisibilityBatchOutput struct { - _ struct{} `type:"structure"` - - // A list of BatchResultErrorEntry items. - // - // Failed is a required field - Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` - - // A list of ChangeMessageVisibilityBatchResultEntry items. - // - // Successful is a required field - Successful []ChangeMessageVisibilityBatchResultEntry `locationNameList:"ChangeMessageVisibilityBatchResultEntry" type:"list" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s ChangeMessageVisibilityBatchOutput) String() string { - return awsutil.Prettify(s) -} - const opChangeMessageVisibilityBatch = "ChangeMessageVisibilityBatch" // ChangeMessageVisibilityBatchRequest returns a request value for making API operation for @@ -109,7 +39,7 @@ const opChangeMessageVisibilityBatch = "ChangeMessageVisibilityBatch" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ChangeMessageVisibilityBatch -func (c *Client) ChangeMessageVisibilityBatchRequest(input *ChangeMessageVisibilityBatchInput) ChangeMessageVisibilityBatchRequest { +func (c *Client) ChangeMessageVisibilityBatchRequest(input *types.ChangeMessageVisibilityBatchInput) ChangeMessageVisibilityBatchRequest { op := &aws.Operation{ Name: opChangeMessageVisibilityBatch, HTTPMethod: "POST", @@ -117,10 +47,10 @@ func (c *Client) ChangeMessageVisibilityBatchRequest(input *ChangeMessageVisibil } if input == nil { - input = &ChangeMessageVisibilityBatchInput{} + input = &types.ChangeMessageVisibilityBatchInput{} } - req := c.newRequest(op, input, &ChangeMessageVisibilityBatchOutput{}) + req := c.newRequest(op, input, &types.ChangeMessageVisibilityBatchOutput{}) return ChangeMessageVisibilityBatchRequest{Request: req, Input: input, Copy: c.ChangeMessageVisibilityBatchRequest} } @@ -128,8 +58,8 @@ func (c *Client) ChangeMessageVisibilityBatchRequest(input *ChangeMessageVisibil // ChangeMessageVisibilityBatch API operation. type ChangeMessageVisibilityBatchRequest struct { *aws.Request - Input *ChangeMessageVisibilityBatchInput - Copy func(*ChangeMessageVisibilityBatchInput) ChangeMessageVisibilityBatchRequest + Input *types.ChangeMessageVisibilityBatchInput + Copy func(*types.ChangeMessageVisibilityBatchInput) ChangeMessageVisibilityBatchRequest } // Send marshals and sends the ChangeMessageVisibilityBatch API request. @@ -141,7 +71,7 @@ func (r ChangeMessageVisibilityBatchRequest) Send(ctx context.Context) (*ChangeM } resp := &ChangeMessageVisibilityBatchResponse{ - ChangeMessageVisibilityBatchOutput: r.Request.Data.(*ChangeMessageVisibilityBatchOutput), + ChangeMessageVisibilityBatchOutput: r.Request.Data.(*types.ChangeMessageVisibilityBatchOutput), response: &aws.Response{Request: r.Request}, } @@ -151,7 +81,7 @@ func (r ChangeMessageVisibilityBatchRequest) Send(ctx context.Context) (*ChangeM // ChangeMessageVisibilityBatchResponse is the response type for the // ChangeMessageVisibilityBatch API operation. type ChangeMessageVisibilityBatchResponse struct { - *ChangeMessageVisibilityBatchOutput + *types.ChangeMessageVisibilityBatchOutput response *aws.Response } diff --git a/service/sqs/api_op_CreateQueue.go b/service/sqs/api_op_CreateQueue.go index aff9b0034e3..bc96a6acf7d 100644 --- a/service/sqs/api_op_CreateQueue.go +++ b/service/sqs/api_op_CreateQueue.go @@ -6,179 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type CreateQueueInput struct { - _ struct{} `type:"structure"` - - // A map of attributes with their corresponding values. - // - // The following lists the names, descriptions, and values of the special request - // parameters that the CreateQueue action uses: - // - // * DelaySeconds - The length of time, in seconds, for which the delivery - // of all messages in the queue is delayed. Valid values: An integer from - // 0 to 900 seconds (15 minutes). Default: 0. - // - // * MaximumMessageSize - The limit of how many bytes a message can contain - // before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes - // (1 KiB) to 262,144 bytes (256 KiB). Default: 262,144 (256 KiB). - // - // * MessageRetentionPeriod - The length of time, in seconds, for which Amazon - // SQS retains a message. Valid values: An integer from 60 seconds (1 minute) - // to 1,209,600 seconds (14 days). Default: 345,600 (4 days). - // - // * Policy - The queue's policy. A valid AWS policy. For more information - // about policy structure, see Overview of AWS IAM Policies (https://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html) - // in the Amazon IAM User Guide. - // - // * ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for - // which a ReceiveMessage action waits for a message to arrive. Valid values: - // An integer from 0 to 20 (seconds). Default: 0. - // - // * RedrivePolicy - The string that includes the parameters for the dead-letter - // queue functionality of the source queue. For more information about the - // redrive policy and dead-letter queues, see Using Amazon SQS Dead-Letter - // Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) - // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn - // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon - // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount - // - The number of times a message is delivered to the source queue before - // being moved to the dead-letter queue. When the ReceiveCount for a message - // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message - // to the dead-letter-queue. The dead-letter queue of a FIFO queue must also - // be a FIFO queue. Similarly, the dead-letter queue of a standard queue - // must also be a standard queue. - // - // * VisibilityTimeout - The visibility timeout for the queue, in seconds. - // Valid values: An integer from 0 to 43,200 (12 hours). Default: 30. For - // more information about the visibility timeout, see Visibility Timeout - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): - // - // * KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) - // for Amazon SQS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). - // While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs, - // the alias of a custom CMK can, for example, be alias/MyAlias . For more - // examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) - // in the AWS Key Management Service API Reference. - // - // * KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which - // Amazon SQS can reuse a data key (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys) - // to encrypt or decrypt messages before calling AWS KMS again. An integer - // representing seconds, between 60 seconds (1 minute) and 86,400 seconds - // (24 hours). Default: 300 (5 minutes). A shorter time period provides better - // security but results in more calls to KMS which might incur charges after - // Free Tier. For more information, see How Does the Data Key Reuse Period - // Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). - // - // The following attributes apply only to FIFO (first-in-first-out) queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): - // - // * FifoQueue - Designates a queue as FIFO. Valid values: true, false. If - // you don't specify the FifoQueue attribute, Amazon SQS creates a standard - // queue. You can provide this attribute only during queue creation. You - // can't change it for an existing queue. When you set this attribute, you - // must also provide the MessageGroupId for your messages explicitly. For - // more information, see FIFO Queue Logic (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic) - // in the Amazon Simple Queue Service Developer Guide. - // - // * ContentBasedDeduplication - Enables content-based deduplication. Valid - // values: true, false. For more information, see Exactly-Once Processing - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) - // in the Amazon Simple Queue Service Developer Guide. Every message must - // have a unique MessageDeduplicationId, You may provide a MessageDeduplicationId - // explicitly. If you aren't able to provide a MessageDeduplicationId and - // you enable ContentBasedDeduplication for your queue, Amazon SQS uses a - // SHA-256 hash to generate the MessageDeduplicationId using the body of - // the message (but not the attributes of the message). If you don't provide - // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication - // set, the action fails with an error. If the queue has ContentBasedDeduplication - // set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication - // is in effect, messages with identical content sent within the deduplication - // interval are treated as duplicates and only one copy of the message is - // delivered. If you send one message with ContentBasedDeduplication enabled - // and then another message with a MessageDeduplicationId that is the same - // as the one generated for the first MessageDeduplicationId, the two messages - // are treated as duplicates and only one copy of the message is delivered. - Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` - - // The name of the new queue. The following limits apply to this name: - // - // * A queue name can have up to 80 characters. - // - // * Valid values: alphanumeric characters, hyphens (-), and underscores - // (_). - // - // * A FIFO queue name must end with the .fifo suffix. - // - // Queue URLs and names are case-sensitive. - // - // QueueName is a required field - QueueName *string `type:"string" required:"true"` - - // Add cost allocation tags to the specified Amazon SQS queue. For an overview, - // see Tagging Your Amazon SQS Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // When you use queue tags, keep the following guidelines in mind: - // - // * Adding more than 50 tags to a queue isn't recommended. - // - // * Tags don't have any semantic meaning. Amazon SQS interprets tags as - // character strings. - // - // * Tags are case-sensitive. - // - // * A new tag with a key identical to that of an existing tag overwrites - // the existing tag. - // - // For a full list of tag restrictions, see Limits Related to Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-limits.html#limits-queues) - // in the Amazon Simple Queue Service Developer Guide. - // - // To be able to tag a queue on creation, you must have the sqs:CreateQueue - // and sqs:TagQueue permissions. - // - // Cross-account permissions don't apply to this action. For more information, - // see Grant Cross-Account Permissions to a Role and a User Name (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name) - // in the Amazon Simple Queue Service Developer Guide. - Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true"` -} - -// String returns the string representation -func (s CreateQueueInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *CreateQueueInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "CreateQueueInput"} - - if s.QueueName == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueName")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// Returns the QueueUrl attribute of the created queue. -type CreateQueueOutput struct { - _ struct{} `type:"structure"` - - // The URL of the created Amazon SQS queue. - QueueUrl *string `type:"string"` -} - -// String returns the string representation -func (s CreateQueueOutput) String() string { - return awsutil.Prettify(s) -} - const opCreateQueue = "CreateQueue" // CreateQueueRequest returns a request value for making API operation for @@ -235,7 +65,7 @@ const opCreateQueue = "CreateQueue" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/CreateQueue -func (c *Client) CreateQueueRequest(input *CreateQueueInput) CreateQueueRequest { +func (c *Client) CreateQueueRequest(input *types.CreateQueueInput) CreateQueueRequest { op := &aws.Operation{ Name: opCreateQueue, HTTPMethod: "POST", @@ -243,10 +73,10 @@ func (c *Client) CreateQueueRequest(input *CreateQueueInput) CreateQueueRequest } if input == nil { - input = &CreateQueueInput{} + input = &types.CreateQueueInput{} } - req := c.newRequest(op, input, &CreateQueueOutput{}) + req := c.newRequest(op, input, &types.CreateQueueOutput{}) return CreateQueueRequest{Request: req, Input: input, Copy: c.CreateQueueRequest} } @@ -254,8 +84,8 @@ func (c *Client) CreateQueueRequest(input *CreateQueueInput) CreateQueueRequest // CreateQueue API operation. type CreateQueueRequest struct { *aws.Request - Input *CreateQueueInput - Copy func(*CreateQueueInput) CreateQueueRequest + Input *types.CreateQueueInput + Copy func(*types.CreateQueueInput) CreateQueueRequest } // Send marshals and sends the CreateQueue API request. @@ -267,7 +97,7 @@ func (r CreateQueueRequest) Send(ctx context.Context) (*CreateQueueResponse, err } resp := &CreateQueueResponse{ - CreateQueueOutput: r.Request.Data.(*CreateQueueOutput), + CreateQueueOutput: r.Request.Data.(*types.CreateQueueOutput), response: &aws.Response{Request: r.Request}, } @@ -277,7 +107,7 @@ func (r CreateQueueRequest) Send(ctx context.Context) (*CreateQueueResponse, err // CreateQueueResponse is the response type for the // CreateQueue API operation. type CreateQueueResponse struct { - *CreateQueueOutput + *types.CreateQueueOutput response *aws.Response } diff --git a/service/sqs/api_op_DeleteMessage.go b/service/sqs/api_op_DeleteMessage.go index 2beb49abe81..b8512458963 100644 --- a/service/sqs/api_op_DeleteMessage.go +++ b/service/sqs/api_op_DeleteMessage.go @@ -6,59 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type DeleteMessageInput struct { - _ struct{} `type:"structure"` - - // The URL of the Amazon SQS queue from which messages are deleted. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` - - // The receipt handle associated with the message to delete. - // - // ReceiptHandle is a required field - ReceiptHandle *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s DeleteMessageInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *DeleteMessageInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "DeleteMessageInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if s.ReceiptHandle == nil { - invalidParams.Add(aws.NewErrParamRequired("ReceiptHandle")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type DeleteMessageOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s DeleteMessageOutput) String() string { - return awsutil.Prettify(s) -} - const opDeleteMessage = "DeleteMessage" // DeleteMessageRequest returns a request value for making API operation for @@ -93,7 +45,7 @@ const opDeleteMessage = "DeleteMessage" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteMessage -func (c *Client) DeleteMessageRequest(input *DeleteMessageInput) DeleteMessageRequest { +func (c *Client) DeleteMessageRequest(input *types.DeleteMessageInput) DeleteMessageRequest { op := &aws.Operation{ Name: opDeleteMessage, HTTPMethod: "POST", @@ -101,10 +53,10 @@ func (c *Client) DeleteMessageRequest(input *DeleteMessageInput) DeleteMessageRe } if input == nil { - input = &DeleteMessageInput{} + input = &types.DeleteMessageInput{} } - req := c.newRequest(op, input, &DeleteMessageOutput{}) + req := c.newRequest(op, input, &types.DeleteMessageOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return DeleteMessageRequest{Request: req, Input: input, Copy: c.DeleteMessageRequest} @@ -114,8 +66,8 @@ func (c *Client) DeleteMessageRequest(input *DeleteMessageInput) DeleteMessageRe // DeleteMessage API operation. type DeleteMessageRequest struct { *aws.Request - Input *DeleteMessageInput - Copy func(*DeleteMessageInput) DeleteMessageRequest + Input *types.DeleteMessageInput + Copy func(*types.DeleteMessageInput) DeleteMessageRequest } // Send marshals and sends the DeleteMessage API request. @@ -127,7 +79,7 @@ func (r DeleteMessageRequest) Send(ctx context.Context) (*DeleteMessageResponse, } resp := &DeleteMessageResponse{ - DeleteMessageOutput: r.Request.Data.(*DeleteMessageOutput), + DeleteMessageOutput: r.Request.Data.(*types.DeleteMessageOutput), response: &aws.Response{Request: r.Request}, } @@ -137,7 +89,7 @@ func (r DeleteMessageRequest) Send(ctx context.Context) (*DeleteMessageResponse, // DeleteMessageResponse is the response type for the // DeleteMessage API operation. type DeleteMessageResponse struct { - *DeleteMessageOutput + *types.DeleteMessageOutput response *aws.Response } diff --git a/service/sqs/api_op_DeleteMessageBatch.go b/service/sqs/api_op_DeleteMessageBatch.go index 106d12e3874..722409d0337 100644 --- a/service/sqs/api_op_DeleteMessageBatch.go +++ b/service/sqs/api_op_DeleteMessageBatch.go @@ -4,80 +4,11 @@ package sqs import ( "context" - "fmt" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type DeleteMessageBatchInput struct { - _ struct{} `type:"structure"` - - // A list of receipt handles for the messages to be deleted. - // - // Entries is a required field - Entries []DeleteMessageBatchRequestEntry `locationNameList:"DeleteMessageBatchRequestEntry" type:"list" flattened:"true" required:"true"` - - // The URL of the Amazon SQS queue from which messages are deleted. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s DeleteMessageBatchInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *DeleteMessageBatchInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "DeleteMessageBatchInput"} - - if s.Entries == nil { - invalidParams.Add(aws.NewErrParamRequired("Entries")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - if s.Entries != nil { - for i, v := range s.Entries { - if err := v.Validate(); err != nil { - invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) - } - } - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// For each message in the batch, the response contains a DeleteMessageBatchResultEntry -// tag if the message is deleted or a BatchResultErrorEntry tag if the message -// can't be deleted. -type DeleteMessageBatchOutput struct { - _ struct{} `type:"structure"` - - // A list of BatchResultErrorEntry items. - // - // Failed is a required field - Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` - - // A list of DeleteMessageBatchResultEntry items. - // - // Successful is a required field - Successful []DeleteMessageBatchResultEntry `locationNameList:"DeleteMessageBatchResultEntry" type:"list" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s DeleteMessageBatchOutput) String() string { - return awsutil.Prettify(s) -} - const opDeleteMessageBatch = "DeleteMessageBatch" // DeleteMessageBatchRequest returns a request value for making API operation for @@ -107,7 +38,7 @@ const opDeleteMessageBatch = "DeleteMessageBatch" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteMessageBatch -func (c *Client) DeleteMessageBatchRequest(input *DeleteMessageBatchInput) DeleteMessageBatchRequest { +func (c *Client) DeleteMessageBatchRequest(input *types.DeleteMessageBatchInput) DeleteMessageBatchRequest { op := &aws.Operation{ Name: opDeleteMessageBatch, HTTPMethod: "POST", @@ -115,10 +46,10 @@ func (c *Client) DeleteMessageBatchRequest(input *DeleteMessageBatchInput) Delet } if input == nil { - input = &DeleteMessageBatchInput{} + input = &types.DeleteMessageBatchInput{} } - req := c.newRequest(op, input, &DeleteMessageBatchOutput{}) + req := c.newRequest(op, input, &types.DeleteMessageBatchOutput{}) return DeleteMessageBatchRequest{Request: req, Input: input, Copy: c.DeleteMessageBatchRequest} } @@ -126,8 +57,8 @@ func (c *Client) DeleteMessageBatchRequest(input *DeleteMessageBatchInput) Delet // DeleteMessageBatch API operation. type DeleteMessageBatchRequest struct { *aws.Request - Input *DeleteMessageBatchInput - Copy func(*DeleteMessageBatchInput) DeleteMessageBatchRequest + Input *types.DeleteMessageBatchInput + Copy func(*types.DeleteMessageBatchInput) DeleteMessageBatchRequest } // Send marshals and sends the DeleteMessageBatch API request. @@ -139,7 +70,7 @@ func (r DeleteMessageBatchRequest) Send(ctx context.Context) (*DeleteMessageBatc } resp := &DeleteMessageBatchResponse{ - DeleteMessageBatchOutput: r.Request.Data.(*DeleteMessageBatchOutput), + DeleteMessageBatchOutput: r.Request.Data.(*types.DeleteMessageBatchOutput), response: &aws.Response{Request: r.Request}, } @@ -149,7 +80,7 @@ func (r DeleteMessageBatchRequest) Send(ctx context.Context) (*DeleteMessageBatc // DeleteMessageBatchResponse is the response type for the // DeleteMessageBatch API operation. type DeleteMessageBatchResponse struct { - *DeleteMessageBatchOutput + *types.DeleteMessageBatchOutput response *aws.Response } diff --git a/service/sqs/api_op_DeleteQueue.go b/service/sqs/api_op_DeleteQueue.go index 22f90a6d0d8..216c5fabc37 100644 --- a/service/sqs/api_op_DeleteQueue.go +++ b/service/sqs/api_op_DeleteQueue.go @@ -6,50 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type DeleteQueueInput struct { - _ struct{} `type:"structure"` - - // The URL of the Amazon SQS queue to delete. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s DeleteQueueInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *DeleteQueueInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "DeleteQueueInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type DeleteQueueOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s DeleteQueueOutput) String() string { - return awsutil.Prettify(s) -} - const opDeleteQueue = "DeleteQueue" // DeleteQueueRequest returns a request value for making API operation for @@ -81,7 +42,7 @@ const opDeleteQueue = "DeleteQueue" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/DeleteQueue -func (c *Client) DeleteQueueRequest(input *DeleteQueueInput) DeleteQueueRequest { +func (c *Client) DeleteQueueRequest(input *types.DeleteQueueInput) DeleteQueueRequest { op := &aws.Operation{ Name: opDeleteQueue, HTTPMethod: "POST", @@ -89,10 +50,10 @@ func (c *Client) DeleteQueueRequest(input *DeleteQueueInput) DeleteQueueRequest } if input == nil { - input = &DeleteQueueInput{} + input = &types.DeleteQueueInput{} } - req := c.newRequest(op, input, &DeleteQueueOutput{}) + req := c.newRequest(op, input, &types.DeleteQueueOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return DeleteQueueRequest{Request: req, Input: input, Copy: c.DeleteQueueRequest} @@ -102,8 +63,8 @@ func (c *Client) DeleteQueueRequest(input *DeleteQueueInput) DeleteQueueRequest // DeleteQueue API operation. type DeleteQueueRequest struct { *aws.Request - Input *DeleteQueueInput - Copy func(*DeleteQueueInput) DeleteQueueRequest + Input *types.DeleteQueueInput + Copy func(*types.DeleteQueueInput) DeleteQueueRequest } // Send marshals and sends the DeleteQueue API request. @@ -115,7 +76,7 @@ func (r DeleteQueueRequest) Send(ctx context.Context) (*DeleteQueueResponse, err } resp := &DeleteQueueResponse{ - DeleteQueueOutput: r.Request.Data.(*DeleteQueueOutput), + DeleteQueueOutput: r.Request.Data.(*types.DeleteQueueOutput), response: &aws.Response{Request: r.Request}, } @@ -125,7 +86,7 @@ func (r DeleteQueueRequest) Send(ctx context.Context) (*DeleteQueueResponse, err // DeleteQueueResponse is the response type for the // DeleteQueue API operation. type DeleteQueueResponse struct { - *DeleteQueueOutput + *types.DeleteQueueOutput response *aws.Response } diff --git a/service/sqs/api_op_GetQueueAttributes.go b/service/sqs/api_op_GetQueueAttributes.go index e747beb8fce..e6461cfdf53 100644 --- a/service/sqs/api_op_GetQueueAttributes.go +++ b/service/sqs/api_op_GetQueueAttributes.go @@ -6,138 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type GetQueueAttributesInput struct { - _ struct{} `type:"structure"` - - // A list of attributes for which to retrieve information. - // - // In the future, new attributes might be added. If you write code that calls - // this action, we recommend that you structure your code so that it can handle - // new attributes gracefully. - // - // The following attributes are supported: - // - // * All - Returns all values. - // - // * ApproximateNumberOfMessages - Returns the approximate number of messages - // available for retrieval from the queue. - // - // * ApproximateNumberOfMessagesDelayed - Returns the approximate number - // of messages in the queue that are delayed and not available for reading - // immediately. This can happen when the queue is configured as a delay queue - // or when a message has been sent with a delay parameter. - // - // * ApproximateNumberOfMessagesNotVisible - Returns the approximate number - // of messages that are in flight. Messages are considered to be in flight - // if they have been sent to a client but have not yet been deleted or have - // not yet reached the end of their visibility window. - // - // * CreatedTimestamp - Returns the time when the queue was created in seconds - // (epoch time (http://en.wikipedia.org/wiki/Unix_time)). - // - // * DelaySeconds - Returns the default delay on the queue in seconds. - // - // * LastModifiedTimestamp - Returns the time when the queue was last changed - // in seconds (epoch time (http://en.wikipedia.org/wiki/Unix_time)). - // - // * MaximumMessageSize - Returns the limit of how many bytes a message can - // contain before Amazon SQS rejects it. - // - // * MessageRetentionPeriod - Returns the length of time, in seconds, for - // which Amazon SQS retains a message. - // - // * Policy - Returns the policy of the queue. - // - // * QueueArn - Returns the Amazon resource name (ARN) of the queue. - // - // * ReceiveMessageWaitTimeSeconds - Returns the length of time, in seconds, - // for which the ReceiveMessage action waits for a message to arrive. - // - // * RedrivePolicy - Returns the string that includes the parameters for - // dead-letter queue functionality of the source queue. For more information - // about the redrive policy and dead-letter queues, see Using Amazon SQS - // Dead-Letter Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) - // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn - // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon - // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount - // - The number of times a message is delivered to the source queue before - // being moved to the dead-letter queue. When the ReceiveCount for a message - // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message - // to the dead-letter-queue. - // - // * VisibilityTimeout - Returns the visibility timeout for the queue. For - // more information about the visibility timeout, see Visibility Timeout - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): - // - // * KmsMasterKeyId - Returns the ID of an AWS-managed customer master key - // (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). - // - // * KmsDataKeyReusePeriodSeconds - Returns the length of time, in seconds, - // for which Amazon SQS can reuse a data key to encrypt or decrypt messages - // before calling AWS KMS again. For more information, see How Does the Data - // Key Reuse Period Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). - // - // The following attributes apply only to FIFO (first-in-first-out) queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): - // - // * FifoQueue - Returns whether the queue is FIFO. For more information, - // see FIFO Queue Logic (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic) - // in the Amazon Simple Queue Service Developer Guide. To determine whether - // a queue is FIFO (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html), - // you can check whether QueueName ends with the .fifo suffix. - // - // * ContentBasedDeduplication - Returns whether content-based deduplication - // is enabled for the queue. For more information, see Exactly-Once Processing - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) - // in the Amazon Simple Queue Service Developer Guide. - AttributeNames []QueueAttributeName `locationNameList:"AttributeName" type:"list" flattened:"true"` - - // The URL of the Amazon SQS queue whose attribute information is retrieved. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s GetQueueAttributesInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *GetQueueAttributesInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "GetQueueAttributesInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// A list of returned queue attributes. -type GetQueueAttributesOutput struct { - _ struct{} `type:"structure"` - - // A map of attributes to their respective values. - Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` -} - -// String returns the string representation -func (s GetQueueAttributesOutput) String() string { - return awsutil.Prettify(s) -} - const opGetQueueAttributes = "GetQueueAttributes" // GetQueueAttributesRequest returns a request value for making API operation for @@ -164,7 +35,7 @@ const opGetQueueAttributes = "GetQueueAttributes" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/GetQueueAttributes -func (c *Client) GetQueueAttributesRequest(input *GetQueueAttributesInput) GetQueueAttributesRequest { +func (c *Client) GetQueueAttributesRequest(input *types.GetQueueAttributesInput) GetQueueAttributesRequest { op := &aws.Operation{ Name: opGetQueueAttributes, HTTPMethod: "POST", @@ -172,10 +43,10 @@ func (c *Client) GetQueueAttributesRequest(input *GetQueueAttributesInput) GetQu } if input == nil { - input = &GetQueueAttributesInput{} + input = &types.GetQueueAttributesInput{} } - req := c.newRequest(op, input, &GetQueueAttributesOutput{}) + req := c.newRequest(op, input, &types.GetQueueAttributesOutput{}) return GetQueueAttributesRequest{Request: req, Input: input, Copy: c.GetQueueAttributesRequest} } @@ -183,8 +54,8 @@ func (c *Client) GetQueueAttributesRequest(input *GetQueueAttributesInput) GetQu // GetQueueAttributes API operation. type GetQueueAttributesRequest struct { *aws.Request - Input *GetQueueAttributesInput - Copy func(*GetQueueAttributesInput) GetQueueAttributesRequest + Input *types.GetQueueAttributesInput + Copy func(*types.GetQueueAttributesInput) GetQueueAttributesRequest } // Send marshals and sends the GetQueueAttributes API request. @@ -196,7 +67,7 @@ func (r GetQueueAttributesRequest) Send(ctx context.Context) (*GetQueueAttribute } resp := &GetQueueAttributesResponse{ - GetQueueAttributesOutput: r.Request.Data.(*GetQueueAttributesOutput), + GetQueueAttributesOutput: r.Request.Data.(*types.GetQueueAttributesOutput), response: &aws.Response{Request: r.Request}, } @@ -206,7 +77,7 @@ func (r GetQueueAttributesRequest) Send(ctx context.Context) (*GetQueueAttribute // GetQueueAttributesResponse is the response type for the // GetQueueAttributes API operation. type GetQueueAttributesResponse struct { - *GetQueueAttributesOutput + *types.GetQueueAttributesOutput response *aws.Response } diff --git a/service/sqs/api_op_GetQueueUrl.go b/service/sqs/api_op_GetQueueUrl.go index 0d5184e3e6f..aed77b1e595 100644 --- a/service/sqs/api_op_GetQueueUrl.go +++ b/service/sqs/api_op_GetQueueUrl.go @@ -6,57 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type GetQueueUrlInput struct { - _ struct{} `type:"structure"` - - // The name of the queue whose URL must be fetched. Maximum 80 characters. Valid - // values: alphanumeric characters, hyphens (-), and underscores (_). - // - // Queue URLs and names are case-sensitive. - // - // QueueName is a required field - QueueName *string `type:"string" required:"true"` - - // The AWS account ID of the account that created the queue. - QueueOwnerAWSAccountId *string `type:"string"` -} - -// String returns the string representation -func (s GetQueueUrlInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *GetQueueUrlInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "GetQueueUrlInput"} - - if s.QueueName == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueName")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// For more information, see Interpreting Responses (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-api-responses.html) -// in the Amazon Simple Queue Service Developer Guide. -type GetQueueUrlOutput struct { - _ struct{} `type:"structure"` - - // The URL of the queue. - QueueUrl *string `type:"string"` -} - -// String returns the string representation -func (s GetQueueUrlOutput) String() string { - return awsutil.Prettify(s) -} - const opGetQueueUrl = "GetQueueUrl" // GetQueueUrlRequest returns a request value for making API operation for @@ -79,7 +31,7 @@ const opGetQueueUrl = "GetQueueUrl" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/GetQueueUrl -func (c *Client) GetQueueUrlRequest(input *GetQueueUrlInput) GetQueueUrlRequest { +func (c *Client) GetQueueUrlRequest(input *types.GetQueueUrlInput) GetQueueUrlRequest { op := &aws.Operation{ Name: opGetQueueUrl, HTTPMethod: "POST", @@ -87,10 +39,10 @@ func (c *Client) GetQueueUrlRequest(input *GetQueueUrlInput) GetQueueUrlRequest } if input == nil { - input = &GetQueueUrlInput{} + input = &types.GetQueueUrlInput{} } - req := c.newRequest(op, input, &GetQueueUrlOutput{}) + req := c.newRequest(op, input, &types.GetQueueUrlOutput{}) return GetQueueUrlRequest{Request: req, Input: input, Copy: c.GetQueueUrlRequest} } @@ -98,8 +50,8 @@ func (c *Client) GetQueueUrlRequest(input *GetQueueUrlInput) GetQueueUrlRequest // GetQueueUrl API operation. type GetQueueUrlRequest struct { *aws.Request - Input *GetQueueUrlInput - Copy func(*GetQueueUrlInput) GetQueueUrlRequest + Input *types.GetQueueUrlInput + Copy func(*types.GetQueueUrlInput) GetQueueUrlRequest } // Send marshals and sends the GetQueueUrl API request. @@ -111,7 +63,7 @@ func (r GetQueueUrlRequest) Send(ctx context.Context) (*GetQueueUrlResponse, err } resp := &GetQueueUrlResponse{ - GetQueueUrlOutput: r.Request.Data.(*GetQueueUrlOutput), + GetQueueUrlOutput: r.Request.Data.(*types.GetQueueUrlOutput), response: &aws.Response{Request: r.Request}, } @@ -121,7 +73,7 @@ func (r GetQueueUrlRequest) Send(ctx context.Context) (*GetQueueUrlResponse, err // GetQueueUrlResponse is the response type for the // GetQueueUrl API operation. type GetQueueUrlResponse struct { - *GetQueueUrlOutput + *types.GetQueueUrlOutput response *aws.Response } diff --git a/service/sqs/api_op_ListDeadLetterSourceQueues.go b/service/sqs/api_op_ListDeadLetterSourceQueues.go index 134f3e81e1a..5d9360cb731 100644 --- a/service/sqs/api_op_ListDeadLetterSourceQueues.go +++ b/service/sqs/api_op_ListDeadLetterSourceQueues.go @@ -6,55 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ListDeadLetterSourceQueuesInput struct { - _ struct{} `type:"structure"` - - // The URL of a dead-letter queue. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s ListDeadLetterSourceQueuesInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *ListDeadLetterSourceQueuesInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "ListDeadLetterSourceQueuesInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// A list of your dead letter source queues. -type ListDeadLetterSourceQueuesOutput struct { - _ struct{} `type:"structure"` - - // A list of source queue URLs that have the RedrivePolicy queue attribute configured - // with a dead-letter queue. - // - // QueueUrls is a required field - QueueUrls []string `locationName:"queueUrls" locationNameList:"QueueUrl" type:"list" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s ListDeadLetterSourceQueuesOutput) String() string { - return awsutil.Prettify(s) -} - const opListDeadLetterSourceQueues = "ListDeadLetterSourceQueues" // ListDeadLetterSourceQueuesRequest returns a request value for making API operation for @@ -75,7 +29,7 @@ const opListDeadLetterSourceQueues = "ListDeadLetterSourceQueues" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListDeadLetterSourceQueues -func (c *Client) ListDeadLetterSourceQueuesRequest(input *ListDeadLetterSourceQueuesInput) ListDeadLetterSourceQueuesRequest { +func (c *Client) ListDeadLetterSourceQueuesRequest(input *types.ListDeadLetterSourceQueuesInput) ListDeadLetterSourceQueuesRequest { op := &aws.Operation{ Name: opListDeadLetterSourceQueues, HTTPMethod: "POST", @@ -83,10 +37,10 @@ func (c *Client) ListDeadLetterSourceQueuesRequest(input *ListDeadLetterSourceQu } if input == nil { - input = &ListDeadLetterSourceQueuesInput{} + input = &types.ListDeadLetterSourceQueuesInput{} } - req := c.newRequest(op, input, &ListDeadLetterSourceQueuesOutput{}) + req := c.newRequest(op, input, &types.ListDeadLetterSourceQueuesOutput{}) return ListDeadLetterSourceQueuesRequest{Request: req, Input: input, Copy: c.ListDeadLetterSourceQueuesRequest} } @@ -94,8 +48,8 @@ func (c *Client) ListDeadLetterSourceQueuesRequest(input *ListDeadLetterSourceQu // ListDeadLetterSourceQueues API operation. type ListDeadLetterSourceQueuesRequest struct { *aws.Request - Input *ListDeadLetterSourceQueuesInput - Copy func(*ListDeadLetterSourceQueuesInput) ListDeadLetterSourceQueuesRequest + Input *types.ListDeadLetterSourceQueuesInput + Copy func(*types.ListDeadLetterSourceQueuesInput) ListDeadLetterSourceQueuesRequest } // Send marshals and sends the ListDeadLetterSourceQueues API request. @@ -107,7 +61,7 @@ func (r ListDeadLetterSourceQueuesRequest) Send(ctx context.Context) (*ListDeadL } resp := &ListDeadLetterSourceQueuesResponse{ - ListDeadLetterSourceQueuesOutput: r.Request.Data.(*ListDeadLetterSourceQueuesOutput), + ListDeadLetterSourceQueuesOutput: r.Request.Data.(*types.ListDeadLetterSourceQueuesOutput), response: &aws.Response{Request: r.Request}, } @@ -117,7 +71,7 @@ func (r ListDeadLetterSourceQueuesRequest) Send(ctx context.Context) (*ListDeadL // ListDeadLetterSourceQueuesResponse is the response type for the // ListDeadLetterSourceQueues API operation. type ListDeadLetterSourceQueuesResponse struct { - *ListDeadLetterSourceQueuesOutput + *types.ListDeadLetterSourceQueuesOutput response *aws.Response } diff --git a/service/sqs/api_op_ListQueueTags.go b/service/sqs/api_op_ListQueueTags.go index 5b6ed91602b..c05117b0958 100644 --- a/service/sqs/api_op_ListQueueTags.go +++ b/service/sqs/api_op_ListQueueTags.go @@ -6,49 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ListQueueTagsInput struct { - _ struct{} `type:"structure"` - - // The URL of the queue. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s ListQueueTagsInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *ListQueueTagsInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "ListQueueTagsInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type ListQueueTagsOutput struct { - _ struct{} `type:"structure"` - - // The list of all tags added to the specified queue. - Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true"` -} - -// String returns the string representation -func (s ListQueueTagsOutput) String() string { - return awsutil.Prettify(s) -} - const opListQueueTags = "ListQueueTags" // ListQueueTagsRequest returns a request value for making API operation for @@ -70,7 +30,7 @@ const opListQueueTags = "ListQueueTags" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListQueueTags -func (c *Client) ListQueueTagsRequest(input *ListQueueTagsInput) ListQueueTagsRequest { +func (c *Client) ListQueueTagsRequest(input *types.ListQueueTagsInput) ListQueueTagsRequest { op := &aws.Operation{ Name: opListQueueTags, HTTPMethod: "POST", @@ -78,10 +38,10 @@ func (c *Client) ListQueueTagsRequest(input *ListQueueTagsInput) ListQueueTagsRe } if input == nil { - input = &ListQueueTagsInput{} + input = &types.ListQueueTagsInput{} } - req := c.newRequest(op, input, &ListQueueTagsOutput{}) + req := c.newRequest(op, input, &types.ListQueueTagsOutput{}) return ListQueueTagsRequest{Request: req, Input: input, Copy: c.ListQueueTagsRequest} } @@ -89,8 +49,8 @@ func (c *Client) ListQueueTagsRequest(input *ListQueueTagsInput) ListQueueTagsRe // ListQueueTags API operation. type ListQueueTagsRequest struct { *aws.Request - Input *ListQueueTagsInput - Copy func(*ListQueueTagsInput) ListQueueTagsRequest + Input *types.ListQueueTagsInput + Copy func(*types.ListQueueTagsInput) ListQueueTagsRequest } // Send marshals and sends the ListQueueTags API request. @@ -102,7 +62,7 @@ func (r ListQueueTagsRequest) Send(ctx context.Context) (*ListQueueTagsResponse, } resp := &ListQueueTagsResponse{ - ListQueueTagsOutput: r.Request.Data.(*ListQueueTagsOutput), + ListQueueTagsOutput: r.Request.Data.(*types.ListQueueTagsOutput), response: &aws.Response{Request: r.Request}, } @@ -112,7 +72,7 @@ func (r ListQueueTagsRequest) Send(ctx context.Context) (*ListQueueTagsResponse, // ListQueueTagsResponse is the response type for the // ListQueueTags API operation. type ListQueueTagsResponse struct { - *ListQueueTagsOutput + *types.ListQueueTagsOutput response *aws.Response } diff --git a/service/sqs/api_op_ListQueues.go b/service/sqs/api_op_ListQueues.go index 1aa25352b06..59207807381 100644 --- a/service/sqs/api_op_ListQueues.go +++ b/service/sqs/api_op_ListQueues.go @@ -6,37 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ListQueuesInput struct { - _ struct{} `type:"structure"` - - // A string to use for filtering the list results. Only those queues whose name - // begins with the specified string are returned. - // - // Queue URLs and names are case-sensitive. - QueueNamePrefix *string `type:"string"` -} - -// String returns the string representation -func (s ListQueuesInput) String() string { - return awsutil.Prettify(s) -} - -// A list of your queues. -type ListQueuesOutput struct { - _ struct{} `type:"structure"` - - // A list of queue URLs, up to 1,000 entries. - QueueUrls []string `locationNameList:"QueueUrl" type:"list" flattened:"true"` -} - -// String returns the string representation -func (s ListQueuesOutput) String() string { - return awsutil.Prettify(s) -} - const opListQueues = "ListQueues" // ListQueuesRequest returns a request value for making API operation for @@ -58,7 +30,7 @@ const opListQueues = "ListQueues" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ListQueues -func (c *Client) ListQueuesRequest(input *ListQueuesInput) ListQueuesRequest { +func (c *Client) ListQueuesRequest(input *types.ListQueuesInput) ListQueuesRequest { op := &aws.Operation{ Name: opListQueues, HTTPMethod: "POST", @@ -66,10 +38,10 @@ func (c *Client) ListQueuesRequest(input *ListQueuesInput) ListQueuesRequest { } if input == nil { - input = &ListQueuesInput{} + input = &types.ListQueuesInput{} } - req := c.newRequest(op, input, &ListQueuesOutput{}) + req := c.newRequest(op, input, &types.ListQueuesOutput{}) return ListQueuesRequest{Request: req, Input: input, Copy: c.ListQueuesRequest} } @@ -77,8 +49,8 @@ func (c *Client) ListQueuesRequest(input *ListQueuesInput) ListQueuesRequest { // ListQueues API operation. type ListQueuesRequest struct { *aws.Request - Input *ListQueuesInput - Copy func(*ListQueuesInput) ListQueuesRequest + Input *types.ListQueuesInput + Copy func(*types.ListQueuesInput) ListQueuesRequest } // Send marshals and sends the ListQueues API request. @@ -90,7 +62,7 @@ func (r ListQueuesRequest) Send(ctx context.Context) (*ListQueuesResponse, error } resp := &ListQueuesResponse{ - ListQueuesOutput: r.Request.Data.(*ListQueuesOutput), + ListQueuesOutput: r.Request.Data.(*types.ListQueuesOutput), response: &aws.Response{Request: r.Request}, } @@ -100,7 +72,7 @@ func (r ListQueuesRequest) Send(ctx context.Context) (*ListQueuesResponse, error // ListQueuesResponse is the response type for the // ListQueues API operation. type ListQueuesResponse struct { - *ListQueuesOutput + *types.ListQueuesOutput response *aws.Response } diff --git a/service/sqs/api_op_PurgeQueue.go b/service/sqs/api_op_PurgeQueue.go index 52b3eec55c9..b8f5120eb1a 100644 --- a/service/sqs/api_op_PurgeQueue.go +++ b/service/sqs/api_op_PurgeQueue.go @@ -6,50 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type PurgeQueueInput struct { - _ struct{} `type:"structure"` - - // The URL of the queue from which the PurgeQueue action deletes messages. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s PurgeQueueInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *PurgeQueueInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "PurgeQueueInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type PurgeQueueOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s PurgeQueueOutput) String() string { - return awsutil.Prettify(s) -} - const opPurgeQueue = "PurgeQueue" // PurgeQueueRequest returns a request value for making API operation for @@ -77,7 +38,7 @@ const opPurgeQueue = "PurgeQueue" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/PurgeQueue -func (c *Client) PurgeQueueRequest(input *PurgeQueueInput) PurgeQueueRequest { +func (c *Client) PurgeQueueRequest(input *types.PurgeQueueInput) PurgeQueueRequest { op := &aws.Operation{ Name: opPurgeQueue, HTTPMethod: "POST", @@ -85,10 +46,10 @@ func (c *Client) PurgeQueueRequest(input *PurgeQueueInput) PurgeQueueRequest { } if input == nil { - input = &PurgeQueueInput{} + input = &types.PurgeQueueInput{} } - req := c.newRequest(op, input, &PurgeQueueOutput{}) + req := c.newRequest(op, input, &types.PurgeQueueOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return PurgeQueueRequest{Request: req, Input: input, Copy: c.PurgeQueueRequest} @@ -98,8 +59,8 @@ func (c *Client) PurgeQueueRequest(input *PurgeQueueInput) PurgeQueueRequest { // PurgeQueue API operation. type PurgeQueueRequest struct { *aws.Request - Input *PurgeQueueInput - Copy func(*PurgeQueueInput) PurgeQueueRequest + Input *types.PurgeQueueInput + Copy func(*types.PurgeQueueInput) PurgeQueueRequest } // Send marshals and sends the PurgeQueue API request. @@ -111,7 +72,7 @@ func (r PurgeQueueRequest) Send(ctx context.Context) (*PurgeQueueResponse, error } resp := &PurgeQueueResponse{ - PurgeQueueOutput: r.Request.Data.(*PurgeQueueOutput), + PurgeQueueOutput: r.Request.Data.(*types.PurgeQueueOutput), response: &aws.Response{Request: r.Request}, } @@ -121,7 +82,7 @@ func (r PurgeQueueRequest) Send(ctx context.Context) (*PurgeQueueResponse, error // PurgeQueueResponse is the response type for the // PurgeQueue API operation. type PurgeQueueResponse struct { - *PurgeQueueOutput + *types.PurgeQueueOutput response *aws.Response } diff --git a/service/sqs/api_op_ReceiveMessage.go b/service/sqs/api_op_ReceiveMessage.go index 65e5411341e..5c5b873b373 100644 --- a/service/sqs/api_op_ReceiveMessage.go +++ b/service/sqs/api_op_ReceiveMessage.go @@ -6,171 +6,9 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type ReceiveMessageInput struct { - _ struct{} `type:"structure"` - - // A list of attributes that need to be returned along with each message. These - // attributes include: - // - // * All - Returns all values. - // - // * ApproximateFirstReceiveTimestamp - Returns the time the message was - // first received from the queue (epoch time (http://en.wikipedia.org/wiki/Unix_time) - // in milliseconds). - // - // * ApproximateReceiveCount - Returns the number of times a message has - // been received from the queue but not deleted. - // - // * AWSTraceHeader - Returns the AWS X-Ray trace header string. - // - // * SenderId For an IAM user, returns the IAM user ID, for example ABCDEFGHI1JKLMNOPQ23R. - // For an IAM role, returns the IAM role ID, for example ABCDE1F2GH3I4JK5LMNOP:i-a123b456. - // - // * SentTimestamp - Returns the time the message was sent to the queue (epoch - // time (http://en.wikipedia.org/wiki/Unix_time) in milliseconds). - // - // * MessageDeduplicationId - Returns the value provided by the producer - // that calls the SendMessage action. - // - // * MessageGroupId - Returns the value provided by the producer that calls - // the SendMessage action. Messages with the same MessageGroupId are returned - // in sequence. - // - // * SequenceNumber - Returns the value provided by Amazon SQS. - AttributeNames []QueueAttributeName `locationNameList:"AttributeName" type:"list" flattened:"true"` - - // The maximum number of messages to return. Amazon SQS never returns more messages - // than this value (however, fewer messages might be returned). Valid values: - // 1 to 10. Default: 1. - MaxNumberOfMessages *int64 `type:"integer"` - - // The name of the message attribute, where N is the index. - // - // * The name can contain alphanumeric characters and the underscore (_), - // hyphen (-), and period (.). - // - // * The name is case-sensitive and must be unique among all attribute names - // for the message. - // - // * The name must not start with AWS-reserved prefixes such as AWS. or Amazon. - // (or any casing variants). - // - // * The name must not start or end with a period (.), and it should not - // have periods in succession (..). - // - // * The name can be up to 256 characters long. - // - // When using ReceiveMessage, you can send a list of attribute names to receive, - // or you can return all of the attributes by specifying All or .* in your request. - // You can also use all message attributes starting with a prefix, for example - // bar.*. - MessageAttributeNames []string `locationNameList:"MessageAttributeName" type:"list" flattened:"true"` - - // The URL of the Amazon SQS queue from which messages are received. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` - - // This parameter applies only to FIFO (first-in-first-out) queues. - // - // The token used for deduplication of ReceiveMessage calls. If a networking - // issue occurs after a ReceiveMessage action, and instead of a response you - // receive a generic error, you can retry the same action with an identical - // ReceiveRequestAttemptId to retrieve the same set of messages, even if their - // visibility timeout has not yet expired. - // - // * You can use ReceiveRequestAttemptId only for 5 minutes after a ReceiveMessage - // action. - // - // * When you set FifoQueue, a caller of the ReceiveMessage action can provide - // a ReceiveRequestAttemptId explicitly. - // - // * If a caller of the ReceiveMessage action doesn't provide a ReceiveRequestAttemptId, - // Amazon SQS generates a ReceiveRequestAttemptId. - // - // * You can retry the ReceiveMessage action with the same ReceiveRequestAttemptId - // if none of the messages have been modified (deleted or had their visibility - // changes). - // - // * During a visibility timeout, subsequent calls with the same ReceiveRequestAttemptId - // return the same messages and receipt handles. If a retry occurs within - // the deduplication interval, it resets the visibility timeout. For more - // information, see Visibility Timeout (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) - // in the Amazon Simple Queue Service Developer Guide. If a caller of the - // ReceiveMessage action still processes messages when the visibility timeout - // expires and messages become visible, another worker consuming from the - // same queue can receive the same messages and therefore process duplicates. - // Also, if a consumer whose message processing time is longer than the visibility - // timeout tries to delete the processed messages, the action fails with - // an error. To mitigate this effect, ensure that your application observes - // a safe threshold before the visibility timeout expires and extend the - // visibility timeout as necessary. - // - // * While messages with a particular MessageGroupId are invisible, no more - // messages belonging to the same MessageGroupId are returned until the visibility - // timeout expires. You can still receive messages with another MessageGroupId - // as long as it is also visible. - // - // * If a caller of ReceiveMessage can't track the ReceiveRequestAttemptId, - // no retries work until the original visibility timeout expires. As a result, - // delays might occur but the messages in the queue remain in a strict order. - // - // The length of ReceiveRequestAttemptId is 128 characters. ReceiveRequestAttemptId - // can contain alphanumeric characters (a-z, A-Z, 0-9) and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). - // - // For best practices of using ReceiveRequestAttemptId, see Using the ReceiveRequestAttemptId - // Request Parameter (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-receiverequestattemptid-request-parameter.html) - // in the Amazon Simple Queue Service Developer Guide. - ReceiveRequestAttemptId *string `type:"string"` - - // The duration (in seconds) that the received messages are hidden from subsequent - // retrieve requests after being retrieved by a ReceiveMessage request. - VisibilityTimeout *int64 `type:"integer"` - - // The duration (in seconds) for which the call waits for a message to arrive - // in the queue before returning. If a message is available, the call returns - // sooner than WaitTimeSeconds. If no messages are available and the wait time - // expires, the call returns successfully with an empty list of messages. - WaitTimeSeconds *int64 `type:"integer"` -} - -// String returns the string representation -func (s ReceiveMessageInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *ReceiveMessageInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "ReceiveMessageInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// A list of received messages. -type ReceiveMessageOutput struct { - _ struct{} `type:"structure"` - - // A list of messages. - Messages []Message `locationNameList:"Message" type:"list" flattened:"true"` -} - -// String returns the string representation -func (s ReceiveMessageOutput) String() string { - return awsutil.Prettify(s) -} - const opReceiveMessage = "ReceiveMessage" // ReceiveMessageRequest returns a request value for making API operation for @@ -232,7 +70,7 @@ const opReceiveMessage = "ReceiveMessage" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/ReceiveMessage -func (c *Client) ReceiveMessageRequest(input *ReceiveMessageInput) ReceiveMessageRequest { +func (c *Client) ReceiveMessageRequest(input *types.ReceiveMessageInput) ReceiveMessageRequest { op := &aws.Operation{ Name: opReceiveMessage, HTTPMethod: "POST", @@ -240,10 +78,10 @@ func (c *Client) ReceiveMessageRequest(input *ReceiveMessageInput) ReceiveMessag } if input == nil { - input = &ReceiveMessageInput{} + input = &types.ReceiveMessageInput{} } - req := c.newRequest(op, input, &ReceiveMessageOutput{}) + req := c.newRequest(op, input, &types.ReceiveMessageOutput{}) return ReceiveMessageRequest{Request: req, Input: input, Copy: c.ReceiveMessageRequest} } @@ -251,8 +89,8 @@ func (c *Client) ReceiveMessageRequest(input *ReceiveMessageInput) ReceiveMessag // ReceiveMessage API operation. type ReceiveMessageRequest struct { *aws.Request - Input *ReceiveMessageInput - Copy func(*ReceiveMessageInput) ReceiveMessageRequest + Input *types.ReceiveMessageInput + Copy func(*types.ReceiveMessageInput) ReceiveMessageRequest } // Send marshals and sends the ReceiveMessage API request. @@ -264,7 +102,7 @@ func (r ReceiveMessageRequest) Send(ctx context.Context) (*ReceiveMessageRespons } resp := &ReceiveMessageResponse{ - ReceiveMessageOutput: r.Request.Data.(*ReceiveMessageOutput), + ReceiveMessageOutput: r.Request.Data.(*types.ReceiveMessageOutput), response: &aws.Response{Request: r.Request}, } @@ -274,7 +112,7 @@ func (r ReceiveMessageRequest) Send(ctx context.Context) (*ReceiveMessageRespons // ReceiveMessageResponse is the response type for the // ReceiveMessage API operation. type ReceiveMessageResponse struct { - *ReceiveMessageOutput + *types.ReceiveMessageOutput response *aws.Response } diff --git a/service/sqs/api_op_RemovePermission.go b/service/sqs/api_op_RemovePermission.go index 68c7338e214..5fa9ff8072a 100644 --- a/service/sqs/api_op_RemovePermission.go +++ b/service/sqs/api_op_RemovePermission.go @@ -6,60 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type RemovePermissionInput struct { - _ struct{} `type:"structure"` - - // The identification of the permission to remove. This is the label added using - // the AddPermission action. - // - // Label is a required field - Label *string `type:"string" required:"true"` - - // The URL of the Amazon SQS queue from which permissions are removed. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s RemovePermissionInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *RemovePermissionInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "RemovePermissionInput"} - - if s.Label == nil { - invalidParams.Add(aws.NewErrParamRequired("Label")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type RemovePermissionOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s RemovePermissionOutput) String() string { - return awsutil.Prettify(s) -} - const opRemovePermission = "RemovePermission" // RemovePermissionRequest returns a request value for making API operation for @@ -86,7 +37,7 @@ const opRemovePermission = "RemovePermission" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/RemovePermission -func (c *Client) RemovePermissionRequest(input *RemovePermissionInput) RemovePermissionRequest { +func (c *Client) RemovePermissionRequest(input *types.RemovePermissionInput) RemovePermissionRequest { op := &aws.Operation{ Name: opRemovePermission, HTTPMethod: "POST", @@ -94,10 +45,10 @@ func (c *Client) RemovePermissionRequest(input *RemovePermissionInput) RemovePer } if input == nil { - input = &RemovePermissionInput{} + input = &types.RemovePermissionInput{} } - req := c.newRequest(op, input, &RemovePermissionOutput{}) + req := c.newRequest(op, input, &types.RemovePermissionOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return RemovePermissionRequest{Request: req, Input: input, Copy: c.RemovePermissionRequest} @@ -107,8 +58,8 @@ func (c *Client) RemovePermissionRequest(input *RemovePermissionInput) RemovePer // RemovePermission API operation. type RemovePermissionRequest struct { *aws.Request - Input *RemovePermissionInput - Copy func(*RemovePermissionInput) RemovePermissionRequest + Input *types.RemovePermissionInput + Copy func(*types.RemovePermissionInput) RemovePermissionRequest } // Send marshals and sends the RemovePermission API request. @@ -120,7 +71,7 @@ func (r RemovePermissionRequest) Send(ctx context.Context) (*RemovePermissionRes } resp := &RemovePermissionResponse{ - RemovePermissionOutput: r.Request.Data.(*RemovePermissionOutput), + RemovePermissionOutput: r.Request.Data.(*types.RemovePermissionOutput), response: &aws.Response{Request: r.Request}, } @@ -130,7 +81,7 @@ func (r RemovePermissionRequest) Send(ctx context.Context) (*RemovePermissionRes // RemovePermissionResponse is the response type for the // RemovePermission API operation. type RemovePermissionResponse struct { - *RemovePermissionOutput + *types.RemovePermissionOutput response *aws.Response } diff --git a/service/sqs/api_op_SendMessage.go b/service/sqs/api_op_SendMessage.go index b3274d73772..a0e7329d8cb 100644 --- a/service/sqs/api_op_SendMessage.go +++ b/service/sqs/api_op_SendMessage.go @@ -4,211 +4,11 @@ package sqs import ( "context" - "fmt" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type SendMessageInput struct { - _ struct{} `type:"structure"` - - // The length of time, in seconds, for which to delay a specific message. Valid - // values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds - // value become available for processing after the delay period is finished. - // If you don't specify a value, the default value for the queue applies. - // - // When you set FifoQueue, you can't set DelaySeconds per message. You can set - // this parameter only on a queue level. - DelaySeconds *int64 `type:"integer"` - - // Each message attribute consists of a Name, Type, and Value. For more information, - // see Amazon SQS Message Attributes (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html) - // in the Amazon Simple Queue Service Developer Guide. - MessageAttributes map[string]MessageAttributeValue `locationName:"MessageAttribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` - - // The message to send. The maximum string size is 256 KB. - // - // A message can include only XML, JSON, and unformatted text. The following - // Unicode characters are allowed: - // - // #x9 | #xA | #xD | #x20 to #xD7FF | #xE000 to #xFFFD | #x10000 to #x10FFFF - // - // Any characters not included in this list will be rejected. For more information, - // see the W3C specification for characters (http://www.w3.org/TR/REC-xml/#charsets). - // - // MessageBody is a required field - MessageBody *string `type:"string" required:"true"` - - // This parameter applies only to FIFO (first-in-first-out) queues. - // - // The token used for deduplication of sent messages. If a message with a particular - // MessageDeduplicationId is sent successfully, any messages sent with the same - // MessageDeduplicationId are accepted successfully but aren't delivered during - // the 5-minute deduplication interval. For more information, see Exactly-Once - // Processing (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) - // in the Amazon Simple Queue Service Developer Guide. - // - // * Every message must have a unique MessageDeduplicationId, You may provide - // a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId - // and you enable ContentBasedDeduplication for your queue, Amazon SQS uses - // a SHA-256 hash to generate the MessageDeduplicationId using the body of - // the message (but not the attributes of the message). If you don't provide - // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication - // set, the action fails with an error. If the queue has ContentBasedDeduplication - // set, your MessageDeduplicationId overrides the generated one. - // - // * When ContentBasedDeduplication is in effect, messages with identical - // content sent within the deduplication interval are treated as duplicates - // and only one copy of the message is delivered. - // - // * If you send one message with ContentBasedDeduplication enabled and then - // another message with a MessageDeduplicationId that is the same as the - // one generated for the first MessageDeduplicationId, the two messages are - // treated as duplicates and only one copy of the message is delivered. - // - // The MessageDeduplicationId is available to the consumer of the message (this - // can be useful for troubleshooting delivery issues). - // - // If a message is sent successfully but the acknowledgement is lost and the - // message is resent with the same MessageDeduplicationId after the deduplication - // interval, Amazon SQS can't detect duplicate messages. - // - // Amazon SQS continues to keep track of the message deduplication ID even after - // the message is received and deleted. - // - // The length of MessageDeduplicationId is 128 characters. MessageDeduplicationId - // can contain alphanumeric characters (a-z, A-Z, 0-9) and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). - // - // For best practices of using MessageDeduplicationId, see Using the MessageDeduplicationId - // Property (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html) - // in the Amazon Simple Queue Service Developer Guide. - MessageDeduplicationId *string `type:"string"` - - // This parameter applies only to FIFO (first-in-first-out) queues. - // - // The tag that specifies that a message belongs to a specific message group. - // Messages that belong to the same message group are processed in a FIFO manner - // (however, messages in different message groups might be processed out of - // order). To interleave multiple ordered streams within a single queue, use - // MessageGroupId values (for example, session data for multiple users). In - // this scenario, multiple consumers can process the queue, but the session - // data of each user is processed in a FIFO fashion. - // - // * You must associate a non-empty MessageGroupId with a message. If you - // don't provide a MessageGroupId, the action fails. - // - // * ReceiveMessage might return messages with multiple MessageGroupId values. - // For each MessageGroupId, the messages are sorted by time sent. The caller - // can't specify a MessageGroupId. - // - // The length of MessageGroupId is 128 characters. Valid values: alphanumeric - // characters and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). - // - // For best practices of using MessageGroupId, see Using the MessageGroupId - // Property (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagegroupid-property.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // MessageGroupId is required for FIFO queues. You can't use it for Standard - // queues. - MessageGroupId *string `type:"string"` - - // The message system attribute to send. Each message system attribute consists - // of a Name, Type, and Value. - // - // * Currently, the only supported message system attribute is AWSTraceHeader. - // Its type must be String and its value must be a correctly formatted AWS - // X-Ray trace string. - // - // * The size of a message system attribute doesn't count towards the total - // size of a message. - MessageSystemAttributes map[string]MessageSystemAttributeValue `locationName:"MessageSystemAttribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` - - // The URL of the Amazon SQS queue to which a message is sent. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s SendMessageInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *SendMessageInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "SendMessageInput"} - - if s.MessageBody == nil { - invalidParams.Add(aws.NewErrParamRequired("MessageBody")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - if s.MessageAttributes != nil { - for i, v := range s.MessageAttributes { - if err := v.Validate(); err != nil { - invalidParams.AddNested(fmt.Sprintf("%s[%v]", "MessageAttributes", i), err.(aws.ErrInvalidParams)) - } - } - } - if s.MessageSystemAttributes != nil { - for i, v := range s.MessageSystemAttributes { - if err := v.Validate(); err != nil { - invalidParams.AddNested(fmt.Sprintf("%s[%v]", "MessageSystemAttributes", i), err.(aws.ErrInvalidParams)) - } - } - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// The MD5OfMessageBody and MessageId elements. -type SendMessageOutput struct { - _ struct{} `type:"structure"` - - // An MD5 digest of the non-URL-encoded message attribute string. You can use - // this attribute to verify that Amazon SQS received the message correctly. - // Amazon SQS URL-decodes the message before creating the MD5 digest. For information - // about MD5, see RFC1321 (https://www.ietf.org/rfc/rfc1321.txt). - MD5OfMessageAttributes *string `type:"string"` - - // An MD5 digest of the non-URL-encoded message attribute string. You can use - // this attribute to verify that Amazon SQS received the message correctly. - // Amazon SQS URL-decodes the message before creating the MD5 digest. For information - // about MD5, see RFC1321 (https://www.ietf.org/rfc/rfc1321.txt). - MD5OfMessageBody *string `type:"string"` - - // An MD5 digest of the non-URL-encoded message system attribute string. You - // can use this attribute to verify that Amazon SQS received the message correctly. - // Amazon SQS URL-decodes the message before creating the MD5 digest. - MD5OfMessageSystemAttributes *string `type:"string"` - - // An attribute containing the MessageId of the message sent to the queue. For - // more information, see Queue and Message Identifiers (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-message-identifiers.html) - // in the Amazon Simple Queue Service Developer Guide. - MessageId *string `type:"string"` - - // This parameter applies only to FIFO (first-in-first-out) queues. - // - // The large, non-consecutive number that Amazon SQS assigns to each message. - // - // The length of SequenceNumber is 128 bits. SequenceNumber continues to increase - // for a particular MessageGroupId. - SequenceNumber *string `type:"string"` -} - -// String returns the string representation -func (s SendMessageOutput) String() string { - return awsutil.Prettify(s) -} - const opSendMessage = "SendMessage" // SendMessageRequest returns a request value for making API operation for @@ -232,7 +32,7 @@ const opSendMessage = "SendMessage" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SendMessage -func (c *Client) SendMessageRequest(input *SendMessageInput) SendMessageRequest { +func (c *Client) SendMessageRequest(input *types.SendMessageInput) SendMessageRequest { op := &aws.Operation{ Name: opSendMessage, HTTPMethod: "POST", @@ -240,10 +40,10 @@ func (c *Client) SendMessageRequest(input *SendMessageInput) SendMessageRequest } if input == nil { - input = &SendMessageInput{} + input = &types.SendMessageInput{} } - req := c.newRequest(op, input, &SendMessageOutput{}) + req := c.newRequest(op, input, &types.SendMessageOutput{}) return SendMessageRequest{Request: req, Input: input, Copy: c.SendMessageRequest} } @@ -251,8 +51,8 @@ func (c *Client) SendMessageRequest(input *SendMessageInput) SendMessageRequest // SendMessage API operation. type SendMessageRequest struct { *aws.Request - Input *SendMessageInput - Copy func(*SendMessageInput) SendMessageRequest + Input *types.SendMessageInput + Copy func(*types.SendMessageInput) SendMessageRequest } // Send marshals and sends the SendMessage API request. @@ -264,7 +64,7 @@ func (r SendMessageRequest) Send(ctx context.Context) (*SendMessageResponse, err } resp := &SendMessageResponse{ - SendMessageOutput: r.Request.Data.(*SendMessageOutput), + SendMessageOutput: r.Request.Data.(*types.SendMessageOutput), response: &aws.Response{Request: r.Request}, } @@ -274,7 +74,7 @@ func (r SendMessageRequest) Send(ctx context.Context) (*SendMessageResponse, err // SendMessageResponse is the response type for the // SendMessage API operation. type SendMessageResponse struct { - *SendMessageOutput + *types.SendMessageOutput response *aws.Response } diff --git a/service/sqs/api_op_SendMessageBatch.go b/service/sqs/api_op_SendMessageBatch.go index 878ae1bf4b9..f8b150acc2a 100644 --- a/service/sqs/api_op_SendMessageBatch.go +++ b/service/sqs/api_op_SendMessageBatch.go @@ -4,81 +4,11 @@ package sqs import ( "context" - "fmt" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type SendMessageBatchInput struct { - _ struct{} `type:"structure"` - - // A list of SendMessageBatchRequestEntry items. - // - // Entries is a required field - Entries []SendMessageBatchRequestEntry `locationNameList:"SendMessageBatchRequestEntry" type:"list" flattened:"true" required:"true"` - - // The URL of the Amazon SQS queue to which batched messages are sent. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s SendMessageBatchInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *SendMessageBatchInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "SendMessageBatchInput"} - - if s.Entries == nil { - invalidParams.Add(aws.NewErrParamRequired("Entries")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - if s.Entries != nil { - for i, v := range s.Entries { - if err := v.Validate(); err != nil { - invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) - } - } - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -// For each message in the batch, the response contains a SendMessageBatchResultEntry -// tag if the message succeeds or a BatchResultErrorEntry tag if the message -// fails. -type SendMessageBatchOutput struct { - _ struct{} `type:"structure"` - - // A list of BatchResultErrorEntry items with error details about each message - // that can't be enqueued. - // - // Failed is a required field - Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` - - // A list of SendMessageBatchResultEntry items. - // - // Successful is a required field - Successful []SendMessageBatchResultEntry `locationNameList:"SendMessageBatchResultEntry" type:"list" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s SendMessageBatchOutput) String() string { - return awsutil.Prettify(s) -} - const opSendMessageBatch = "SendMessageBatch" // SendMessageBatchRequest returns a request value for making API operation for @@ -124,7 +54,7 @@ const opSendMessageBatch = "SendMessageBatch" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SendMessageBatch -func (c *Client) SendMessageBatchRequest(input *SendMessageBatchInput) SendMessageBatchRequest { +func (c *Client) SendMessageBatchRequest(input *types.SendMessageBatchInput) SendMessageBatchRequest { op := &aws.Operation{ Name: opSendMessageBatch, HTTPMethod: "POST", @@ -132,10 +62,10 @@ func (c *Client) SendMessageBatchRequest(input *SendMessageBatchInput) SendMessa } if input == nil { - input = &SendMessageBatchInput{} + input = &types.SendMessageBatchInput{} } - req := c.newRequest(op, input, &SendMessageBatchOutput{}) + req := c.newRequest(op, input, &types.SendMessageBatchOutput{}) return SendMessageBatchRequest{Request: req, Input: input, Copy: c.SendMessageBatchRequest} } @@ -143,8 +73,8 @@ func (c *Client) SendMessageBatchRequest(input *SendMessageBatchInput) SendMessa // SendMessageBatch API operation. type SendMessageBatchRequest struct { *aws.Request - Input *SendMessageBatchInput - Copy func(*SendMessageBatchInput) SendMessageBatchRequest + Input *types.SendMessageBatchInput + Copy func(*types.SendMessageBatchInput) SendMessageBatchRequest } // Send marshals and sends the SendMessageBatch API request. @@ -156,7 +86,7 @@ func (r SendMessageBatchRequest) Send(ctx context.Context) (*SendMessageBatchRes } resp := &SendMessageBatchResponse{ - SendMessageBatchOutput: r.Request.Data.(*SendMessageBatchOutput), + SendMessageBatchOutput: r.Request.Data.(*types.SendMessageBatchOutput), response: &aws.Response{Request: r.Request}, } @@ -166,7 +96,7 @@ func (r SendMessageBatchRequest) Send(ctx context.Context) (*SendMessageBatchRes // SendMessageBatchResponse is the response type for the // SendMessageBatch API operation. type SendMessageBatchResponse struct { - *SendMessageBatchOutput + *types.SendMessageBatchOutput response *aws.Response } diff --git a/service/sqs/api_op_SetQueueAttributes.go b/service/sqs/api_op_SetQueueAttributes.go index 4ab4cd96e3e..4b9061bca6f 100644 --- a/service/sqs/api_op_SetQueueAttributes.go +++ b/service/sqs/api_op_SetQueueAttributes.go @@ -6,141 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type SetQueueAttributesInput struct { - _ struct{} `type:"structure"` - - // A map of attributes to set. - // - // The following lists the names, descriptions, and values of the special request - // parameters that the SetQueueAttributes action uses: - // - // * DelaySeconds - The length of time, in seconds, for which the delivery - // of all messages in the queue is delayed. Valid values: An integer from - // 0 to 900 (15 minutes). Default: 0. - // - // * MaximumMessageSize - The limit of how many bytes a message can contain - // before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes - // (1 KiB) up to 262,144 bytes (256 KiB). Default: 262,144 (256 KiB). - // - // * MessageRetentionPeriod - The length of time, in seconds, for which Amazon - // SQS retains a message. Valid values: An integer representing seconds, - // from 60 (1 minute) to 1,209,600 (14 days). Default: 345,600 (4 days). - // - // * Policy - The queue's policy. A valid AWS policy. For more information - // about policy structure, see Overview of AWS IAM Policies (https://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html) - // in the Amazon IAM User Guide. - // - // * ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for - // which a ReceiveMessage action waits for a message to arrive. Valid values: - // an integer from 0 to 20 (seconds). Default: 0. - // - // * RedrivePolicy - The string that includes the parameters for the dead-letter - // queue functionality of the source queue. For more information about the - // redrive policy and dead-letter queues, see Using Amazon SQS Dead-Letter - // Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) - // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn - // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon - // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount - // - The number of times a message is delivered to the source queue before - // being moved to the dead-letter queue. When the ReceiveCount for a message - // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message - // to the dead-letter-queue. The dead-letter queue of a FIFO queue must also - // be a FIFO queue. Similarly, the dead-letter queue of a standard queue - // must also be a standard queue. - // - // * VisibilityTimeout - The visibility timeout for the queue, in seconds. - // Valid values: an integer from 0 to 43,200 (12 hours). Default: 30. For - // more information about the visibility timeout, see Visibility Timeout - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) - // in the Amazon Simple Queue Service Developer Guide. - // - // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): - // - // * KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) - // for Amazon SQS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). - // While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs, - // the alias of a custom CMK can, for example, be alias/MyAlias . For more - // examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) - // in the AWS Key Management Service API Reference. - // - // * KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which - // Amazon SQS can reuse a data key (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys) - // to encrypt or decrypt messages before calling AWS KMS again. An integer - // representing seconds, between 60 seconds (1 minute) and 86,400 seconds - // (24 hours). Default: 300 (5 minutes). A shorter time period provides better - // security but results in more calls to KMS which might incur charges after - // Free Tier. For more information, see How Does the Data Key Reuse Period - // Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). - // - // The following attribute applies only to FIFO (first-in-first-out) queues - // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): - // - // * ContentBasedDeduplication - Enables content-based deduplication. For - // more information, see Exactly-Once Processing (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) - // in the Amazon Simple Queue Service Developer Guide. Every message must - // have a unique MessageDeduplicationId, You may provide a MessageDeduplicationId - // explicitly. If you aren't able to provide a MessageDeduplicationId and - // you enable ContentBasedDeduplication for your queue, Amazon SQS uses a - // SHA-256 hash to generate the MessageDeduplicationId using the body of - // the message (but not the attributes of the message). If you don't provide - // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication - // set, the action fails with an error. If the queue has ContentBasedDeduplication - // set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication - // is in effect, messages with identical content sent within the deduplication - // interval are treated as duplicates and only one copy of the message is - // delivered. If you send one message with ContentBasedDeduplication enabled - // and then another message with a MessageDeduplicationId that is the same - // as the one generated for the first MessageDeduplicationId, the two messages - // are treated as duplicates and only one copy of the message is delivered. - // - // Attributes is a required field - Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true" required:"true"` - - // The URL of the Amazon SQS queue whose attributes are set. - // - // Queue URLs and names are case-sensitive. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` -} - -// String returns the string representation -func (s SetQueueAttributesInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *SetQueueAttributesInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "SetQueueAttributesInput"} - - if s.Attributes == nil { - invalidParams.Add(aws.NewErrParamRequired("Attributes")) - } - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type SetQueueAttributesOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s SetQueueAttributesOutput) String() string { - return awsutil.Prettify(s) -} - const opSetQueueAttributes = "SetQueueAttributes" // SetQueueAttributesRequest returns a request value for making API operation for @@ -171,7 +41,7 @@ const opSetQueueAttributes = "SetQueueAttributes" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/SetQueueAttributes -func (c *Client) SetQueueAttributesRequest(input *SetQueueAttributesInput) SetQueueAttributesRequest { +func (c *Client) SetQueueAttributesRequest(input *types.SetQueueAttributesInput) SetQueueAttributesRequest { op := &aws.Operation{ Name: opSetQueueAttributes, HTTPMethod: "POST", @@ -179,10 +49,10 @@ func (c *Client) SetQueueAttributesRequest(input *SetQueueAttributesInput) SetQu } if input == nil { - input = &SetQueueAttributesInput{} + input = &types.SetQueueAttributesInput{} } - req := c.newRequest(op, input, &SetQueueAttributesOutput{}) + req := c.newRequest(op, input, &types.SetQueueAttributesOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return SetQueueAttributesRequest{Request: req, Input: input, Copy: c.SetQueueAttributesRequest} @@ -192,8 +62,8 @@ func (c *Client) SetQueueAttributesRequest(input *SetQueueAttributesInput) SetQu // SetQueueAttributes API operation. type SetQueueAttributesRequest struct { *aws.Request - Input *SetQueueAttributesInput - Copy func(*SetQueueAttributesInput) SetQueueAttributesRequest + Input *types.SetQueueAttributesInput + Copy func(*types.SetQueueAttributesInput) SetQueueAttributesRequest } // Send marshals and sends the SetQueueAttributes API request. @@ -205,7 +75,7 @@ func (r SetQueueAttributesRequest) Send(ctx context.Context) (*SetQueueAttribute } resp := &SetQueueAttributesResponse{ - SetQueueAttributesOutput: r.Request.Data.(*SetQueueAttributesOutput), + SetQueueAttributesOutput: r.Request.Data.(*types.SetQueueAttributesOutput), response: &aws.Response{Request: r.Request}, } @@ -215,7 +85,7 @@ func (r SetQueueAttributesRequest) Send(ctx context.Context) (*SetQueueAttribute // SetQueueAttributesResponse is the response type for the // SetQueueAttributes API operation. type SetQueueAttributesResponse struct { - *SetQueueAttributesOutput + *types.SetQueueAttributesOutput response *aws.Response } diff --git a/service/sqs/api_op_TagQueue.go b/service/sqs/api_op_TagQueue.go index 5f5d69f3b10..8d80efb7e69 100644 --- a/service/sqs/api_op_TagQueue.go +++ b/service/sqs/api_op_TagQueue.go @@ -6,57 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type TagQueueInput struct { - _ struct{} `type:"structure"` - - // The URL of the queue. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` - - // The list of tags to be added to the specified queue. - // - // Tags is a required field - Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s TagQueueInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *TagQueueInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "TagQueueInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if s.Tags == nil { - invalidParams.Add(aws.NewErrParamRequired("Tags")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type TagQueueOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s TagQueueOutput) String() string { - return awsutil.Prettify(s) -} - const opTagQueue = "TagQueue" // TagQueueRequest returns a request value for making API operation for @@ -93,7 +47,7 @@ const opTagQueue = "TagQueue" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/TagQueue -func (c *Client) TagQueueRequest(input *TagQueueInput) TagQueueRequest { +func (c *Client) TagQueueRequest(input *types.TagQueueInput) TagQueueRequest { op := &aws.Operation{ Name: opTagQueue, HTTPMethod: "POST", @@ -101,10 +55,10 @@ func (c *Client) TagQueueRequest(input *TagQueueInput) TagQueueRequest { } if input == nil { - input = &TagQueueInput{} + input = &types.TagQueueInput{} } - req := c.newRequest(op, input, &TagQueueOutput{}) + req := c.newRequest(op, input, &types.TagQueueOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return TagQueueRequest{Request: req, Input: input, Copy: c.TagQueueRequest} @@ -114,8 +68,8 @@ func (c *Client) TagQueueRequest(input *TagQueueInput) TagQueueRequest { // TagQueue API operation. type TagQueueRequest struct { *aws.Request - Input *TagQueueInput - Copy func(*TagQueueInput) TagQueueRequest + Input *types.TagQueueInput + Copy func(*types.TagQueueInput) TagQueueRequest } // Send marshals and sends the TagQueue API request. @@ -127,7 +81,7 @@ func (r TagQueueRequest) Send(ctx context.Context) (*TagQueueResponse, error) { } resp := &TagQueueResponse{ - TagQueueOutput: r.Request.Data.(*TagQueueOutput), + TagQueueOutput: r.Request.Data.(*types.TagQueueOutput), response: &aws.Response{Request: r.Request}, } @@ -137,7 +91,7 @@ func (r TagQueueRequest) Send(ctx context.Context) (*TagQueueResponse, error) { // TagQueueResponse is the response type for the // TagQueue API operation. type TagQueueResponse struct { - *TagQueueOutput + *types.TagQueueOutput response *aws.Response } diff --git a/service/sqs/api_op_UntagQueue.go b/service/sqs/api_op_UntagQueue.go index 41c4962f401..24f349ac95c 100644 --- a/service/sqs/api_op_UntagQueue.go +++ b/service/sqs/api_op_UntagQueue.go @@ -6,57 +6,11 @@ import ( "context" "github.com/aws/aws-sdk-go-v2/aws" - "github.com/aws/aws-sdk-go-v2/internal/awsutil" "github.com/aws/aws-sdk-go-v2/private/protocol" "github.com/aws/aws-sdk-go-v2/private/protocol/query" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) -type UntagQueueInput struct { - _ struct{} `type:"structure"` - - // The URL of the queue. - // - // QueueUrl is a required field - QueueUrl *string `type:"string" required:"true"` - - // The list of tags to be removed from the specified queue. - // - // TagKeys is a required field - TagKeys []string `locationNameList:"TagKey" type:"list" flattened:"true" required:"true"` -} - -// String returns the string representation -func (s UntagQueueInput) String() string { - return awsutil.Prettify(s) -} - -// Validate inspects the fields of the type to determine if they are valid. -func (s *UntagQueueInput) Validate() error { - invalidParams := aws.ErrInvalidParams{Context: "UntagQueueInput"} - - if s.QueueUrl == nil { - invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) - } - - if s.TagKeys == nil { - invalidParams.Add(aws.NewErrParamRequired("TagKeys")) - } - - if invalidParams.Len() > 0 { - return invalidParams - } - return nil -} - -type UntagQueueOutput struct { - _ struct{} `type:"structure"` -} - -// String returns the string representation -func (s UntagQueueOutput) String() string { - return awsutil.Prettify(s) -} - const opUntagQueue = "UntagQueue" // UntagQueueRequest returns a request value for making API operation for @@ -78,7 +32,7 @@ const opUntagQueue = "UntagQueue" // } // // Please also see https://docs.aws.amazon.com/goto/WebAPI/sqs-2012-11-05/UntagQueue -func (c *Client) UntagQueueRequest(input *UntagQueueInput) UntagQueueRequest { +func (c *Client) UntagQueueRequest(input *types.UntagQueueInput) UntagQueueRequest { op := &aws.Operation{ Name: opUntagQueue, HTTPMethod: "POST", @@ -86,10 +40,10 @@ func (c *Client) UntagQueueRequest(input *UntagQueueInput) UntagQueueRequest { } if input == nil { - input = &UntagQueueInput{} + input = &types.UntagQueueInput{} } - req := c.newRequest(op, input, &UntagQueueOutput{}) + req := c.newRequest(op, input, &types.UntagQueueOutput{}) req.Handlers.Unmarshal.Remove(query.UnmarshalHandler) req.Handlers.Unmarshal.PushBackNamed(protocol.UnmarshalDiscardBodyHandler) return UntagQueueRequest{Request: req, Input: input, Copy: c.UntagQueueRequest} @@ -99,8 +53,8 @@ func (c *Client) UntagQueueRequest(input *UntagQueueInput) UntagQueueRequest { // UntagQueue API operation. type UntagQueueRequest struct { *aws.Request - Input *UntagQueueInput - Copy func(*UntagQueueInput) UntagQueueRequest + Input *types.UntagQueueInput + Copy func(*types.UntagQueueInput) UntagQueueRequest } // Send marshals and sends the UntagQueue API request. @@ -112,7 +66,7 @@ func (r UntagQueueRequest) Send(ctx context.Context) (*UntagQueueResponse, error } resp := &UntagQueueResponse{ - UntagQueueOutput: r.Request.Data.(*UntagQueueOutput), + UntagQueueOutput: r.Request.Data.(*types.UntagQueueOutput), response: &aws.Response{Request: r.Request}, } @@ -122,7 +76,7 @@ func (r UntagQueueRequest) Send(ctx context.Context) (*UntagQueueResponse, error // UntagQueueResponse is the response type for the // UntagQueue API operation. type UntagQueueResponse struct { - *UntagQueueOutput + *types.UntagQueueOutput response *aws.Response } diff --git a/service/sqs/checksums.go b/service/sqs/checksums.go index 79771be5da9..b5de2b24075 100644 --- a/service/sqs/checksums.go +++ b/service/sqs/checksums.go @@ -9,6 +9,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws" request "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/aws/awserr" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var ( @@ -29,8 +30,8 @@ func setupChecksumValidation(r *request.Request) { func verifySendMessage(r *request.Request) { if r.ParamsFilled() { - in := r.Params.(*SendMessageInput) - out := r.Data.(*SendMessageOutput) + in := r.Params.(*types.SendMessageInput) + out := r.Data.(*types.SendMessageOutput) err := checksumsMatch(in.MessageBody, out.MD5OfMessageBody) if err != nil { setChecksumError(r, err.Error()) @@ -40,15 +41,15 @@ func verifySendMessage(r *request.Request) { func verifySendMessageBatch(r *request.Request) { if r.ParamsFilled() { - entries := map[string]SendMessageBatchResultEntry{} + entries := map[string]types.SendMessageBatchResultEntry{} ids := []string{} - out := r.Data.(*SendMessageBatchOutput) + out := r.Data.(*types.SendMessageBatchOutput) for _, entry := range out.Successful { entries[*entry.Id] = entry } - in := r.Params.(*SendMessageBatchInput) + in := r.Params.(*types.SendMessageBatchInput) for _, entry := range in.Entries { if e, ok := entries[*entry.Id]; ok { if err := checksumsMatch(entry.MessageBody, e.MD5OfMessageBody); err != nil { @@ -65,7 +66,7 @@ func verifySendMessageBatch(r *request.Request) { func verifyReceiveMessage(r *request.Request) { if r.ParamsFilled() { ids := []string{} - out := r.Data.(*ReceiveMessageOutput) + out := r.Data.(*types.ReceiveMessageOutput) for i, msg := range out.Messages { err := checksumsMatch(msg.Body, msg.MD5OfBody) if err != nil { diff --git a/service/sqs/checksums_test.go b/service/sqs/checksums_test.go index c35a89f41e2..cb542ba882d 100644 --- a/service/sqs/checksums_test.go +++ b/service/sqs/checksums_test.go @@ -14,6 +14,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/defaults" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) var svc = func() *sqs.Client { @@ -26,13 +27,13 @@ var svc = func() *sqs.Client { }() func TestSendMessageChecksum(t *testing.T) { - req := svc.SendMessageRequest(&sqs.SendMessageInput{ + req := svc.SendMessageRequest(&types.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageOutput{ + r.Data = &types.SendMessageOutput{ MD5OfMessageBody: aws.String("098f6bcd4621d373cade4e832627b4f6"), MessageId: aws.String("12345"), } @@ -44,13 +45,13 @@ func TestSendMessageChecksum(t *testing.T) { } func TestSendMessageChecksumInvalid(t *testing.T) { - req := svc.SendMessageRequest(&sqs.SendMessageInput{ + req := svc.SendMessageRequest(&types.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageOutput{ + r.Data = &types.SendMessageOutput{ MD5OfMessageBody: aws.String("000"), MessageId: aws.String("12345"), } @@ -76,13 +77,13 @@ func TestSendMessageChecksumInvalidNoValidation(t *testing.T) { s.DisableComputeChecksums = true s.Handlers.Send.Clear() - req := s.SendMessageRequest(&sqs.SendMessageInput{ + req := s.SendMessageRequest(&types.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageOutput{ + r.Data = &types.SendMessageOutput{ MD5OfMessageBody: aws.String("000"), MessageId: aws.String("12345"), } @@ -94,11 +95,11 @@ func TestSendMessageChecksumInvalidNoValidation(t *testing.T) { } func TestSendMessageChecksumNoInput(t *testing.T) { - req := svc.SendMessageRequest(&sqs.SendMessageInput{}) + req := svc.SendMessageRequest(&types.SendMessageInput{}) req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageOutput{} + r.Data = &types.SendMessageOutput{} }) _, err := req.Send(context.Background()) if err == nil { @@ -114,13 +115,13 @@ func TestSendMessageChecksumNoInput(t *testing.T) { } func TestSendMessageChecksumNoOutput(t *testing.T) { - req := svc.SendMessageRequest(&sqs.SendMessageInput{ + req := svc.SendMessageRequest(&types.SendMessageInput{ MessageBody: aws.String("test"), }) req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageOutput{} + r.Data = &types.SendMessageOutput{} }) _, err := req.Send(context.Background()) if err == nil { @@ -136,13 +137,13 @@ func TestSendMessageChecksumNoOutput(t *testing.T) { } func TestRecieveMessageChecksum(t *testing.T) { - req := svc.ReceiveMessageRequest(&sqs.ReceiveMessageInput{}) + req := svc.ReceiveMessageRequest(&types.ReceiveMessageInput{}) req.Handlers.Send.PushBack(func(r *request.Request) { md5 := "098f6bcd4621d373cade4e832627b4f6" body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.ReceiveMessageOutput{ - Messages: []sqs.Message{ + r.Data = &types.ReceiveMessageOutput{ + Messages: []types.Message{ {Body: aws.String("test"), MD5OfBody: &md5}, {Body: aws.String("test"), MD5OfBody: &md5}, {Body: aws.String("test"), MD5OfBody: &md5}, @@ -157,13 +158,13 @@ func TestRecieveMessageChecksum(t *testing.T) { } func TestRecieveMessageChecksumInvalid(t *testing.T) { - req := svc.ReceiveMessageRequest(&sqs.ReceiveMessageInput{}) + req := svc.ReceiveMessageRequest(&types.ReceiveMessageInput{}) req.Handlers.Send.PushBack(func(r *request.Request) { md5 := "098f6bcd4621d373cade4e832627b4f6" body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.ReceiveMessageOutput{ - Messages: []sqs.Message{ + r.Data = &types.ReceiveMessageOutput{ + Messages: []types.Message{ {Body: aws.String("test"), MD5OfBody: &md5}, {Body: aws.String("test"), MD5OfBody: aws.String("000"), MessageId: aws.String("123")}, {Body: aws.String("test"), MD5OfBody: aws.String("000"), MessageId: aws.String("456")}, @@ -186,8 +187,8 @@ func TestRecieveMessageChecksumInvalid(t *testing.T) { } func TestSendMessageBatchChecksum(t *testing.T) { - req := svc.SendMessageBatchRequest(&sqs.SendMessageBatchInput{ - Entries: []sqs.SendMessageBatchRequestEntry{ + req := svc.SendMessageBatchRequest(&types.SendMessageBatchInput{ + Entries: []types.SendMessageBatchRequestEntry{ {Id: aws.String("1"), MessageBody: aws.String("test")}, {Id: aws.String("2"), MessageBody: aws.String("test")}, {Id: aws.String("3"), MessageBody: aws.String("test")}, @@ -198,8 +199,8 @@ func TestSendMessageBatchChecksum(t *testing.T) { md5 := "098f6bcd4621d373cade4e832627b4f6" body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageBatchOutput{ - Successful: []sqs.SendMessageBatchResultEntry{ + r.Data = &types.SendMessageBatchOutput{ + Successful: []types.SendMessageBatchResultEntry{ {MD5OfMessageBody: &md5, MessageId: aws.String("123"), Id: aws.String("1")}, {MD5OfMessageBody: &md5, MessageId: aws.String("456"), Id: aws.String("2")}, {MD5OfMessageBody: &md5, MessageId: aws.String("789"), Id: aws.String("3")}, @@ -214,8 +215,8 @@ func TestSendMessageBatchChecksum(t *testing.T) { } func TestSendMessageBatchChecksumFailed(t *testing.T) { - req := svc.SendMessageBatchRequest(&sqs.SendMessageBatchInput{ - Entries: []sqs.SendMessageBatchRequestEntry{ + req := svc.SendMessageBatchRequest(&types.SendMessageBatchInput{ + Entries: []types.SendMessageBatchRequestEntry{ {Id: aws.String("1"), MessageBody: aws.String("test")}, {Id: aws.String("2"), MessageBody: aws.String("test")}, {Id: aws.String("3"), MessageBody: aws.String("test")}, @@ -225,8 +226,8 @@ func TestSendMessageBatchChecksumFailed(t *testing.T) { req.Handlers.Send.PushBack(func(r *request.Request) { body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageBatchOutput{ - Failed: []sqs.BatchResultErrorEntry{ + r.Data = &types.SendMessageBatchOutput{ + Failed: []types.BatchResultErrorEntry{ {Id: aws.String("1"), Code: aws.String("test"), Message: aws.String("test"), SenderFault: aws.Bool(false)}, {Id: aws.String("2"), Code: aws.String("test"), Message: aws.String("test"), SenderFault: aws.Bool(false)}, {Id: aws.String("3"), Code: aws.String("test"), Message: aws.String("test"), SenderFault: aws.Bool(false)}, @@ -241,8 +242,8 @@ func TestSendMessageBatchChecksumFailed(t *testing.T) { } func TestSendMessageBatchChecksumInvalid(t *testing.T) { - req := svc.SendMessageBatchRequest(&sqs.SendMessageBatchInput{ - Entries: []sqs.SendMessageBatchRequestEntry{ + req := svc.SendMessageBatchRequest(&types.SendMessageBatchInput{ + Entries: []types.SendMessageBatchRequestEntry{ {Id: aws.String("1"), MessageBody: aws.String("test")}, {Id: aws.String("2"), MessageBody: aws.String("test")}, {Id: aws.String("3"), MessageBody: aws.String("test")}, @@ -253,8 +254,8 @@ func TestSendMessageBatchChecksumInvalid(t *testing.T) { md5 := "098f6bcd4621d373cade4e832627b4f6" body := ioutil.NopCloser(bytes.NewReader([]byte(""))) r.HTTPResponse = &http.Response{StatusCode: 200, Body: body} - r.Data = &sqs.SendMessageBatchOutput{ - Successful: []sqs.SendMessageBatchResultEntry{ + r.Data = &types.SendMessageBatchOutput{ + Successful: []types.SendMessageBatchResultEntry{ {MD5OfMessageBody: &md5, MessageId: aws.String("123"), Id: aws.String("1")}, {MD5OfMessageBody: aws.String("000"), MessageId: aws.String("456"), Id: aws.String("2")}, {MD5OfMessageBody: aws.String("000"), MessageId: aws.String("789"), Id: aws.String("3")}, diff --git a/service/sqs/api_enums.go b/service/sqs/enums/api_enums.go similarity index 99% rename from service/sqs/api_enums.go rename to service/sqs/enums/api_enums.go index 05a2d943069..70b259c4e24 100644 --- a/service/sqs/api_enums.go +++ b/service/sqs/enums/api_enums.go @@ -1,6 +1,6 @@ // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. -package sqs +package enums type MessageSystemAttributeName string diff --git a/service/sqs/sqsiface/interface.go b/service/sqs/sqsiface/interface.go index c369d7bced1..40a63d39ac5 100644 --- a/service/sqs/sqsiface/interface.go +++ b/service/sqs/sqsiface/interface.go @@ -10,6 +10,7 @@ package sqsiface import ( "github.com/aws/aws-sdk-go-v2/service/sqs" + "github.com/aws/aws-sdk-go-v2/service/sqs/types" ) // ClientAPI provides an interface to enable mocking the @@ -43,7 +44,7 @@ import ( // type mockClientClient struct { // sqsiface.ClientPI // } -// func (m *mockClientClient) AddPermission(input *sqs.AddPermissionInput) (*sqs.AddPermissionOutput, error) { +// func (m *mockClientClient) AddPermission(input *types.AddPermissionInput) (*types.AddPermissionOutput, error) { // // mock response/functionality // } // @@ -61,45 +62,45 @@ import ( // and waiters. Its suggested to use the pattern above for testing, or using // tooling to generate mocks to satisfy the interfaces. type ClientAPI interface { - AddPermissionRequest(*sqs.AddPermissionInput) sqs.AddPermissionRequest + AddPermissionRequest(*types.AddPermissionInput) sqs.AddPermissionRequest - ChangeMessageVisibilityRequest(*sqs.ChangeMessageVisibilityInput) sqs.ChangeMessageVisibilityRequest + ChangeMessageVisibilityRequest(*types.ChangeMessageVisibilityInput) sqs.ChangeMessageVisibilityRequest - ChangeMessageVisibilityBatchRequest(*sqs.ChangeMessageVisibilityBatchInput) sqs.ChangeMessageVisibilityBatchRequest + ChangeMessageVisibilityBatchRequest(*types.ChangeMessageVisibilityBatchInput) sqs.ChangeMessageVisibilityBatchRequest - CreateQueueRequest(*sqs.CreateQueueInput) sqs.CreateQueueRequest + CreateQueueRequest(*types.CreateQueueInput) sqs.CreateQueueRequest - DeleteMessageRequest(*sqs.DeleteMessageInput) sqs.DeleteMessageRequest + DeleteMessageRequest(*types.DeleteMessageInput) sqs.DeleteMessageRequest - DeleteMessageBatchRequest(*sqs.DeleteMessageBatchInput) sqs.DeleteMessageBatchRequest + DeleteMessageBatchRequest(*types.DeleteMessageBatchInput) sqs.DeleteMessageBatchRequest - DeleteQueueRequest(*sqs.DeleteQueueInput) sqs.DeleteQueueRequest + DeleteQueueRequest(*types.DeleteQueueInput) sqs.DeleteQueueRequest - GetQueueAttributesRequest(*sqs.GetQueueAttributesInput) sqs.GetQueueAttributesRequest + GetQueueAttributesRequest(*types.GetQueueAttributesInput) sqs.GetQueueAttributesRequest - GetQueueUrlRequest(*sqs.GetQueueUrlInput) sqs.GetQueueUrlRequest + GetQueueUrlRequest(*types.GetQueueUrlInput) sqs.GetQueueUrlRequest - ListDeadLetterSourceQueuesRequest(*sqs.ListDeadLetterSourceQueuesInput) sqs.ListDeadLetterSourceQueuesRequest + ListDeadLetterSourceQueuesRequest(*types.ListDeadLetterSourceQueuesInput) sqs.ListDeadLetterSourceQueuesRequest - ListQueueTagsRequest(*sqs.ListQueueTagsInput) sqs.ListQueueTagsRequest + ListQueueTagsRequest(*types.ListQueueTagsInput) sqs.ListQueueTagsRequest - ListQueuesRequest(*sqs.ListQueuesInput) sqs.ListQueuesRequest + ListQueuesRequest(*types.ListQueuesInput) sqs.ListQueuesRequest - PurgeQueueRequest(*sqs.PurgeQueueInput) sqs.PurgeQueueRequest + PurgeQueueRequest(*types.PurgeQueueInput) sqs.PurgeQueueRequest - ReceiveMessageRequest(*sqs.ReceiveMessageInput) sqs.ReceiveMessageRequest + ReceiveMessageRequest(*types.ReceiveMessageInput) sqs.ReceiveMessageRequest - RemovePermissionRequest(*sqs.RemovePermissionInput) sqs.RemovePermissionRequest + RemovePermissionRequest(*types.RemovePermissionInput) sqs.RemovePermissionRequest - SendMessageRequest(*sqs.SendMessageInput) sqs.SendMessageRequest + SendMessageRequest(*types.SendMessageInput) sqs.SendMessageRequest - SendMessageBatchRequest(*sqs.SendMessageBatchInput) sqs.SendMessageBatchRequest + SendMessageBatchRequest(*types.SendMessageBatchInput) sqs.SendMessageBatchRequest - SetQueueAttributesRequest(*sqs.SetQueueAttributesInput) sqs.SetQueueAttributesRequest + SetQueueAttributesRequest(*types.SetQueueAttributesInput) sqs.SetQueueAttributesRequest - TagQueueRequest(*sqs.TagQueueInput) sqs.TagQueueRequest + TagQueueRequest(*types.TagQueueInput) sqs.TagQueueRequest - UntagQueueRequest(*sqs.UntagQueueInput) sqs.UntagQueueRequest + UntagQueueRequest(*types.UntagQueueInput) sqs.UntagQueueRequest } var _ ClientAPI = (*sqs.Client)(nil) diff --git a/service/sqs/types/api_op_AddPermission.go b/service/sqs/types/api_op_AddPermission.go new file mode 100644 index 00000000000..5178b7583ac --- /dev/null +++ b/service/sqs/types/api_op_AddPermission.go @@ -0,0 +1,89 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type AddPermissionInput struct { + _ struct{} `type:"structure"` + + // The AWS account number of the principal (https://docs.aws.amazon.com/general/latest/gr/glos-chap.html#P) + // who is given permission. The principal must have an AWS account, but does + // not need to be signed up for Amazon SQS. For information about locating the + // AWS account identification, see Your AWS Identifiers (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-making-api-requests.html#sqs-api-request-authentication) + // in the Amazon Simple Queue Service Developer Guide. + // + // AWSAccountIds is a required field + AWSAccountIds []string `locationNameList:"AWSAccountId" type:"list" flattened:"true" required:"true"` + + // The action the client wants to allow for the specified principal. Valid values: + // the name of any action or *. + // + // For more information about these actions, see Overview of Managing Access + // Permissions to Your Amazon Simple Queue Service Resource (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-overview-of-managing-access.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // Specifying SendMessage, DeleteMessage, or ChangeMessageVisibility for ActionName.n + // also grants permissions for the corresponding batch versions of those actions: + // SendMessageBatch, DeleteMessageBatch, and ChangeMessageVisibilityBatch. + // + // Actions is a required field + Actions []string `locationNameList:"ActionName" type:"list" flattened:"true" required:"true"` + + // The unique identification of the permission you're setting (for example, + // AliceSendMessage). Maximum 80 characters. Allowed characters include alphanumeric + // characters, hyphens (-), and underscores (_). + // + // Label is a required field + Label *string `type:"string" required:"true"` + + // The URL of the Amazon SQS queue to which permissions are added. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s AddPermissionInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *AddPermissionInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "AddPermissionInput"} + + if s.AWSAccountIds == nil { + invalidParams.Add(aws.NewErrParamRequired("AWSAccountIds")) + } + + if s.Actions == nil { + invalidParams.Add(aws.NewErrParamRequired("Actions")) + } + + if s.Label == nil { + invalidParams.Add(aws.NewErrParamRequired("Label")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type AddPermissionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s AddPermissionOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ChangeMessageVisibility.go b/service/sqs/types/api_op_ChangeMessageVisibility.go new file mode 100644 index 00000000000..f30d372bef4 --- /dev/null +++ b/service/sqs/types/api_op_ChangeMessageVisibility.go @@ -0,0 +1,67 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type ChangeMessageVisibilityInput struct { + _ struct{} `type:"structure"` + + // The URL of the Amazon SQS queue whose message's visibility is changed. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` + + // The receipt handle associated with the message whose visibility timeout is + // changed. This parameter is returned by the ReceiveMessage action. + // + // ReceiptHandle is a required field + ReceiptHandle *string `type:"string" required:"true"` + + // The new value for the message's visibility timeout (in seconds). Values values: + // 0 to 43200. Maximum: 12 hours. + // + // VisibilityTimeout is a required field + VisibilityTimeout *int64 `type:"integer" required:"true"` +} + +// String returns the string representation +func (s ChangeMessageVisibilityInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ChangeMessageVisibilityInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "ChangeMessageVisibilityInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if s.ReceiptHandle == nil { + invalidParams.Add(aws.NewErrParamRequired("ReceiptHandle")) + } + + if s.VisibilityTimeout == nil { + invalidParams.Add(aws.NewErrParamRequired("VisibilityTimeout")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type ChangeMessageVisibilityOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s ChangeMessageVisibilityOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ChangeMessageVisibilityBatch.go b/service/sqs/types/api_op_ChangeMessageVisibilityBatch.go new file mode 100644 index 00000000000..383b9c98fbd --- /dev/null +++ b/service/sqs/types/api_op_ChangeMessageVisibilityBatch.go @@ -0,0 +1,79 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type ChangeMessageVisibilityBatchInput struct { + _ struct{} `type:"structure"` + + // A list of receipt handles of the messages for which the visibility timeout + // must be changed. + // + // Entries is a required field + Entries []ChangeMessageVisibilityBatchRequestEntry `locationNameList:"ChangeMessageVisibilityBatchRequestEntry" type:"list" flattened:"true" required:"true"` + + // The URL of the Amazon SQS queue whose messages' visibility is changed. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ChangeMessageVisibilityBatchInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ChangeMessageVisibilityBatchInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "ChangeMessageVisibilityBatchInput"} + + if s.Entries == nil { + invalidParams.Add(aws.NewErrParamRequired("Entries")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + if s.Entries != nil { + for i, v := range s.Entries { + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// For each message in the batch, the response contains a ChangeMessageVisibilityBatchResultEntry +// tag if the message succeeds or a BatchResultErrorEntry tag if the message +// fails. +type ChangeMessageVisibilityBatchOutput struct { + _ struct{} `type:"structure"` + + // A list of BatchResultErrorEntry items. + // + // Failed is a required field + Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` + + // A list of ChangeMessageVisibilityBatchResultEntry items. + // + // Successful is a required field + Successful []ChangeMessageVisibilityBatchResultEntry `locationNameList:"ChangeMessageVisibilityBatchResultEntry" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s ChangeMessageVisibilityBatchOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_CreateQueue.go b/service/sqs/types/api_op_CreateQueue.go new file mode 100644 index 00000000000..c12fdad7553 --- /dev/null +++ b/service/sqs/types/api_op_CreateQueue.go @@ -0,0 +1,178 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type CreateQueueInput struct { + _ struct{} `type:"structure"` + + // A map of attributes with their corresponding values. + // + // The following lists the names, descriptions, and values of the special request + // parameters that the CreateQueue action uses: + // + // * DelaySeconds - The length of time, in seconds, for which the delivery + // of all messages in the queue is delayed. Valid values: An integer from + // 0 to 900 seconds (15 minutes). Default: 0. + // + // * MaximumMessageSize - The limit of how many bytes a message can contain + // before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes + // (1 KiB) to 262,144 bytes (256 KiB). Default: 262,144 (256 KiB). + // + // * MessageRetentionPeriod - The length of time, in seconds, for which Amazon + // SQS retains a message. Valid values: An integer from 60 seconds (1 minute) + // to 1,209,600 seconds (14 days). Default: 345,600 (4 days). + // + // * Policy - The queue's policy. A valid AWS policy. For more information + // about policy structure, see Overview of AWS IAM Policies (https://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html) + // in the Amazon IAM User Guide. + // + // * ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for + // which a ReceiveMessage action waits for a message to arrive. Valid values: + // An integer from 0 to 20 (seconds). Default: 0. + // + // * RedrivePolicy - The string that includes the parameters for the dead-letter + // queue functionality of the source queue. For more information about the + // redrive policy and dead-letter queues, see Using Amazon SQS Dead-Letter + // Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) + // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn + // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon + // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount + // - The number of times a message is delivered to the source queue before + // being moved to the dead-letter queue. When the ReceiveCount for a message + // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message + // to the dead-letter-queue. The dead-letter queue of a FIFO queue must also + // be a FIFO queue. Similarly, the dead-letter queue of a standard queue + // must also be a standard queue. + // + // * VisibilityTimeout - The visibility timeout for the queue, in seconds. + // Valid values: An integer from 0 to 43,200 (12 hours). Default: 30. For + // more information about the visibility timeout, see Visibility Timeout + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): + // + // * KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) + // for Amazon SQS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). + // While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs, + // the alias of a custom CMK can, for example, be alias/MyAlias . For more + // examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) + // in the AWS Key Management Service API Reference. + // + // * KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which + // Amazon SQS can reuse a data key (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys) + // to encrypt or decrypt messages before calling AWS KMS again. An integer + // representing seconds, between 60 seconds (1 minute) and 86,400 seconds + // (24 hours). Default: 300 (5 minutes). A shorter time period provides better + // security but results in more calls to KMS which might incur charges after + // Free Tier. For more information, see How Does the Data Key Reuse Period + // Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). + // + // The following attributes apply only to FIFO (first-in-first-out) queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): + // + // * FifoQueue - Designates a queue as FIFO. Valid values: true, false. If + // you don't specify the FifoQueue attribute, Amazon SQS creates a standard + // queue. You can provide this attribute only during queue creation. You + // can't change it for an existing queue. When you set this attribute, you + // must also provide the MessageGroupId for your messages explicitly. For + // more information, see FIFO Queue Logic (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic) + // in the Amazon Simple Queue Service Developer Guide. + // + // * ContentBasedDeduplication - Enables content-based deduplication. Valid + // values: true, false. For more information, see Exactly-Once Processing + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) + // in the Amazon Simple Queue Service Developer Guide. Every message must + // have a unique MessageDeduplicationId, You may provide a MessageDeduplicationId + // explicitly. If you aren't able to provide a MessageDeduplicationId and + // you enable ContentBasedDeduplication for your queue, Amazon SQS uses a + // SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). If you don't provide + // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication + // set, the action fails with an error. If the queue has ContentBasedDeduplication + // set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication + // is in effect, messages with identical content sent within the deduplication + // interval are treated as duplicates and only one copy of the message is + // delivered. If you send one message with ContentBasedDeduplication enabled + // and then another message with a MessageDeduplicationId that is the same + // as the one generated for the first MessageDeduplicationId, the two messages + // are treated as duplicates and only one copy of the message is delivered. + Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` + + // The name of the new queue. The following limits apply to this name: + // + // * A queue name can have up to 80 characters. + // + // * Valid values: alphanumeric characters, hyphens (-), and underscores + // (_). + // + // * A FIFO queue name must end with the .fifo suffix. + // + // Queue URLs and names are case-sensitive. + // + // QueueName is a required field + QueueName *string `type:"string" required:"true"` + + // Add cost allocation tags to the specified Amazon SQS queue. For an overview, + // see Tagging Your Amazon SQS Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-tags.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // When you use queue tags, keep the following guidelines in mind: + // + // * Adding more than 50 tags to a queue isn't recommended. + // + // * Tags don't have any semantic meaning. Amazon SQS interprets tags as + // character strings. + // + // * Tags are case-sensitive. + // + // * A new tag with a key identical to that of an existing tag overwrites + // the existing tag. + // + // For a full list of tag restrictions, see Limits Related to Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-limits.html#limits-queues) + // in the Amazon Simple Queue Service Developer Guide. + // + // To be able to tag a queue on creation, you must have the sqs:CreateQueue + // and sqs:TagQueue permissions. + // + // Cross-account permissions don't apply to this action. For more information, + // see Grant Cross-Account Permissions to a Role and a User Name (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-customer-managed-policy-examples.html#grant-cross-account-permissions-to-role-and-user-name) + // in the Amazon Simple Queue Service Developer Guide. + Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true"` +} + +// String returns the string representation +func (s CreateQueueInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *CreateQueueInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "CreateQueueInput"} + + if s.QueueName == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// Returns the QueueUrl attribute of the created queue. +type CreateQueueOutput struct { + _ struct{} `type:"structure"` + + // The URL of the created Amazon SQS queue. + QueueUrl *string `type:"string"` +} + +// String returns the string representation +func (s CreateQueueOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_DeleteMessage.go b/service/sqs/types/api_op_DeleteMessage.go new file mode 100644 index 00000000000..9ea6cb01af9 --- /dev/null +++ b/service/sqs/types/api_op_DeleteMessage.go @@ -0,0 +1,56 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type DeleteMessageInput struct { + _ struct{} `type:"structure"` + + // The URL of the Amazon SQS queue from which messages are deleted. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` + + // The receipt handle associated with the message to delete. + // + // ReceiptHandle is a required field + ReceiptHandle *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteMessageInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteMessageInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "DeleteMessageInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if s.ReceiptHandle == nil { + invalidParams.Add(aws.NewErrParamRequired("ReceiptHandle")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type DeleteMessageOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteMessageOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_DeleteMessageBatch.go b/service/sqs/types/api_op_DeleteMessageBatch.go new file mode 100644 index 00000000000..95ae8645724 --- /dev/null +++ b/service/sqs/types/api_op_DeleteMessageBatch.go @@ -0,0 +1,78 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type DeleteMessageBatchInput struct { + _ struct{} `type:"structure"` + + // A list of receipt handles for the messages to be deleted. + // + // Entries is a required field + Entries []DeleteMessageBatchRequestEntry `locationNameList:"DeleteMessageBatchRequestEntry" type:"list" flattened:"true" required:"true"` + + // The URL of the Amazon SQS queue from which messages are deleted. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteMessageBatchInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteMessageBatchInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "DeleteMessageBatchInput"} + + if s.Entries == nil { + invalidParams.Add(aws.NewErrParamRequired("Entries")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + if s.Entries != nil { + for i, v := range s.Entries { + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// For each message in the batch, the response contains a DeleteMessageBatchResultEntry +// tag if the message is deleted or a BatchResultErrorEntry tag if the message +// can't be deleted. +type DeleteMessageBatchOutput struct { + _ struct{} `type:"structure"` + + // A list of BatchResultErrorEntry items. + // + // Failed is a required field + Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` + + // A list of DeleteMessageBatchResultEntry items. + // + // Successful is a required field + Successful []DeleteMessageBatchResultEntry `locationNameList:"DeleteMessageBatchResultEntry" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s DeleteMessageBatchOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_DeleteQueue.go b/service/sqs/types/api_op_DeleteQueue.go new file mode 100644 index 00000000000..8b848e217aa --- /dev/null +++ b/service/sqs/types/api_op_DeleteQueue.go @@ -0,0 +1,47 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type DeleteQueueInput struct { + _ struct{} `type:"structure"` + + // The URL of the Amazon SQS queue to delete. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s DeleteQueueInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *DeleteQueueInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "DeleteQueueInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type DeleteQueueOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s DeleteQueueOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_GetQueueAttributes.go b/service/sqs/types/api_op_GetQueueAttributes.go new file mode 100644 index 00000000000..81a66e7a7bc --- /dev/null +++ b/service/sqs/types/api_op_GetQueueAttributes.go @@ -0,0 +1,138 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/enums" +) + +type GetQueueAttributesInput struct { + _ struct{} `type:"structure"` + + // A list of attributes for which to retrieve information. + // + // In the future, new attributes might be added. If you write code that calls + // this action, we recommend that you structure your code so that it can handle + // new attributes gracefully. + // + // The following attributes are supported: + // + // * All - Returns all values. + // + // * ApproximateNumberOfMessages - Returns the approximate number of messages + // available for retrieval from the queue. + // + // * ApproximateNumberOfMessagesDelayed - Returns the approximate number + // of messages in the queue that are delayed and not available for reading + // immediately. This can happen when the queue is configured as a delay queue + // or when a message has been sent with a delay parameter. + // + // * ApproximateNumberOfMessagesNotVisible - Returns the approximate number + // of messages that are in flight. Messages are considered to be in flight + // if they have been sent to a client but have not yet been deleted or have + // not yet reached the end of their visibility window. + // + // * CreatedTimestamp - Returns the time when the queue was created in seconds + // (epoch time (http://en.wikipedia.org/wiki/Unix_time)). + // + // * DelaySeconds - Returns the default delay on the queue in seconds. + // + // * LastModifiedTimestamp - Returns the time when the queue was last changed + // in seconds (epoch time (http://en.wikipedia.org/wiki/Unix_time)). + // + // * MaximumMessageSize - Returns the limit of how many bytes a message can + // contain before Amazon SQS rejects it. + // + // * MessageRetentionPeriod - Returns the length of time, in seconds, for + // which Amazon SQS retains a message. + // + // * Policy - Returns the policy of the queue. + // + // * QueueArn - Returns the Amazon resource name (ARN) of the queue. + // + // * ReceiveMessageWaitTimeSeconds - Returns the length of time, in seconds, + // for which the ReceiveMessage action waits for a message to arrive. + // + // * RedrivePolicy - Returns the string that includes the parameters for + // dead-letter queue functionality of the source queue. For more information + // about the redrive policy and dead-letter queues, see Using Amazon SQS + // Dead-Letter Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) + // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn + // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon + // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount + // - The number of times a message is delivered to the source queue before + // being moved to the dead-letter queue. When the ReceiveCount for a message + // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message + // to the dead-letter-queue. + // + // * VisibilityTimeout - Returns the visibility timeout for the queue. For + // more information about the visibility timeout, see Visibility Timeout + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): + // + // * KmsMasterKeyId - Returns the ID of an AWS-managed customer master key + // (CMK) for Amazon SQS or a custom CMK. For more information, see Key Terms + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). + // + // * KmsDataKeyReusePeriodSeconds - Returns the length of time, in seconds, + // for which Amazon SQS can reuse a data key to encrypt or decrypt messages + // before calling AWS KMS again. For more information, see How Does the Data + // Key Reuse Period Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). + // + // The following attributes apply only to FIFO (first-in-first-out) queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): + // + // * FifoQueue - Returns whether the queue is FIFO. For more information, + // see FIFO Queue Logic (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-understanding-logic) + // in the Amazon Simple Queue Service Developer Guide. To determine whether + // a queue is FIFO (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html), + // you can check whether QueueName ends with the .fifo suffix. + // + // * ContentBasedDeduplication - Returns whether content-based deduplication + // is enabled for the queue. For more information, see Exactly-Once Processing + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) + // in the Amazon Simple Queue Service Developer Guide. + AttributeNames []enums.QueueAttributeName `locationNameList:"AttributeName" type:"list" flattened:"true"` + + // The URL of the Amazon SQS queue whose attribute information is retrieved. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s GetQueueAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetQueueAttributesInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "GetQueueAttributesInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// A list of returned queue attributes. +type GetQueueAttributesOutput struct { + _ struct{} `type:"structure"` + + // A map of attributes to their respective values. + Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` +} + +// String returns the string representation +func (s GetQueueAttributesOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_GetQueueUrl.go b/service/sqs/types/api_op_GetQueueUrl.go new file mode 100644 index 00000000000..c95d948eb6e --- /dev/null +++ b/service/sqs/types/api_op_GetQueueUrl.go @@ -0,0 +1,56 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type GetQueueUrlInput struct { + _ struct{} `type:"structure"` + + // The name of the queue whose URL must be fetched. Maximum 80 characters. Valid + // values: alphanumeric characters, hyphens (-), and underscores (_). + // + // Queue URLs and names are case-sensitive. + // + // QueueName is a required field + QueueName *string `type:"string" required:"true"` + + // The AWS account ID of the account that created the queue. + QueueOwnerAWSAccountId *string `type:"string"` +} + +// String returns the string representation +func (s GetQueueUrlInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *GetQueueUrlInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "GetQueueUrlInput"} + + if s.QueueName == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueName")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// For more information, see Interpreting Responses (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-api-responses.html) +// in the Amazon Simple Queue Service Developer Guide. +type GetQueueUrlOutput struct { + _ struct{} `type:"structure"` + + // The URL of the queue. + QueueUrl *string `type:"string"` +} + +// String returns the string representation +func (s GetQueueUrlOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ListDeadLetterSourceQueues.go b/service/sqs/types/api_op_ListDeadLetterSourceQueues.go new file mode 100644 index 00000000000..9ea99c22bf9 --- /dev/null +++ b/service/sqs/types/api_op_ListDeadLetterSourceQueues.go @@ -0,0 +1,54 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type ListDeadLetterSourceQueuesInput struct { + _ struct{} `type:"structure"` + + // The URL of a dead-letter queue. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ListDeadLetterSourceQueuesInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListDeadLetterSourceQueuesInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "ListDeadLetterSourceQueuesInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// A list of your dead letter source queues. +type ListDeadLetterSourceQueuesOutput struct { + _ struct{} `type:"structure"` + + // A list of source queue URLs that have the RedrivePolicy queue attribute configured + // with a dead-letter queue. + // + // QueueUrls is a required field + QueueUrls []string `locationName:"queueUrls" locationNameList:"QueueUrl" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s ListDeadLetterSourceQueuesOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ListQueueTags.go b/service/sqs/types/api_op_ListQueueTags.go new file mode 100644 index 00000000000..50a37998b5a --- /dev/null +++ b/service/sqs/types/api_op_ListQueueTags.go @@ -0,0 +1,48 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type ListQueueTagsInput struct { + _ struct{} `type:"structure"` + + // The URL of the queue. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s ListQueueTagsInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ListQueueTagsInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "ListQueueTagsInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type ListQueueTagsOutput struct { + _ struct{} `type:"structure"` + + // The list of all tags added to the specified queue. + Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true"` +} + +// String returns the string representation +func (s ListQueueTagsOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ListQueues.go b/service/sqs/types/api_op_ListQueues.go new file mode 100644 index 00000000000..b33d0099089 --- /dev/null +++ b/service/sqs/types/api_op_ListQueues.go @@ -0,0 +1,35 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type ListQueuesInput struct { + _ struct{} `type:"structure"` + + // A string to use for filtering the list results. Only those queues whose name + // begins with the specified string are returned. + // + // Queue URLs and names are case-sensitive. + QueueNamePrefix *string `type:"string"` +} + +// String returns the string representation +func (s ListQueuesInput) String() string { + return awsutil.Prettify(s) +} + +// A list of your queues. +type ListQueuesOutput struct { + _ struct{} `type:"structure"` + + // A list of queue URLs, up to 1,000 entries. + QueueUrls []string `locationNameList:"QueueUrl" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s ListQueuesOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_PurgeQueue.go b/service/sqs/types/api_op_PurgeQueue.go new file mode 100644 index 00000000000..8f1bc991c78 --- /dev/null +++ b/service/sqs/types/api_op_PurgeQueue.go @@ -0,0 +1,47 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type PurgeQueueInput struct { + _ struct{} `type:"structure"` + + // The URL of the queue from which the PurgeQueue action deletes messages. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s PurgeQueueInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *PurgeQueueInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "PurgeQueueInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type PurgeQueueOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s PurgeQueueOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_ReceiveMessage.go b/service/sqs/types/api_op_ReceiveMessage.go new file mode 100644 index 00000000000..a96301f13d8 --- /dev/null +++ b/service/sqs/types/api_op_ReceiveMessage.go @@ -0,0 +1,171 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" + "github.com/aws/aws-sdk-go-v2/service/sqs/enums" +) + +type ReceiveMessageInput struct { + _ struct{} `type:"structure"` + + // A list of attributes that need to be returned along with each message. These + // attributes include: + // + // * All - Returns all values. + // + // * ApproximateFirstReceiveTimestamp - Returns the time the message was + // first received from the queue (epoch time (http://en.wikipedia.org/wiki/Unix_time) + // in milliseconds). + // + // * ApproximateReceiveCount - Returns the number of times a message has + // been received from the queue but not deleted. + // + // * AWSTraceHeader - Returns the AWS X-Ray trace header string. + // + // * SenderId For an IAM user, returns the IAM user ID, for example ABCDEFGHI1JKLMNOPQ23R. + // For an IAM role, returns the IAM role ID, for example ABCDE1F2GH3I4JK5LMNOP:i-a123b456. + // + // * SentTimestamp - Returns the time the message was sent to the queue (epoch + // time (http://en.wikipedia.org/wiki/Unix_time) in milliseconds). + // + // * MessageDeduplicationId - Returns the value provided by the producer + // that calls the SendMessage action. + // + // * MessageGroupId - Returns the value provided by the producer that calls + // the SendMessage action. Messages with the same MessageGroupId are returned + // in sequence. + // + // * SequenceNumber - Returns the value provided by Amazon SQS. + AttributeNames []enums.QueueAttributeName `locationNameList:"AttributeName" type:"list" flattened:"true"` + + // The maximum number of messages to return. Amazon SQS never returns more messages + // than this value (however, fewer messages might be returned). Valid values: + // 1 to 10. Default: 1. + MaxNumberOfMessages *int64 `type:"integer"` + + // The name of the message attribute, where N is the index. + // + // * The name can contain alphanumeric characters and the underscore (_), + // hyphen (-), and period (.). + // + // * The name is case-sensitive and must be unique among all attribute names + // for the message. + // + // * The name must not start with AWS-reserved prefixes such as AWS. or Amazon. + // (or any casing variants). + // + // * The name must not start or end with a period (.), and it should not + // have periods in succession (..). + // + // * The name can be up to 256 characters long. + // + // When using ReceiveMessage, you can send a list of attribute names to receive, + // or you can return all of the attributes by specifying All or .* in your request. + // You can also use all message attributes starting with a prefix, for example + // bar.*. + MessageAttributeNames []string `locationNameList:"MessageAttributeName" type:"list" flattened:"true"` + + // The URL of the Amazon SQS queue from which messages are received. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` + + // This parameter applies only to FIFO (first-in-first-out) queues. + // + // The token used for deduplication of ReceiveMessage calls. If a networking + // issue occurs after a ReceiveMessage action, and instead of a response you + // receive a generic error, you can retry the same action with an identical + // ReceiveRequestAttemptId to retrieve the same set of messages, even if their + // visibility timeout has not yet expired. + // + // * You can use ReceiveRequestAttemptId only for 5 minutes after a ReceiveMessage + // action. + // + // * When you set FifoQueue, a caller of the ReceiveMessage action can provide + // a ReceiveRequestAttemptId explicitly. + // + // * If a caller of the ReceiveMessage action doesn't provide a ReceiveRequestAttemptId, + // Amazon SQS generates a ReceiveRequestAttemptId. + // + // * You can retry the ReceiveMessage action with the same ReceiveRequestAttemptId + // if none of the messages have been modified (deleted or had their visibility + // changes). + // + // * During a visibility timeout, subsequent calls with the same ReceiveRequestAttemptId + // return the same messages and receipt handles. If a retry occurs within + // the deduplication interval, it resets the visibility timeout. For more + // information, see Visibility Timeout (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) + // in the Amazon Simple Queue Service Developer Guide. If a caller of the + // ReceiveMessage action still processes messages when the visibility timeout + // expires and messages become visible, another worker consuming from the + // same queue can receive the same messages and therefore process duplicates. + // Also, if a consumer whose message processing time is longer than the visibility + // timeout tries to delete the processed messages, the action fails with + // an error. To mitigate this effect, ensure that your application observes + // a safe threshold before the visibility timeout expires and extend the + // visibility timeout as necessary. + // + // * While messages with a particular MessageGroupId are invisible, no more + // messages belonging to the same MessageGroupId are returned until the visibility + // timeout expires. You can still receive messages with another MessageGroupId + // as long as it is also visible. + // + // * If a caller of ReceiveMessage can't track the ReceiveRequestAttemptId, + // no retries work until the original visibility timeout expires. As a result, + // delays might occur but the messages in the queue remain in a strict order. + // + // The length of ReceiveRequestAttemptId is 128 characters. ReceiveRequestAttemptId + // can contain alphanumeric characters (a-z, A-Z, 0-9) and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). + // + // For best practices of using ReceiveRequestAttemptId, see Using the ReceiveRequestAttemptId + // Request Parameter (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-receiverequestattemptid-request-parameter.html) + // in the Amazon Simple Queue Service Developer Guide. + ReceiveRequestAttemptId *string `type:"string"` + + // The duration (in seconds) that the received messages are hidden from subsequent + // retrieve requests after being retrieved by a ReceiveMessage request. + VisibilityTimeout *int64 `type:"integer"` + + // The duration (in seconds) for which the call waits for a message to arrive + // in the queue before returning. If a message is available, the call returns + // sooner than WaitTimeSeconds. If no messages are available and the wait time + // expires, the call returns successfully with an empty list of messages. + WaitTimeSeconds *int64 `type:"integer"` +} + +// String returns the string representation +func (s ReceiveMessageInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *ReceiveMessageInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "ReceiveMessageInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// A list of received messages. +type ReceiveMessageOutput struct { + _ struct{} `type:"structure"` + + // A list of messages. + Messages []Message `locationNameList:"Message" type:"list" flattened:"true"` +} + +// String returns the string representation +func (s ReceiveMessageOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_RemovePermission.go b/service/sqs/types/api_op_RemovePermission.go new file mode 100644 index 00000000000..11bb3dd2f45 --- /dev/null +++ b/service/sqs/types/api_op_RemovePermission.go @@ -0,0 +1,57 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type RemovePermissionInput struct { + _ struct{} `type:"structure"` + + // The identification of the permission to remove. This is the label added using + // the AddPermission action. + // + // Label is a required field + Label *string `type:"string" required:"true"` + + // The URL of the Amazon SQS queue from which permissions are removed. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s RemovePermissionInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *RemovePermissionInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "RemovePermissionInput"} + + if s.Label == nil { + invalidParams.Add(aws.NewErrParamRequired("Label")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type RemovePermissionOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s RemovePermissionOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_SendMessage.go b/service/sqs/types/api_op_SendMessage.go new file mode 100644 index 00000000000..64b0a50dd7a --- /dev/null +++ b/service/sqs/types/api_op_SendMessage.go @@ -0,0 +1,209 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type SendMessageInput struct { + _ struct{} `type:"structure"` + + // The length of time, in seconds, for which to delay a specific message. Valid + // values: 0 to 900. Maximum: 15 minutes. Messages with a positive DelaySeconds + // value become available for processing after the delay period is finished. + // If you don't specify a value, the default value for the queue applies. + // + // When you set FifoQueue, you can't set DelaySeconds per message. You can set + // this parameter only on a queue level. + DelaySeconds *int64 `type:"integer"` + + // Each message attribute consists of a Name, Type, and Value. For more information, + // see Amazon SQS Message Attributes (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-message-attributes.html) + // in the Amazon Simple Queue Service Developer Guide. + MessageAttributes map[string]MessageAttributeValue `locationName:"MessageAttribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` + + // The message to send. The maximum string size is 256 KB. + // + // A message can include only XML, JSON, and unformatted text. The following + // Unicode characters are allowed: + // + // #x9 | #xA | #xD | #x20 to #xD7FF | #xE000 to #xFFFD | #x10000 to #x10FFFF + // + // Any characters not included in this list will be rejected. For more information, + // see the W3C specification for characters (http://www.w3.org/TR/REC-xml/#charsets). + // + // MessageBody is a required field + MessageBody *string `type:"string" required:"true"` + + // This parameter applies only to FIFO (first-in-first-out) queues. + // + // The token used for deduplication of sent messages. If a message with a particular + // MessageDeduplicationId is sent successfully, any messages sent with the same + // MessageDeduplicationId are accepted successfully but aren't delivered during + // the 5-minute deduplication interval. For more information, see Exactly-Once + // Processing (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) + // in the Amazon Simple Queue Service Developer Guide. + // + // * Every message must have a unique MessageDeduplicationId, You may provide + // a MessageDeduplicationId explicitly. If you aren't able to provide a MessageDeduplicationId + // and you enable ContentBasedDeduplication for your queue, Amazon SQS uses + // a SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). If you don't provide + // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication + // set, the action fails with an error. If the queue has ContentBasedDeduplication + // set, your MessageDeduplicationId overrides the generated one. + // + // * When ContentBasedDeduplication is in effect, messages with identical + // content sent within the deduplication interval are treated as duplicates + // and only one copy of the message is delivered. + // + // * If you send one message with ContentBasedDeduplication enabled and then + // another message with a MessageDeduplicationId that is the same as the + // one generated for the first MessageDeduplicationId, the two messages are + // treated as duplicates and only one copy of the message is delivered. + // + // The MessageDeduplicationId is available to the consumer of the message (this + // can be useful for troubleshooting delivery issues). + // + // If a message is sent successfully but the acknowledgement is lost and the + // message is resent with the same MessageDeduplicationId after the deduplication + // interval, Amazon SQS can't detect duplicate messages. + // + // Amazon SQS continues to keep track of the message deduplication ID even after + // the message is received and deleted. + // + // The length of MessageDeduplicationId is 128 characters. MessageDeduplicationId + // can contain alphanumeric characters (a-z, A-Z, 0-9) and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). + // + // For best practices of using MessageDeduplicationId, see Using the MessageDeduplicationId + // Property (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagededuplicationid-property.html) + // in the Amazon Simple Queue Service Developer Guide. + MessageDeduplicationId *string `type:"string"` + + // This parameter applies only to FIFO (first-in-first-out) queues. + // + // The tag that specifies that a message belongs to a specific message group. + // Messages that belong to the same message group are processed in a FIFO manner + // (however, messages in different message groups might be processed out of + // order). To interleave multiple ordered streams within a single queue, use + // MessageGroupId values (for example, session data for multiple users). In + // this scenario, multiple consumers can process the queue, but the session + // data of each user is processed in a FIFO fashion. + // + // * You must associate a non-empty MessageGroupId with a message. If you + // don't provide a MessageGroupId, the action fails. + // + // * ReceiveMessage might return messages with multiple MessageGroupId values. + // For each MessageGroupId, the messages are sorted by time sent. The caller + // can't specify a MessageGroupId. + // + // The length of MessageGroupId is 128 characters. Valid values: alphanumeric + // characters and punctuation (!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~). + // + // For best practices of using MessageGroupId, see Using the MessageGroupId + // Property (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/using-messagegroupid-property.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // MessageGroupId is required for FIFO queues. You can't use it for Standard + // queues. + MessageGroupId *string `type:"string"` + + // The message system attribute to send. Each message system attribute consists + // of a Name, Type, and Value. + // + // * Currently, the only supported message system attribute is AWSTraceHeader. + // Its type must be String and its value must be a correctly formatted AWS + // X-Ray trace string. + // + // * The size of a message system attribute doesn't count towards the total + // size of a message. + MessageSystemAttributes map[string]MessageSystemAttributeValue `locationName:"MessageSystemAttribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true"` + + // The URL of the Amazon SQS queue to which a message is sent. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SendMessageInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SendMessageInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "SendMessageInput"} + + if s.MessageBody == nil { + invalidParams.Add(aws.NewErrParamRequired("MessageBody")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + if s.MessageAttributes != nil { + for i, v := range s.MessageAttributes { + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "MessageAttributes", i), err.(aws.ErrInvalidParams)) + } + } + } + if s.MessageSystemAttributes != nil { + for i, v := range s.MessageSystemAttributes { + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "MessageSystemAttributes", i), err.(aws.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// The MD5OfMessageBody and MessageId elements. +type SendMessageOutput struct { + _ struct{} `type:"structure"` + + // An MD5 digest of the non-URL-encoded message attribute string. You can use + // this attribute to verify that Amazon SQS received the message correctly. + // Amazon SQS URL-decodes the message before creating the MD5 digest. For information + // about MD5, see RFC1321 (https://www.ietf.org/rfc/rfc1321.txt). + MD5OfMessageAttributes *string `type:"string"` + + // An MD5 digest of the non-URL-encoded message attribute string. You can use + // this attribute to verify that Amazon SQS received the message correctly. + // Amazon SQS URL-decodes the message before creating the MD5 digest. For information + // about MD5, see RFC1321 (https://www.ietf.org/rfc/rfc1321.txt). + MD5OfMessageBody *string `type:"string"` + + // An MD5 digest of the non-URL-encoded message system attribute string. You + // can use this attribute to verify that Amazon SQS received the message correctly. + // Amazon SQS URL-decodes the message before creating the MD5 digest. + MD5OfMessageSystemAttributes *string `type:"string"` + + // An attribute containing the MessageId of the message sent to the queue. For + // more information, see Queue and Message Identifiers (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-queue-message-identifiers.html) + // in the Amazon Simple Queue Service Developer Guide. + MessageId *string `type:"string"` + + // This parameter applies only to FIFO (first-in-first-out) queues. + // + // The large, non-consecutive number that Amazon SQS assigns to each message. + // + // The length of SequenceNumber is 128 bits. SequenceNumber continues to increase + // for a particular MessageGroupId. + SequenceNumber *string `type:"string"` +} + +// String returns the string representation +func (s SendMessageOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_SendMessageBatch.go b/service/sqs/types/api_op_SendMessageBatch.go new file mode 100644 index 00000000000..1a8ee84fb07 --- /dev/null +++ b/service/sqs/types/api_op_SendMessageBatch.go @@ -0,0 +1,79 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "fmt" + + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type SendMessageBatchInput struct { + _ struct{} `type:"structure"` + + // A list of SendMessageBatchRequestEntry items. + // + // Entries is a required field + Entries []SendMessageBatchRequestEntry `locationNameList:"SendMessageBatchRequestEntry" type:"list" flattened:"true" required:"true"` + + // The URL of the Amazon SQS queue to which batched messages are sent. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SendMessageBatchInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SendMessageBatchInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "SendMessageBatchInput"} + + if s.Entries == nil { + invalidParams.Add(aws.NewErrParamRequired("Entries")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + if s.Entries != nil { + for i, v := range s.Entries { + if err := v.Validate(); err != nil { + invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Entries", i), err.(aws.ErrInvalidParams)) + } + } + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +// For each message in the batch, the response contains a SendMessageBatchResultEntry +// tag if the message succeeds or a BatchResultErrorEntry tag if the message +// fails. +type SendMessageBatchOutput struct { + _ struct{} `type:"structure"` + + // A list of BatchResultErrorEntry items with error details about each message + // that can't be enqueued. + // + // Failed is a required field + Failed []BatchResultErrorEntry `locationNameList:"BatchResultErrorEntry" type:"list" flattened:"true" required:"true"` + + // A list of SendMessageBatchResultEntry items. + // + // Successful is a required field + Successful []SendMessageBatchResultEntry `locationNameList:"SendMessageBatchResultEntry" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s SendMessageBatchOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_SetQueueAttributes.go b/service/sqs/types/api_op_SetQueueAttributes.go new file mode 100644 index 00000000000..7ba5172cd77 --- /dev/null +++ b/service/sqs/types/api_op_SetQueueAttributes.go @@ -0,0 +1,138 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type SetQueueAttributesInput struct { + _ struct{} `type:"structure"` + + // A map of attributes to set. + // + // The following lists the names, descriptions, and values of the special request + // parameters that the SetQueueAttributes action uses: + // + // * DelaySeconds - The length of time, in seconds, for which the delivery + // of all messages in the queue is delayed. Valid values: An integer from + // 0 to 900 (15 minutes). Default: 0. + // + // * MaximumMessageSize - The limit of how many bytes a message can contain + // before Amazon SQS rejects it. Valid values: An integer from 1,024 bytes + // (1 KiB) up to 262,144 bytes (256 KiB). Default: 262,144 (256 KiB). + // + // * MessageRetentionPeriod - The length of time, in seconds, for which Amazon + // SQS retains a message. Valid values: An integer representing seconds, + // from 60 (1 minute) to 1,209,600 (14 days). Default: 345,600 (4 days). + // + // * Policy - The queue's policy. A valid AWS policy. For more information + // about policy structure, see Overview of AWS IAM Policies (https://docs.aws.amazon.com/IAM/latest/UserGuide/PoliciesOverview.html) + // in the Amazon IAM User Guide. + // + // * ReceiveMessageWaitTimeSeconds - The length of time, in seconds, for + // which a ReceiveMessage action waits for a message to arrive. Valid values: + // an integer from 0 to 20 (seconds). Default: 0. + // + // * RedrivePolicy - The string that includes the parameters for the dead-letter + // queue functionality of the source queue. For more information about the + // redrive policy and dead-letter queues, see Using Amazon SQS Dead-Letter + // Queues (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-dead-letter-queues.html) + // in the Amazon Simple Queue Service Developer Guide. deadLetterTargetArn + // - The Amazon Resource Name (ARN) of the dead-letter queue to which Amazon + // SQS moves messages after the value of maxReceiveCount is exceeded. maxReceiveCount + // - The number of times a message is delivered to the source queue before + // being moved to the dead-letter queue. When the ReceiveCount for a message + // exceeds the maxReceiveCount for a queue, Amazon SQS moves the message + // to the dead-letter-queue. The dead-letter queue of a FIFO queue must also + // be a FIFO queue. Similarly, the dead-letter queue of a standard queue + // must also be a standard queue. + // + // * VisibilityTimeout - The visibility timeout for the queue, in seconds. + // Valid values: an integer from 0 to 43,200 (12 hours). Default: 30. For + // more information about the visibility timeout, see Visibility Timeout + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-visibility-timeout.html) + // in the Amazon Simple Queue Service Developer Guide. + // + // The following attributes apply only to server-side-encryption (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html): + // + // * KmsMasterKeyId - The ID of an AWS-managed customer master key (CMK) + // for Amazon SQS or a custom CMK. For more information, see Key Terms (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-sse-key-terms). + // While the alias of the AWS-managed CMK for Amazon SQS is always alias/aws/sqs, + // the alias of a custom CMK can, for example, be alias/MyAlias . For more + // examples, see KeyId (https://docs.aws.amazon.com/kms/latest/APIReference/API_DescribeKey.html#API_DescribeKey_RequestParameters) + // in the AWS Key Management Service API Reference. + // + // * KmsDataKeyReusePeriodSeconds - The length of time, in seconds, for which + // Amazon SQS can reuse a data key (https://docs.aws.amazon.com/kms/latest/developerguide/concepts.html#data-keys) + // to encrypt or decrypt messages before calling AWS KMS again. An integer + // representing seconds, between 60 seconds (1 minute) and 86,400 seconds + // (24 hours). Default: 300 (5 minutes). A shorter time period provides better + // security but results in more calls to KMS which might incur charges after + // Free Tier. For more information, see How Does the Data Key Reuse Period + // Work? (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/sqs-server-side-encryption.html#sqs-how-does-the-data-key-reuse-period-work). + // + // The following attribute applies only to FIFO (first-in-first-out) queues + // (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html): + // + // * ContentBasedDeduplication - Enables content-based deduplication. For + // more information, see Exactly-Once Processing (https://docs.aws.amazon.com/AWSSimpleQueueService/latest/SQSDeveloperGuide/FIFO-queues.html#FIFO-queues-exactly-once-processing) + // in the Amazon Simple Queue Service Developer Guide. Every message must + // have a unique MessageDeduplicationId, You may provide a MessageDeduplicationId + // explicitly. If you aren't able to provide a MessageDeduplicationId and + // you enable ContentBasedDeduplication for your queue, Amazon SQS uses a + // SHA-256 hash to generate the MessageDeduplicationId using the body of + // the message (but not the attributes of the message). If you don't provide + // a MessageDeduplicationId and the queue doesn't have ContentBasedDeduplication + // set, the action fails with an error. If the queue has ContentBasedDeduplication + // set, your MessageDeduplicationId overrides the generated one. When ContentBasedDeduplication + // is in effect, messages with identical content sent within the deduplication + // interval are treated as duplicates and only one copy of the message is + // delivered. If you send one message with ContentBasedDeduplication enabled + // and then another message with a MessageDeduplicationId that is the same + // as the one generated for the first MessageDeduplicationId, the two messages + // are treated as duplicates and only one copy of the message is delivered. + // + // Attributes is a required field + Attributes map[string]string `locationName:"Attribute" locationNameKey:"Name" locationNameValue:"Value" type:"map" flattened:"true" required:"true"` + + // The URL of the Amazon SQS queue whose attributes are set. + // + // Queue URLs and names are case-sensitive. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` +} + +// String returns the string representation +func (s SetQueueAttributesInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *SetQueueAttributesInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "SetQueueAttributesInput"} + + if s.Attributes == nil { + invalidParams.Add(aws.NewErrParamRequired("Attributes")) + } + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type SetQueueAttributesOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s SetQueueAttributesOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_TagQueue.go b/service/sqs/types/api_op_TagQueue.go new file mode 100644 index 00000000000..b13609e5562 --- /dev/null +++ b/service/sqs/types/api_op_TagQueue.go @@ -0,0 +1,54 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type TagQueueInput struct { + _ struct{} `type:"structure"` + + // The URL of the queue. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` + + // The list of tags to be added to the specified queue. + // + // Tags is a required field + Tags map[string]string `locationName:"Tag" locationNameKey:"Key" locationNameValue:"Value" type:"map" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s TagQueueInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *TagQueueInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "TagQueueInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if s.Tags == nil { + invalidParams.Add(aws.NewErrParamRequired("Tags")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type TagQueueOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s TagQueueOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/types/api_op_UntagQueue.go b/service/sqs/types/api_op_UntagQueue.go new file mode 100644 index 00000000000..0f99b920fed --- /dev/null +++ b/service/sqs/types/api_op_UntagQueue.go @@ -0,0 +1,54 @@ +// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. + +package types + +import ( + "github.com/aws/aws-sdk-go-v2/aws" + "github.com/aws/aws-sdk-go-v2/internal/awsutil" +) + +type UntagQueueInput struct { + _ struct{} `type:"structure"` + + // The URL of the queue. + // + // QueueUrl is a required field + QueueUrl *string `type:"string" required:"true"` + + // The list of tags to be removed from the specified queue. + // + // TagKeys is a required field + TagKeys []string `locationNameList:"TagKey" type:"list" flattened:"true" required:"true"` +} + +// String returns the string representation +func (s UntagQueueInput) String() string { + return awsutil.Prettify(s) +} + +// Validate inspects the fields of the type to determine if they are valid. +func (s *UntagQueueInput) Validate() error { + invalidParams := aws.ErrInvalidParams{Context: "UntagQueueInput"} + + if s.QueueUrl == nil { + invalidParams.Add(aws.NewErrParamRequired("QueueUrl")) + } + + if s.TagKeys == nil { + invalidParams.Add(aws.NewErrParamRequired("TagKeys")) + } + + if invalidParams.Len() > 0 { + return invalidParams + } + return nil +} + +type UntagQueueOutput struct { + _ struct{} `type:"structure"` +} + +// String returns the string representation +func (s UntagQueueOutput) String() string { + return awsutil.Prettify(s) +} diff --git a/service/sqs/api_types.go b/service/sqs/types/api_types.go similarity index 99% rename from service/sqs/api_types.go rename to service/sqs/types/api_types.go index 215765157d7..1d261ab8a0e 100644 --- a/service/sqs/api_types.go +++ b/service/sqs/types/api_types.go @@ -1,6 +1,6 @@ // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT. -package sqs +package types import ( "fmt" @@ -9,9 +9,6 @@ import ( "github.com/aws/aws-sdk-go-v2/internal/awsutil" ) -var _ aws.Config -var _ = awsutil.Prettify - // Gives a detailed description of the result of an action on each entry in // the request. type BatchResultErrorEntry struct { diff --git a/service/sts/customizations_test.go b/service/sts/customizations_test.go index 6e57dfcc2ea..8ca49babe53 100644 --- a/service/sts/customizations_test.go +++ b/service/sts/customizations_test.go @@ -13,6 +13,7 @@ import ( "github.com/aws/aws-sdk-go-v2/aws/endpoints" "github.com/aws/aws-sdk-go-v2/internal/awstesting/unit" "github.com/aws/aws-sdk-go-v2/service/sts" + "github.com/aws/aws-sdk-go-v2/service/sts/types" ) func init() { @@ -25,7 +26,7 @@ func init() { var svc *sts.Client func TestUnsignedRequest_AssumeRoleWithSAML(t *testing.T) { - req := svc.AssumeRoleWithSAMLRequest(&sts.AssumeRoleWithSAMLInput{ + req := svc.AssumeRoleWithSAMLRequest(&types.AssumeRoleWithSAMLInput{ PrincipalArn: aws.String("ARN01234567890123456789"), RoleArn: aws.String("ARN01234567890123456789"), SAMLAssertion: aws.String("ASSERT"), @@ -41,7 +42,7 @@ func TestUnsignedRequest_AssumeRoleWithSAML(t *testing.T) { } func TestUnsignedRequest_AssumeRoleWithWebIdentity(t *testing.T) { - req := svc.AssumeRoleWithWebIdentityRequest(&sts.AssumeRoleWithWebIdentityInput{ + req := svc.AssumeRoleWithWebIdentityRequest(&types.AssumeRoleWithWebIdentityInput{ RoleArn: aws.String("ARN01234567890123456789"), RoleSessionName: aws.String("SESSION"), WebIdentityToken: aws.String("TOKEN"), @@ -82,7 +83,7 @@ func TestSTSCustomRetryErrorCodes(t *testing.T) { }, } - req := svc.AssumeRoleWithWebIdentityRequest(&sts.AssumeRoleWithWebIdentityInput{}) + req := svc.AssumeRoleWithWebIdentityRequest(&types.AssumeRoleWithWebIdentityInput{}) req.Handlers.Send.Swap(defaults.SendHandler.Name, aws.NamedHandler{ Name: "custom send handler", Fn: func(r *aws.Request) {