diff --git a/.changes/next-release/bugfix-SageMakerRuntime-407b0118.json b/.changes/next-release/bugfix-SageMakerRuntime-407b0118.json new file mode 100644 index 0000000000..e94abf556b --- /dev/null +++ b/.changes/next-release/bugfix-SageMakerRuntime-407b0118.json @@ -0,0 +1,5 @@ +{ + "type": "bugfix", + "category": "SageMakerRuntime", + "description": "fixed the issue that invokeEndpointAsync is not callable #4203" +} \ No newline at end of file diff --git a/clients/sagemakerruntime.js b/clients/sagemakerruntime.js index 1a2f4b9095..73b9779443 100644 --- a/clients/sagemakerruntime.js +++ b/clients/sagemakerruntime.js @@ -5,6 +5,7 @@ var apiLoader = AWS.apiLoader; apiLoader.services['sagemakerruntime'] = {}; AWS.SageMakerRuntime = Service.defineService('sagemakerruntime', ['2017-05-13']); +require('../lib/services/sagemakerruntime'); Object.defineProperty(apiLoader.services['sagemakerruntime'], '2017-05-13', { get: function get() { var model = require('../apis/runtime.sagemaker-2017-05-13.min.json'); diff --git a/lib/services/sagemakerruntime.js b/lib/services/sagemakerruntime.js new file mode 100644 index 0000000000..92191f7bb7 --- /dev/null +++ b/lib/services/sagemakerruntime.js @@ -0,0 +1,20 @@ +var AWS = require('../core'); + +AWS.util.update(AWS.SageMakerRuntime.prototype, { + /** + * @api private + */ + setupRequestListeners: function setupRequestListeners(request) { + if (request.operation === 'invokeEndpointAsync') { + request.addListener('build', this.emptyBody); + } + }, + + /** + * Empty request body for async inference + * @api private + */ + emptyBody: function emptyBody(request) { + request.httpRequest.body = ''; + }, +}); diff --git a/test/services/sagemakerruntime.spec.js b/test/services/sagemakerruntime.spec.js new file mode 100644 index 0000000000..277f56ee4f --- /dev/null +++ b/test/services/sagemakerruntime.spec.js @@ -0,0 +1,30 @@ +(function () { + const helpers = require('../helpers'); + const { AWS, spyOn } = helpers; + + return describe('SageMakerRuntime.invokeEndpointAsync', function () { + it('should call api with an empty body', async () => { + const httpClient = AWS.HttpClient.getInstance(); + spyOn(httpClient, 'handleRequest').andCallFake(function ( + httpReq, + httpOp, + cb, + errCb + ) { + expect(httpReq.body).to.equal(''); + helpers.mockHttpSuccessfulResponse( + 200, + {}, + JSON.stringify({ success: true }), + cb + ); + }); + await new AWS.SageMakerRuntime() + .invokeEndpointAsync({ + InputLocation: 's3://mock', + EndpointName: 'mock', + }) + .promise(); + }); + }); +}.call(this));