Skip to content

Commit

Permalink
Sqs AwsJson migration (#4105)
Browse files Browse the repository at this point in the history
* Add awsQueryCompatible trait support to service

When awsQueryCompatible trait is found, it's made available as an API property. When this property is found,
the error code is returned by looking up the mapping. This is a pre-requisite for migrating services from
AWSQuery wire protocol to AWSJson.

* Add additional tests; review comments

* Add awsQueryCompatible trait support to service

When awsQueryCompatible trait is found, it's made available as an API property. When this property is found,
the error code is returned by looking up the mapping. This is a pre-requisite for migrating services from
AWSQuery wire protocol to AWSJson.

* Add additional tests; review comments

* Review comments

* Use MockServiceFromApi; Move errorCodeMapping logic to even)listeners

* Update on.error function

* Fix type

* Remove reimplementation of mapping function

* Use add instead of addAsync

Co-authored-by: AllanZhengYP <[email protected]>

* Add null check to error listener

* Use simple service null check

* Fix add 'Error' implementation

* Add changelog

Co-authored-by: AllanZhengYP <[email protected]>
  • Loading branch information
eddy-aws and AllanZhengYP authored Jun 29, 2022
1 parent d4a4f4a commit 2a87ec1
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "feature",
"category": "AwsQueryCompatible",
"description": "Add awsQueryCompatible trait support to service"
}
10 changes: 10 additions & 0 deletions lib/event_listeners.js
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,16 @@ AWS.EventListeners = {
}
});

add('ERROR', 'error', function ERROR(err, resp) {
var errorCodeMapping = resp.request.service.api.errorCodeMapping;
if (errorCodeMapping && err && err.code) {
var mapping = errorCodeMapping[err.code];
if (mapping) {
resp.error.code = mapping.code;
}
}
}, true);

addAsync('SEND', 'send', function SEND(resp, done) {
resp.httpResponse._abortCallback = done;
resp.error = null;
Expand Down
1 change: 1 addition & 0 deletions lib/model/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ function Api(api, options) {
property(this, 'documentation', api.documentation);
property(this, 'documentationUrl', api.documentationUrl);
}
property(this, 'errorCodeMapping', api.awsQueryCompatible);
}

/**
Expand Down
18 changes: 7 additions & 11 deletions test/helpers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

69 changes: 67 additions & 2 deletions test/service.spec.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2a87ec1

Please sign in to comment.