Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

service: Adds prototyped operations from APIGateWay and S3 service that uses rest encoder utility #452

Closed
wants to merge 13 commits into from
Closed
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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:
9 changes: 5 additions & 4 deletions aws/defaults/handlers_test.go
Original file line number Diff line number Diff line change
@@ -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"),
})
5 changes: 3 additions & 2 deletions aws/defaults/param_validator_test.go
Original file line number Diff line number Diff line change
@@ -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"),
}
6 changes: 4 additions & 2 deletions aws/example_test.go
Original file line number Diff line number Diff line change
@@ -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())
12 changes: 7 additions & 5 deletions aws/signer/v4/functional_test.go
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 3 additions & 2 deletions aws/stscreds/provider.go
Original file line number Diff line number Diff line change
@@ -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),
17 changes: 9 additions & 8 deletions aws/stscreds/provider_test.go
Original file line number Diff line number Diff line change
@@ -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")
},
}
11 changes: 7 additions & 4 deletions example/aws/endpoints/customEndpoint/customEndpoint.go
Original file line number Diff line number Diff line change
@@ -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())
}
Original file line number Diff line number Diff line change
@@ -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]),
})
3 changes: 2 additions & 1 deletion example/aws/request/withContext/withContext.go
Original file line number Diff line number Diff line change
@@ -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,
5 changes: 3 additions & 2 deletions example/service/dynamodb/expression/scan.go
Original file line number Diff line number Diff line change
@@ -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
7 changes: 4 additions & 3 deletions example/service/dynamodb/scanItems/scanItems.go
Original file line number Diff line number Diff line change
@@ -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
Loading