@aws-sdk/client-sagemaker-runtime 3.181.0 → 3.183.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,347 +1,266 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { decorateServiceException as __decorateServiceException, expectInt32 as __expectInt32, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, map as __map, resolvedPath as __resolvedPath, throwDefaultError, } from "@aws-sdk/smithy-client";
4
3
  import { InternalDependencyException, InternalFailure, ModelError, ModelNotReadyException, ServiceUnavailable, ValidationError, } from "../models/models_0";
5
4
  import { SageMakerRuntimeServiceException as __BaseException } from "../models/SageMakerRuntimeServiceException";
6
- export var serializeAws_restJson1InvokeEndpointCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
8
- return __generator(this, function (_c) {
9
- switch (_c.label) {
10
- case 0: return [4, context.endpoint()];
11
- case 1:
12
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
13
- headers = map({}, isSerializableHeaderValue, {
14
- "content-type": input.ContentType || "application/octet-stream",
15
- accept: input.Accept,
16
- "x-amzn-sagemaker-custom-attributes": input.CustomAttributes,
17
- "x-amzn-sagemaker-target-model": input.TargetModel,
18
- "x-amzn-sagemaker-target-variant": input.TargetVariant,
19
- "x-amzn-sagemaker-target-container-hostname": input.TargetContainerHostname,
20
- "x-amzn-sagemaker-inference-id": input.InferenceId,
21
- });
22
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/endpoints/{EndpointName}/invocations";
23
- resolvedPath = __resolvedPath(resolvedPath, input, "EndpointName", function () { return input.EndpointName; }, "{EndpointName}", false);
24
- if (input.Body !== undefined) {
25
- body = input.Body;
26
- }
27
- return [2, new __HttpRequest({
28
- protocol: protocol,
29
- hostname: hostname,
30
- port: port,
31
- method: "POST",
32
- headers: headers,
33
- path: resolvedPath,
34
- body: body,
35
- })];
36
- }
5
+ export const serializeAws_restJson1InvokeEndpointCommand = async (input, context) => {
6
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
+ const headers = map({}, isSerializableHeaderValue, {
8
+ "content-type": input.ContentType || "application/octet-stream",
9
+ accept: input.Accept,
10
+ "x-amzn-sagemaker-custom-attributes": input.CustomAttributes,
11
+ "x-amzn-sagemaker-target-model": input.TargetModel,
12
+ "x-amzn-sagemaker-target-variant": input.TargetVariant,
13
+ "x-amzn-sagemaker-target-container-hostname": input.TargetContainerHostname,
14
+ "x-amzn-sagemaker-inference-id": input.InferenceId,
15
+ "x-amzn-sagemaker-enable-explanations": input.EnableExplanations,
37
16
  });
38
- }); };
39
- export var serializeAws_restJson1InvokeEndpointAsyncCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
40
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
41
- return __generator(this, function (_c) {
42
- switch (_c.label) {
43
- case 0: return [4, context.endpoint()];
44
- case 1:
45
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
46
- headers = map({}, isSerializableHeaderValue, {
47
- "x-amzn-sagemaker-content-type": input.ContentType,
48
- "x-amzn-sagemaker-accept": input.Accept,
49
- "x-amzn-sagemaker-custom-attributes": input.CustomAttributes,
50
- "x-amzn-sagemaker-inference-id": input.InferenceId,
51
- "x-amzn-sagemaker-inputlocation": input.InputLocation,
52
- "x-amzn-sagemaker-requestttlseconds": [
53
- function () { return isSerializableHeaderValue(input.RequestTTLSeconds); },
54
- function () { return input.RequestTTLSeconds.toString(); },
55
- ],
56
- });
57
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") +
58
- "/endpoints/{EndpointName}/async-invocations";
59
- resolvedPath = __resolvedPath(resolvedPath, input, "EndpointName", function () { return input.EndpointName; }, "{EndpointName}", false);
60
- return [2, new __HttpRequest({
61
- protocol: protocol,
62
- hostname: hostname,
63
- port: port,
64
- method: "POST",
65
- headers: headers,
66
- path: resolvedPath,
67
- body: body,
68
- })];
69
- }
17
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/endpoints/{EndpointName}/invocations";
18
+ resolvedPath = __resolvedPath(resolvedPath, input, "EndpointName", () => input.EndpointName, "{EndpointName}", false);
19
+ let body;
20
+ if (input.Body !== undefined) {
21
+ body = input.Body;
22
+ }
23
+ return new __HttpRequest({
24
+ protocol,
25
+ hostname,
26
+ port,
27
+ method: "POST",
28
+ headers,
29
+ path: resolvedPath,
30
+ body,
70
31
  });
71
- }); };
72
- export var deserializeAws_restJson1InvokeEndpointCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
73
- var contents, data;
74
- return __generator(this, function (_a) {
75
- switch (_a.label) {
76
- case 0:
77
- if (output.statusCode !== 200 && output.statusCode >= 300) {
78
- return [2, deserializeAws_restJson1InvokeEndpointCommandError(output, context)];
79
- }
80
- contents = map({
81
- $metadata: deserializeMetadata(output),
82
- ContentType: [, output.headers["content-type"]],
83
- InvokedProductionVariant: [, output.headers["x-amzn-invoked-production-variant"]],
84
- CustomAttributes: [, output.headers["x-amzn-sagemaker-custom-attributes"]],
85
- });
86
- return [4, collectBody(output.body, context)];
87
- case 1:
88
- data = _a.sent();
89
- contents.Body = data;
90
- return [2, contents];
91
- }
32
+ };
33
+ export const serializeAws_restJson1InvokeEndpointAsyncCommand = async (input, context) => {
34
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
35
+ const headers = map({}, isSerializableHeaderValue, {
36
+ "x-amzn-sagemaker-content-type": input.ContentType,
37
+ "x-amzn-sagemaker-accept": input.Accept,
38
+ "x-amzn-sagemaker-custom-attributes": input.CustomAttributes,
39
+ "x-amzn-sagemaker-inference-id": input.InferenceId,
40
+ "x-amzn-sagemaker-inputlocation": input.InputLocation,
41
+ "x-amzn-sagemaker-requestttlseconds": [
42
+ () => isSerializableHeaderValue(input.RequestTTLSeconds),
43
+ () => input.RequestTTLSeconds.toString(),
44
+ ],
92
45
  });
93
- }); };
94
- var deserializeAws_restJson1InvokeEndpointCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
95
- var parsedOutput, _a, errorCode, _b, parsedBody;
96
- var _c;
97
- return __generator(this, function (_d) {
98
- switch (_d.label) {
99
- case 0:
100
- _a = [__assign({}, output)];
101
- _c = {};
102
- return [4, parseErrorBody(output.body, context)];
103
- case 1:
104
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
105
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
106
- _b = errorCode;
107
- switch (_b) {
108
- case "InternalDependencyException": return [3, 2];
109
- case "com.amazonaws.sagemakerruntime#InternalDependencyException": return [3, 2];
110
- case "InternalFailure": return [3, 4];
111
- case "com.amazonaws.sagemakerruntime#InternalFailure": return [3, 4];
112
- case "ModelError": return [3, 6];
113
- case "com.amazonaws.sagemakerruntime#ModelError": return [3, 6];
114
- case "ModelNotReadyException": return [3, 8];
115
- case "com.amazonaws.sagemakerruntime#ModelNotReadyException": return [3, 8];
116
- case "ServiceUnavailable": return [3, 10];
117
- case "com.amazonaws.sagemakerruntime#ServiceUnavailable": return [3, 10];
118
- case "ValidationError": return [3, 12];
119
- case "com.amazonaws.sagemakerruntime#ValidationError": return [3, 12];
120
- }
121
- return [3, 14];
122
- case 2: return [4, deserializeAws_restJson1InternalDependencyExceptionResponse(parsedOutput, context)];
123
- case 3: throw _d.sent();
124
- case 4: return [4, deserializeAws_restJson1InternalFailureResponse(parsedOutput, context)];
125
- case 5: throw _d.sent();
126
- case 6: return [4, deserializeAws_restJson1ModelErrorResponse(parsedOutput, context)];
127
- case 7: throw _d.sent();
128
- case 8: return [4, deserializeAws_restJson1ModelNotReadyExceptionResponse(parsedOutput, context)];
129
- case 9: throw _d.sent();
130
- case 10: return [4, deserializeAws_restJson1ServiceUnavailableResponse(parsedOutput, context)];
131
- case 11: throw _d.sent();
132
- case 12: return [4, deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context)];
133
- case 13: throw _d.sent();
134
- case 14:
135
- parsedBody = parsedOutput.body;
136
- throwDefaultError({
137
- output: output,
138
- parsedBody: parsedBody,
139
- exceptionCtor: __BaseException,
140
- errorCode: errorCode,
141
- });
142
- _d.label = 15;
143
- case 15: return [2];
144
- }
46
+ let resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` +
47
+ "/endpoints/{EndpointName}/async-invocations";
48
+ resolvedPath = __resolvedPath(resolvedPath, input, "EndpointName", () => input.EndpointName, "{EndpointName}", false);
49
+ let body;
50
+ return new __HttpRequest({
51
+ protocol,
52
+ hostname,
53
+ port,
54
+ method: "POST",
55
+ headers,
56
+ path: resolvedPath,
57
+ body,
145
58
  });
146
- }); };
147
- export var deserializeAws_restJson1InvokeEndpointAsyncCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
148
- var contents, data, _a, _b;
149
- return __generator(this, function (_c) {
150
- switch (_c.label) {
151
- case 0:
152
- if (output.statusCode !== 202 && output.statusCode >= 300) {
153
- return [2, deserializeAws_restJson1InvokeEndpointAsyncCommandError(output, context)];
154
- }
155
- contents = map({
156
- $metadata: deserializeMetadata(output),
157
- OutputLocation: [, output.headers["x-amzn-sagemaker-outputlocation"]],
158
- });
159
- _a = __expectNonNull;
160
- _b = __expectObject;
161
- return [4, parseBody(output.body, context)];
162
- case 1:
163
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
164
- if (data.InferenceId != null) {
165
- contents.InferenceId = __expectString(data.InferenceId);
166
- }
167
- return [2, contents];
168
- }
169
- });
170
- }); };
171
- var deserializeAws_restJson1InvokeEndpointAsyncCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
172
- var parsedOutput, _a, errorCode, _b, parsedBody;
173
- var _c;
174
- return __generator(this, function (_d) {
175
- switch (_d.label) {
176
- case 0:
177
- _a = [__assign({}, output)];
178
- _c = {};
179
- return [4, parseErrorBody(output.body, context)];
180
- case 1:
181
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
182
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
183
- _b = errorCode;
184
- switch (_b) {
185
- case "InternalFailure": return [3, 2];
186
- case "com.amazonaws.sagemakerruntime#InternalFailure": return [3, 2];
187
- case "ServiceUnavailable": return [3, 4];
188
- case "com.amazonaws.sagemakerruntime#ServiceUnavailable": return [3, 4];
189
- case "ValidationError": return [3, 6];
190
- case "com.amazonaws.sagemakerruntime#ValidationError": return [3, 6];
191
- }
192
- return [3, 8];
193
- case 2: return [4, deserializeAws_restJson1InternalFailureResponse(parsedOutput, context)];
194
- case 3: throw _d.sent();
195
- case 4: return [4, deserializeAws_restJson1ServiceUnavailableResponse(parsedOutput, context)];
196
- case 5: throw _d.sent();
197
- case 6: return [4, deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context)];
198
- case 7: throw _d.sent();
199
- case 8:
200
- parsedBody = parsedOutput.body;
201
- throwDefaultError({
202
- output: output,
203
- parsedBody: parsedBody,
204
- exceptionCtor: __BaseException,
205
- errorCode: errorCode,
206
- });
207
- _d.label = 9;
208
- case 9: return [2];
209
- }
59
+ };
60
+ export const deserializeAws_restJson1InvokeEndpointCommand = async (output, context) => {
61
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
62
+ return deserializeAws_restJson1InvokeEndpointCommandError(output, context);
63
+ }
64
+ const contents = map({
65
+ $metadata: deserializeMetadata(output),
66
+ ContentType: [, output.headers["content-type"]],
67
+ InvokedProductionVariant: [, output.headers["x-amzn-invoked-production-variant"]],
68
+ CustomAttributes: [, output.headers["x-amzn-sagemaker-custom-attributes"]],
210
69
  });
211
- }); };
212
- var map = __map;
213
- var deserializeAws_restJson1InternalDependencyExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
214
- var contents, data, exception;
215
- return __generator(this, function (_a) {
216
- contents = map({});
217
- data = parsedOutput.body;
218
- if (data.Message != null) {
219
- contents.Message = __expectString(data.Message);
220
- }
221
- exception = new InternalDependencyException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
222
- return [2, __decorateServiceException(exception, parsedOutput.body)];
70
+ const data = await collectBody(output.body, context);
71
+ contents.Body = data;
72
+ return contents;
73
+ };
74
+ const deserializeAws_restJson1InvokeEndpointCommandError = async (output, context) => {
75
+ const parsedOutput = {
76
+ ...output,
77
+ body: await parseErrorBody(output.body, context),
78
+ };
79
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
80
+ switch (errorCode) {
81
+ case "InternalDependencyException":
82
+ case "com.amazonaws.sagemakerruntime#InternalDependencyException":
83
+ throw await deserializeAws_restJson1InternalDependencyExceptionResponse(parsedOutput, context);
84
+ case "InternalFailure":
85
+ case "com.amazonaws.sagemakerruntime#InternalFailure":
86
+ throw await deserializeAws_restJson1InternalFailureResponse(parsedOutput, context);
87
+ case "ModelError":
88
+ case "com.amazonaws.sagemakerruntime#ModelError":
89
+ throw await deserializeAws_restJson1ModelErrorResponse(parsedOutput, context);
90
+ case "ModelNotReadyException":
91
+ case "com.amazonaws.sagemakerruntime#ModelNotReadyException":
92
+ throw await deserializeAws_restJson1ModelNotReadyExceptionResponse(parsedOutput, context);
93
+ case "ServiceUnavailable":
94
+ case "com.amazonaws.sagemakerruntime#ServiceUnavailable":
95
+ throw await deserializeAws_restJson1ServiceUnavailableResponse(parsedOutput, context);
96
+ case "ValidationError":
97
+ case "com.amazonaws.sagemakerruntime#ValidationError":
98
+ throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context);
99
+ default:
100
+ const parsedBody = parsedOutput.body;
101
+ throwDefaultError({
102
+ output,
103
+ parsedBody,
104
+ exceptionCtor: __BaseException,
105
+ errorCode,
106
+ });
107
+ }
108
+ };
109
+ export const deserializeAws_restJson1InvokeEndpointAsyncCommand = async (output, context) => {
110
+ if (output.statusCode !== 202 && output.statusCode >= 300) {
111
+ return deserializeAws_restJson1InvokeEndpointAsyncCommandError(output, context);
112
+ }
113
+ const contents = map({
114
+ $metadata: deserializeMetadata(output),
115
+ OutputLocation: [, output.headers["x-amzn-sagemaker-outputlocation"]],
223
116
  });
224
- }); };
225
- var deserializeAws_restJson1InternalFailureResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
226
- var contents, data, exception;
227
- return __generator(this, function (_a) {
228
- contents = map({});
229
- data = parsedOutput.body;
230
- if (data.Message != null) {
231
- contents.Message = __expectString(data.Message);
232
- }
233
- exception = new InternalFailure(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
234
- return [2, __decorateServiceException(exception, parsedOutput.body)];
117
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
118
+ if (data.InferenceId != null) {
119
+ contents.InferenceId = __expectString(data.InferenceId);
120
+ }
121
+ return contents;
122
+ };
123
+ const deserializeAws_restJson1InvokeEndpointAsyncCommandError = async (output, context) => {
124
+ const parsedOutput = {
125
+ ...output,
126
+ body: await parseErrorBody(output.body, context),
127
+ };
128
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
129
+ switch (errorCode) {
130
+ case "InternalFailure":
131
+ case "com.amazonaws.sagemakerruntime#InternalFailure":
132
+ throw await deserializeAws_restJson1InternalFailureResponse(parsedOutput, context);
133
+ case "ServiceUnavailable":
134
+ case "com.amazonaws.sagemakerruntime#ServiceUnavailable":
135
+ throw await deserializeAws_restJson1ServiceUnavailableResponse(parsedOutput, context);
136
+ case "ValidationError":
137
+ case "com.amazonaws.sagemakerruntime#ValidationError":
138
+ throw await deserializeAws_restJson1ValidationErrorResponse(parsedOutput, context);
139
+ default:
140
+ const parsedBody = parsedOutput.body;
141
+ throwDefaultError({
142
+ output,
143
+ parsedBody,
144
+ exceptionCtor: __BaseException,
145
+ errorCode,
146
+ });
147
+ }
148
+ };
149
+ const map = __map;
150
+ const deserializeAws_restJson1InternalDependencyExceptionResponse = async (parsedOutput, context) => {
151
+ const contents = map({});
152
+ const data = parsedOutput.body;
153
+ if (data.Message != null) {
154
+ contents.Message = __expectString(data.Message);
155
+ }
156
+ const exception = new InternalDependencyException({
157
+ $metadata: deserializeMetadata(parsedOutput),
158
+ ...contents,
235
159
  });
236
- }); };
237
- var deserializeAws_restJson1ModelErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
238
- var contents, data, exception;
239
- return __generator(this, function (_a) {
240
- contents = map({});
241
- data = parsedOutput.body;
242
- if (data.LogStreamArn != null) {
243
- contents.LogStreamArn = __expectString(data.LogStreamArn);
244
- }
245
- if (data.Message != null) {
246
- contents.Message = __expectString(data.Message);
247
- }
248
- if (data.OriginalMessage != null) {
249
- contents.OriginalMessage = __expectString(data.OriginalMessage);
250
- }
251
- if (data.OriginalStatusCode != null) {
252
- contents.OriginalStatusCode = __expectInt32(data.OriginalStatusCode);
253
- }
254
- exception = new ModelError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
255
- return [2, __decorateServiceException(exception, parsedOutput.body)];
160
+ return __decorateServiceException(exception, parsedOutput.body);
161
+ };
162
+ const deserializeAws_restJson1InternalFailureResponse = async (parsedOutput, context) => {
163
+ const contents = map({});
164
+ const data = parsedOutput.body;
165
+ if (data.Message != null) {
166
+ contents.Message = __expectString(data.Message);
167
+ }
168
+ const exception = new InternalFailure({
169
+ $metadata: deserializeMetadata(parsedOutput),
170
+ ...contents,
256
171
  });
257
- }); };
258
- var deserializeAws_restJson1ModelNotReadyExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
259
- var contents, data, exception;
260
- return __generator(this, function (_a) {
261
- contents = map({});
262
- data = parsedOutput.body;
263
- if (data.Message != null) {
264
- contents.Message = __expectString(data.Message);
265
- }
266
- exception = new ModelNotReadyException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
267
- return [2, __decorateServiceException(exception, parsedOutput.body)];
172
+ return __decorateServiceException(exception, parsedOutput.body);
173
+ };
174
+ const deserializeAws_restJson1ModelErrorResponse = async (parsedOutput, context) => {
175
+ const contents = map({});
176
+ const data = parsedOutput.body;
177
+ if (data.LogStreamArn != null) {
178
+ contents.LogStreamArn = __expectString(data.LogStreamArn);
179
+ }
180
+ if (data.Message != null) {
181
+ contents.Message = __expectString(data.Message);
182
+ }
183
+ if (data.OriginalMessage != null) {
184
+ contents.OriginalMessage = __expectString(data.OriginalMessage);
185
+ }
186
+ if (data.OriginalStatusCode != null) {
187
+ contents.OriginalStatusCode = __expectInt32(data.OriginalStatusCode);
188
+ }
189
+ const exception = new ModelError({
190
+ $metadata: deserializeMetadata(parsedOutput),
191
+ ...contents,
268
192
  });
269
- }); };
270
- var deserializeAws_restJson1ServiceUnavailableResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
271
- var contents, data, exception;
272
- return __generator(this, function (_a) {
273
- contents = map({});
274
- data = parsedOutput.body;
275
- if (data.Message != null) {
276
- contents.Message = __expectString(data.Message);
277
- }
278
- exception = new ServiceUnavailable(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
279
- return [2, __decorateServiceException(exception, parsedOutput.body)];
193
+ return __decorateServiceException(exception, parsedOutput.body);
194
+ };
195
+ const deserializeAws_restJson1ModelNotReadyExceptionResponse = async (parsedOutput, context) => {
196
+ const contents = map({});
197
+ const data = parsedOutput.body;
198
+ if (data.Message != null) {
199
+ contents.Message = __expectString(data.Message);
200
+ }
201
+ const exception = new ModelNotReadyException({
202
+ $metadata: deserializeMetadata(parsedOutput),
203
+ ...contents,
280
204
  });
281
- }); };
282
- var deserializeAws_restJson1ValidationErrorResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
283
- var contents, data, exception;
284
- return __generator(this, function (_a) {
285
- contents = map({});
286
- data = parsedOutput.body;
287
- if (data.Message != null) {
288
- contents.Message = __expectString(data.Message);
289
- }
290
- exception = new ValidationError(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
291
- return [2, __decorateServiceException(exception, parsedOutput.body)];
205
+ return __decorateServiceException(exception, parsedOutput.body);
206
+ };
207
+ const deserializeAws_restJson1ServiceUnavailableResponse = async (parsedOutput, context) => {
208
+ const contents = map({});
209
+ const data = parsedOutput.body;
210
+ if (data.Message != null) {
211
+ contents.Message = __expectString(data.Message);
212
+ }
213
+ const exception = new ServiceUnavailable({
214
+ $metadata: deserializeMetadata(parsedOutput),
215
+ ...contents,
292
216
  });
293
- }); };
294
- var deserializeMetadata = function (output) {
295
- var _a;
296
- return ({
297
- httpStatusCode: output.statusCode,
298
- requestId: (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"],
299
- extendedRequestId: output.headers["x-amz-id-2"],
300
- cfId: output.headers["x-amz-cf-id"],
217
+ return __decorateServiceException(exception, parsedOutput.body);
218
+ };
219
+ const deserializeAws_restJson1ValidationErrorResponse = async (parsedOutput, context) => {
220
+ const contents = map({});
221
+ const data = parsedOutput.body;
222
+ if (data.Message != null) {
223
+ contents.Message = __expectString(data.Message);
224
+ }
225
+ const exception = new ValidationError({
226
+ $metadata: deserializeMetadata(parsedOutput),
227
+ ...contents,
301
228
  });
229
+ return __decorateServiceException(exception, parsedOutput.body);
302
230
  };
303
- var collectBody = function (streamBody, context) {
304
- if (streamBody === void 0) { streamBody = new Uint8Array(); }
231
+ const deserializeMetadata = (output) => ({
232
+ httpStatusCode: output.statusCode,
233
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
234
+ extendedRequestId: output.headers["x-amz-id-2"],
235
+ cfId: output.headers["x-amz-cf-id"],
236
+ });
237
+ const collectBody = (streamBody = new Uint8Array(), context) => {
305
238
  if (streamBody instanceof Uint8Array) {
306
239
  return Promise.resolve(streamBody);
307
240
  }
308
241
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
309
242
  };
310
- var collectBodyString = function (streamBody, context) {
311
- return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
312
- };
313
- var isSerializableHeaderValue = function (value) {
314
- return value !== undefined &&
315
- value !== null &&
316
- value !== "" &&
317
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
318
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
319
- };
320
- var parseBody = function (streamBody, context) {
321
- return collectBodyString(streamBody, context).then(function (encoded) {
322
- if (encoded.length) {
323
- return JSON.parse(encoded);
324
- }
325
- return {};
326
- });
243
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
244
+ const isSerializableHeaderValue = (value) => value !== undefined &&
245
+ value !== null &&
246
+ value !== "" &&
247
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
248
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
249
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
250
+ if (encoded.length) {
251
+ return JSON.parse(encoded);
252
+ }
253
+ return {};
254
+ });
255
+ const parseErrorBody = async (errorBody, context) => {
256
+ const value = await parseBody(errorBody, context);
257
+ value.message = value.message ?? value.Message;
258
+ return value;
327
259
  };
328
- var parseErrorBody = function (errorBody, context) { return __awaiter(void 0, void 0, void 0, function () {
329
- var value;
330
- var _a;
331
- return __generator(this, function (_b) {
332
- switch (_b.label) {
333
- case 0: return [4, parseBody(errorBody, context)];
334
- case 1:
335
- value = _b.sent();
336
- value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
337
- return [2, value];
338
- }
339
- });
340
- }); };
341
- var loadRestJsonErrorCode = function (output, data) {
342
- var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
343
- var sanitizeErrorCode = function (rawValue) {
344
- var cleanValue = rawValue;
260
+ const loadRestJsonErrorCode = (output, data) => {
261
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
262
+ const sanitizeErrorCode = (rawValue) => {
263
+ let cleanValue = rawValue;
345
264
  if (typeof cleanValue === "number") {
346
265
  cleanValue = cleanValue.toString();
347
266
  }
@@ -356,7 +275,7 @@ var loadRestJsonErrorCode = function (output, data) {
356
275
  }
357
276
  return cleanValue;
358
277
  };
359
- var headerKey = findKey(output.headers, "x-amzn-errortype");
278
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
360
279
  if (headerKey !== undefined) {
361
280
  return sanitizeErrorCode(output.headers[headerKey]);
362
281
  }