Skip to content

Commit

Permalink
Merge pull request #4597 from eddy-aws/main
Browse files Browse the repository at this point in the history
Add awsQueryCompatible error code translation support
  • Loading branch information
isaiahvita committed Dec 28, 2022
2 parents 5ce492c + 3f9c4f2 commit 698f054
Show file tree
Hide file tree
Showing 11 changed files with 812 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changelog/6b25cc1a38cf4e229728e8e169b9152b.json
@@ -0,0 +1,8 @@
{
"id": "6b25cc1a-38cf-4e22-9728-e8e169b9152b",
"type": "feature",
"description": "Add awsQueryCompatible error code translation support",
"modules": [
"."
]
}
14 changes: 14 additions & 0 deletions private/model/api/api.go
Expand Up @@ -96,8 +96,11 @@ type Metadata struct {
ServiceID string

NoResolveEndpoint bool
AWSQueryCompatible *awsQueryCompatible
}

type awsQueryCompatible struct {}

// ProtocolSettings define how the SDK should handle requests in the context
// of of a protocol.
type ProtocolSettings struct {
Expand Down Expand Up @@ -639,7 +642,11 @@ func newClient(cfg aws.Config, handlers request.Handlers, partitionID, endpoint,
{{- if and $.WithGeneratedTypedErrors (gt (len $.ShapeListErrors) 0) }}
{{- $_ := $.AddSDKImport "private/protocol" }}
svc.Handlers.UnmarshalError.PushBackNamed(
{{- if .Metadata.AWSQueryCompatible }}
protocol.NewUnmarshalErrorHandler({{ .ProtocolPackage }}.NewUnmarshalTypedErrorWithOptions(exceptionFromCode, {{ .ProtocolPackage }}.WithQueryCompatibility(queryExceptionFromCode))).NamedHandler(),
{{- else }}
protocol.NewUnmarshalErrorHandler({{ .ProtocolPackage }}.NewUnmarshalTypedError(exceptionFromCode)).NamedHandler(),
{{- end}}
)
{{- else }}
svc.Handlers.UnmarshalError.PushBackNamed({{ .ProtocolPackage }}.UnmarshalErrorHandler)
Expand Down Expand Up @@ -933,6 +940,13 @@ const (
"{{ $s.ErrorName }}": newError{{ $s.ShapeName }},
{{- end }}
}
{{- if .Metadata.AWSQueryCompatible }}
var queryExceptionFromCode = map[string]func(protocol.ResponseMetadata, string)error {
{{- range $_, $s := $.ShapeListErrors }}
"{{ $s.ErrorName }}": newQueryCompatibleError{{ $s.ShapeName }},
{{- end }}
}
{{- end }}
{{- end }}
`))

Expand Down
75 changes: 75 additions & 0 deletions private/model/api/codegentest/models/awsquerycompatible/api-2.json
@@ -0,0 +1,75 @@

{
"version":"2.0",
"metadata":{
"apiVersion":"2012-11-05",
"awsQueryCompatible": {

},
"endpointPrefix":"awsqc-exampleendpoint",
"jsonVersion":"1.1",
"protocol":"json",
"serviceAbbreviation":"AwsQueryCompatible",
"serviceFullName":"AWSQuery Compatible Service",
"serviceId":"AWSQueryCompatible",
"signatureVersion":"v4",
"uid":"awsquerycompatible-2012-11-05",
"xmlNamespace":"http://queue.amazonaws.com/doc/2012-11-05/"
},
"operations":{
"CreateQueue":{
"name":"CreateQueue",
"http":{
"method":"POST",
"requestUri":"/"
},
"input":{"shape":"CreateQueueRequest"},
"output":{
"shape":"CreateQueueResult",
"resultWrapper":"CreateQueueResult"
},
"errors":[
{"shape":"QueueDeletedRecently"},
{"shape":"QueueNameExists"}
]
}
},
"shapes":{
"CreateQueueRequest":{
"type":"structure",
"required":["QueueName"],
"members":{
"QueueName":{"shape":"String"}
}
},
"CreateQueueResult":{
"type":"structure",
"members":{
"QueueUrl":{"shape":"String"}
}
},
"QueueDeletedRecently":{
"type":"structure",
"members":{
},
"error":{
"code":"AWS.SimpleQueueService.QueueDeletedRecently",
"httpStatusCode":400,
"senderFault":true
},
"exception":true
},
"QueueNameExists":{
"type":"structure",
"members":{
},
"error":{
"code":"QueueAlreadyExists",
"httpStatusCode":400,
"senderFault":true
},
"exception":true
},
"String":{"type":"string"}
}
}

0 comments on commit 698f054

Please sign in to comment.