@aws-sdk/client-ebs 3.137.0 → 3.145.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.
@@ -8,27 +8,17 @@ const EBSServiceException_1 = require("../models/EBSServiceException");
8
8
  const models_0_1 = require("../models/models_0");
9
9
  const serializeAws_restJson1CompleteSnapshotCommand = async (input, context) => {
10
10
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
11
- const headers = {
12
- ...(isSerializableHeaderValue(input.ChangedBlocksCount) && {
13
- "x-amz-changedblockscount": input.ChangedBlocksCount.toString(),
14
- }),
15
- ...(isSerializableHeaderValue(input.Checksum) && { "x-amz-checksum": input.Checksum }),
16
- ...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-checksum-algorithm": input.ChecksumAlgorithm }),
17
- ...(isSerializableHeaderValue(input.ChecksumAggregationMethod) && {
18
- "x-amz-checksum-aggregation-method": input.ChecksumAggregationMethod,
19
- }),
20
- };
11
+ const headers = map({}, isSerializableHeaderValue, {
12
+ "x-amz-changedblockscount": [
13
+ () => isSerializableHeaderValue(input.ChangedBlocksCount),
14
+ () => input.ChangedBlocksCount.toString(),
15
+ ],
16
+ "x-amz-checksum": input.Checksum,
17
+ "x-amz-checksum-algorithm": input.ChecksumAlgorithm,
18
+ "x-amz-checksum-aggregation-method": input.ChecksumAggregationMethod,
19
+ });
21
20
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/snapshots/completion/{SnapshotId}";
22
- if (input.SnapshotId !== undefined) {
23
- const labelValue = input.SnapshotId;
24
- if (labelValue.length <= 0) {
25
- throw new Error("Empty value provided for input HTTP label: SnapshotId.");
26
- }
27
- resolvedPath = resolvedPath.replace("{SnapshotId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
28
- }
29
- else {
30
- throw new Error("No value provided for input HTTP label: SnapshotId.");
31
- }
21
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "SnapshotId", () => input.SnapshotId, "{SnapshotId}", false);
32
22
  let body;
33
23
  return new protocol_http_1.HttpRequest({
34
24
  protocol,
@@ -46,29 +36,11 @@ const serializeAws_restJson1GetSnapshotBlockCommand = async (input, context) =>
46
36
  const headers = {};
47
37
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
48
38
  "/snapshots/{SnapshotId}/blocks/{BlockIndex}";
49
- if (input.SnapshotId !== undefined) {
50
- const labelValue = input.SnapshotId;
51
- if (labelValue.length <= 0) {
52
- throw new Error("Empty value provided for input HTTP label: SnapshotId.");
53
- }
54
- resolvedPath = resolvedPath.replace("{SnapshotId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
55
- }
56
- else {
57
- throw new Error("No value provided for input HTTP label: SnapshotId.");
58
- }
59
- if (input.BlockIndex !== undefined) {
60
- const labelValue = input.BlockIndex.toString();
61
- if (labelValue.length <= 0) {
62
- throw new Error("Empty value provided for input HTTP label: BlockIndex.");
63
- }
64
- resolvedPath = resolvedPath.replace("{BlockIndex}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
65
- }
66
- else {
67
- throw new Error("No value provided for input HTTP label: BlockIndex.");
68
- }
69
- const query = {
70
- ...(input.BlockToken !== undefined && { blockToken: input.BlockToken }),
71
- };
39
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "SnapshotId", () => input.SnapshotId, "{SnapshotId}", false);
40
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "BlockIndex", () => input.BlockIndex.toString(), "{BlockIndex}", false);
41
+ const query = map({
42
+ blockToken: [, input.BlockToken],
43
+ });
72
44
  let body;
73
45
  return new protocol_http_1.HttpRequest({
74
46
  protocol,
@@ -87,22 +59,13 @@ const serializeAws_restJson1ListChangedBlocksCommand = async (input, context) =>
87
59
  const headers = {};
88
60
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
89
61
  "/snapshots/{SecondSnapshotId}/changedblocks";
90
- if (input.SecondSnapshotId !== undefined) {
91
- const labelValue = input.SecondSnapshotId;
92
- if (labelValue.length <= 0) {
93
- throw new Error("Empty value provided for input HTTP label: SecondSnapshotId.");
94
- }
95
- resolvedPath = resolvedPath.replace("{SecondSnapshotId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
96
- }
97
- else {
98
- throw new Error("No value provided for input HTTP label: SecondSnapshotId.");
99
- }
100
- const query = {
101
- ...(input.FirstSnapshotId !== undefined && { firstSnapshotId: input.FirstSnapshotId }),
102
- ...(input.NextToken !== undefined && { pageToken: input.NextToken }),
103
- ...(input.MaxResults !== undefined && { maxResults: input.MaxResults.toString() }),
104
- ...(input.StartingBlockIndex !== undefined && { startingBlockIndex: input.StartingBlockIndex.toString() }),
105
- };
62
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "SecondSnapshotId", () => input.SecondSnapshotId, "{SecondSnapshotId}", false);
63
+ const query = map({
64
+ firstSnapshotId: [, input.FirstSnapshotId],
65
+ pageToken: [, input.NextToken],
66
+ maxResults: [() => input.MaxResults !== void 0, () => input.MaxResults.toString()],
67
+ startingBlockIndex: [() => input.StartingBlockIndex !== void 0, () => input.StartingBlockIndex.toString()],
68
+ });
106
69
  let body;
107
70
  return new protocol_http_1.HttpRequest({
108
71
  protocol,
@@ -120,21 +83,12 @@ const serializeAws_restJson1ListSnapshotBlocksCommand = async (input, context) =
120
83
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
121
84
  const headers = {};
122
85
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` + "/snapshots/{SnapshotId}/blocks";
123
- if (input.SnapshotId !== undefined) {
124
- const labelValue = input.SnapshotId;
125
- if (labelValue.length <= 0) {
126
- throw new Error("Empty value provided for input HTTP label: SnapshotId.");
127
- }
128
- resolvedPath = resolvedPath.replace("{SnapshotId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
129
- }
130
- else {
131
- throw new Error("No value provided for input HTTP label: SnapshotId.");
132
- }
133
- const query = {
134
- ...(input.NextToken !== undefined && { pageToken: input.NextToken }),
135
- ...(input.MaxResults !== undefined && { maxResults: input.MaxResults.toString() }),
136
- ...(input.StartingBlockIndex !== undefined && { startingBlockIndex: input.StartingBlockIndex.toString() }),
137
- };
86
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "SnapshotId", () => input.SnapshotId, "{SnapshotId}", false);
87
+ const query = map({
88
+ pageToken: [, input.NextToken],
89
+ maxResults: [() => input.MaxResults !== void 0, () => input.MaxResults.toString()],
90
+ startingBlockIndex: [() => input.StartingBlockIndex !== void 0, () => input.StartingBlockIndex.toString()],
91
+ });
138
92
  let body;
139
93
  return new protocol_http_1.HttpRequest({
140
94
  protocol,
@@ -150,36 +104,18 @@ const serializeAws_restJson1ListSnapshotBlocksCommand = async (input, context) =
150
104
  exports.serializeAws_restJson1ListSnapshotBlocksCommand = serializeAws_restJson1ListSnapshotBlocksCommand;
151
105
  const serializeAws_restJson1PutSnapshotBlockCommand = async (input, context) => {
152
106
  const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
153
- const headers = {
154
- "content-type": "application/octet-stream",
107
+ const headers = map({}, isSerializableHeaderValue, {
155
108
  "x-amz-content-sha256": "UNSIGNED-PAYLOAD",
156
- ...(isSerializableHeaderValue(input.DataLength) && { "x-amz-data-length": input.DataLength.toString() }),
157
- ...(isSerializableHeaderValue(input.Progress) && { "x-amz-progress": input.Progress.toString() }),
158
- ...(isSerializableHeaderValue(input.Checksum) && { "x-amz-checksum": input.Checksum }),
159
- ...(isSerializableHeaderValue(input.ChecksumAlgorithm) && { "x-amz-checksum-algorithm": input.ChecksumAlgorithm }),
160
- };
109
+ "content-type": "application/octet-stream",
110
+ "x-amz-data-length": [() => isSerializableHeaderValue(input.DataLength), () => input.DataLength.toString()],
111
+ "x-amz-progress": [() => isSerializableHeaderValue(input.Progress), () => input.Progress.toString()],
112
+ "x-amz-checksum": input.Checksum,
113
+ "x-amz-checksum-algorithm": input.ChecksumAlgorithm,
114
+ });
161
115
  let resolvedPath = `${(basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || ""}` +
162
116
  "/snapshots/{SnapshotId}/blocks/{BlockIndex}";
163
- if (input.SnapshotId !== undefined) {
164
- const labelValue = input.SnapshotId;
165
- if (labelValue.length <= 0) {
166
- throw new Error("Empty value provided for input HTTP label: SnapshotId.");
167
- }
168
- resolvedPath = resolvedPath.replace("{SnapshotId}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
169
- }
170
- else {
171
- throw new Error("No value provided for input HTTP label: SnapshotId.");
172
- }
173
- if (input.BlockIndex !== undefined) {
174
- const labelValue = input.BlockIndex.toString();
175
- if (labelValue.length <= 0) {
176
- throw new Error("Empty value provided for input HTTP label: BlockIndex.");
177
- }
178
- resolvedPath = resolvedPath.replace("{BlockIndex}", (0, smithy_client_1.extendedEncodeURIComponent)(labelValue));
179
- }
180
- else {
181
- throw new Error("No value provided for input HTTP label: BlockIndex.");
182
- }
117
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "SnapshotId", () => input.SnapshotId, "{SnapshotId}", false);
118
+ resolvedPath = (0, smithy_client_1.resolvedPath)(resolvedPath, input, "BlockIndex", () => input.BlockIndex.toString(), "{BlockIndex}", false);
183
119
  let body;
184
120
  if (input.BlockData !== undefined) {
185
121
  body = input.BlockData;
@@ -228,15 +164,14 @@ const deserializeAws_restJson1CompleteSnapshotCommand = async (output, context)
228
164
  if (output.statusCode !== 202 && output.statusCode >= 300) {
229
165
  return deserializeAws_restJson1CompleteSnapshotCommandError(output, context);
230
166
  }
231
- const contents = {
167
+ const contents = map({
232
168
  $metadata: deserializeMetadata(output),
233
- Status: undefined,
234
- };
169
+ });
235
170
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
236
- if (data.Status !== undefined && data.Status !== null) {
171
+ if (data.Status != null) {
237
172
  contents.Status = (0, smithy_client_1.expectString)(data.Status);
238
173
  }
239
- return Promise.resolve(contents);
174
+ return contents;
240
175
  };
241
176
  exports.deserializeAws_restJson1CompleteSnapshotCommand = deserializeAws_restJson1CompleteSnapshotCommand;
242
177
  const deserializeAws_restJson1CompleteSnapshotCommandError = async (output, context) => {
@@ -244,7 +179,6 @@ const deserializeAws_restJson1CompleteSnapshotCommandError = async (output, cont
244
179
  ...output,
245
180
  body: await parseBody(output.body, context),
246
181
  };
247
- let response;
248
182
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
249
183
  switch (errorCode) {
250
184
  case "AccessDeniedException":
@@ -267,39 +201,30 @@ const deserializeAws_restJson1CompleteSnapshotCommandError = async (output, cont
267
201
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
268
202
  default:
269
203
  const parsedBody = parsedOutput.body;
270
- const $metadata = deserializeMetadata(output);
271
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
272
- response = new EBSServiceException_1.EBSServiceException({
273
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
274
- $fault: "client",
275
- $metadata,
204
+ (0, smithy_client_1.throwDefaultError)({
205
+ output,
206
+ parsedBody,
207
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
208
+ errorCode,
276
209
  });
277
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
278
210
  }
279
211
  };
280
212
  const deserializeAws_restJson1GetSnapshotBlockCommand = async (output, context) => {
281
213
  if (output.statusCode !== 200 && output.statusCode >= 300) {
282
214
  return deserializeAws_restJson1GetSnapshotBlockCommandError(output, context);
283
215
  }
284
- const contents = {
216
+ const contents = map({
285
217
  $metadata: deserializeMetadata(output),
286
- BlockData: undefined,
287
- Checksum: undefined,
288
- ChecksumAlgorithm: undefined,
289
- DataLength: undefined,
290
- };
291
- if (output.headers["x-amz-data-length"] !== undefined) {
292
- contents.DataLength = (0, smithy_client_1.strictParseInt32)(output.headers["x-amz-data-length"]);
293
- }
294
- if (output.headers["x-amz-checksum"] !== undefined) {
295
- contents.Checksum = output.headers["x-amz-checksum"];
296
- }
297
- if (output.headers["x-amz-checksum-algorithm"] !== undefined) {
298
- contents.ChecksumAlgorithm = output.headers["x-amz-checksum-algorithm"];
299
- }
218
+ DataLength: [
219
+ () => void 0 !== output.headers["x-amz-data-length"],
220
+ () => (0, smithy_client_1.strictParseInt32)(output.headers["x-amz-data-length"]),
221
+ ],
222
+ Checksum: [, output.headers["x-amz-checksum"]],
223
+ ChecksumAlgorithm: [, output.headers["x-amz-checksum-algorithm"]],
224
+ });
300
225
  const data = output.body;
301
226
  contents.BlockData = data;
302
- return Promise.resolve(contents);
227
+ return contents;
303
228
  };
304
229
  exports.deserializeAws_restJson1GetSnapshotBlockCommand = deserializeAws_restJson1GetSnapshotBlockCommand;
305
230
  const deserializeAws_restJson1GetSnapshotBlockCommandError = async (output, context) => {
@@ -307,7 +232,6 @@ const deserializeAws_restJson1GetSnapshotBlockCommandError = async (output, cont
307
232
  ...output,
308
233
  body: await parseBody(output.body, context),
309
234
  };
310
- let response;
311
235
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
312
236
  switch (errorCode) {
313
237
  case "AccessDeniedException":
@@ -330,45 +254,38 @@ const deserializeAws_restJson1GetSnapshotBlockCommandError = async (output, cont
330
254
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
331
255
  default:
332
256
  const parsedBody = parsedOutput.body;
333
- const $metadata = deserializeMetadata(output);
334
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
335
- response = new EBSServiceException_1.EBSServiceException({
336
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
337
- $fault: "client",
338
- $metadata,
257
+ (0, smithy_client_1.throwDefaultError)({
258
+ output,
259
+ parsedBody,
260
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
261
+ errorCode,
339
262
  });
340
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
341
263
  }
342
264
  };
343
265
  const deserializeAws_restJson1ListChangedBlocksCommand = async (output, context) => {
344
266
  if (output.statusCode !== 200 && output.statusCode >= 300) {
345
267
  return deserializeAws_restJson1ListChangedBlocksCommandError(output, context);
346
268
  }
347
- const contents = {
269
+ const contents = map({
348
270
  $metadata: deserializeMetadata(output),
349
- BlockSize: undefined,
350
- ChangedBlocks: undefined,
351
- ExpiryTime: undefined,
352
- NextToken: undefined,
353
- VolumeSize: undefined,
354
- };
271
+ });
355
272
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
356
- if (data.BlockSize !== undefined && data.BlockSize !== null) {
273
+ if (data.BlockSize != null) {
357
274
  contents.BlockSize = (0, smithy_client_1.expectInt32)(data.BlockSize);
358
275
  }
359
- if (data.ChangedBlocks !== undefined && data.ChangedBlocks !== null) {
276
+ if (data.ChangedBlocks != null) {
360
277
  contents.ChangedBlocks = deserializeAws_restJson1ChangedBlocks(data.ChangedBlocks, context);
361
278
  }
362
- if (data.ExpiryTime !== undefined && data.ExpiryTime !== null) {
279
+ if (data.ExpiryTime != null) {
363
280
  contents.ExpiryTime = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseEpochTimestamp)((0, smithy_client_1.expectNumber)(data.ExpiryTime)));
364
281
  }
365
- if (data.NextToken !== undefined && data.NextToken !== null) {
282
+ if (data.NextToken != null) {
366
283
  contents.NextToken = (0, smithy_client_1.expectString)(data.NextToken);
367
284
  }
368
- if (data.VolumeSize !== undefined && data.VolumeSize !== null) {
285
+ if (data.VolumeSize != null) {
369
286
  contents.VolumeSize = (0, smithy_client_1.expectLong)(data.VolumeSize);
370
287
  }
371
- return Promise.resolve(contents);
288
+ return contents;
372
289
  };
373
290
  exports.deserializeAws_restJson1ListChangedBlocksCommand = deserializeAws_restJson1ListChangedBlocksCommand;
374
291
  const deserializeAws_restJson1ListChangedBlocksCommandError = async (output, context) => {
@@ -376,7 +293,6 @@ const deserializeAws_restJson1ListChangedBlocksCommandError = async (output, con
376
293
  ...output,
377
294
  body: await parseBody(output.body, context),
378
295
  };
379
- let response;
380
296
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
381
297
  switch (errorCode) {
382
298
  case "AccessDeniedException":
@@ -399,45 +315,38 @@ const deserializeAws_restJson1ListChangedBlocksCommandError = async (output, con
399
315
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
400
316
  default:
401
317
  const parsedBody = parsedOutput.body;
402
- const $metadata = deserializeMetadata(output);
403
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
404
- response = new EBSServiceException_1.EBSServiceException({
405
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
406
- $fault: "client",
407
- $metadata,
318
+ (0, smithy_client_1.throwDefaultError)({
319
+ output,
320
+ parsedBody,
321
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
322
+ errorCode,
408
323
  });
409
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
410
324
  }
411
325
  };
412
326
  const deserializeAws_restJson1ListSnapshotBlocksCommand = async (output, context) => {
413
327
  if (output.statusCode !== 200 && output.statusCode >= 300) {
414
328
  return deserializeAws_restJson1ListSnapshotBlocksCommandError(output, context);
415
329
  }
416
- const contents = {
330
+ const contents = map({
417
331
  $metadata: deserializeMetadata(output),
418
- BlockSize: undefined,
419
- Blocks: undefined,
420
- ExpiryTime: undefined,
421
- NextToken: undefined,
422
- VolumeSize: undefined,
423
- };
332
+ });
424
333
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
425
- if (data.BlockSize !== undefined && data.BlockSize !== null) {
334
+ if (data.BlockSize != null) {
426
335
  contents.BlockSize = (0, smithy_client_1.expectInt32)(data.BlockSize);
427
336
  }
428
- if (data.Blocks !== undefined && data.Blocks !== null) {
337
+ if (data.Blocks != null) {
429
338
  contents.Blocks = deserializeAws_restJson1Blocks(data.Blocks, context);
430
339
  }
431
- if (data.ExpiryTime !== undefined && data.ExpiryTime !== null) {
340
+ if (data.ExpiryTime != null) {
432
341
  contents.ExpiryTime = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseEpochTimestamp)((0, smithy_client_1.expectNumber)(data.ExpiryTime)));
433
342
  }
434
- if (data.NextToken !== undefined && data.NextToken !== null) {
343
+ if (data.NextToken != null) {
435
344
  contents.NextToken = (0, smithy_client_1.expectString)(data.NextToken);
436
345
  }
437
- if (data.VolumeSize !== undefined && data.VolumeSize !== null) {
346
+ if (data.VolumeSize != null) {
438
347
  contents.VolumeSize = (0, smithy_client_1.expectLong)(data.VolumeSize);
439
348
  }
440
- return Promise.resolve(contents);
349
+ return contents;
441
350
  };
442
351
  exports.deserializeAws_restJson1ListSnapshotBlocksCommand = deserializeAws_restJson1ListSnapshotBlocksCommand;
443
352
  const deserializeAws_restJson1ListSnapshotBlocksCommandError = async (output, context) => {
@@ -445,7 +354,6 @@ const deserializeAws_restJson1ListSnapshotBlocksCommandError = async (output, co
445
354
  ...output,
446
355
  body: await parseBody(output.body, context),
447
356
  };
448
- let response;
449
357
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
450
358
  switch (errorCode) {
451
359
  case "AccessDeniedException":
@@ -468,33 +376,25 @@ const deserializeAws_restJson1ListSnapshotBlocksCommandError = async (output, co
468
376
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
469
377
  default:
470
378
  const parsedBody = parsedOutput.body;
471
- const $metadata = deserializeMetadata(output);
472
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
473
- response = new EBSServiceException_1.EBSServiceException({
474
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
475
- $fault: "client",
476
- $metadata,
379
+ (0, smithy_client_1.throwDefaultError)({
380
+ output,
381
+ parsedBody,
382
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
383
+ errorCode,
477
384
  });
478
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
479
385
  }
480
386
  };
481
387
  const deserializeAws_restJson1PutSnapshotBlockCommand = async (output, context) => {
482
388
  if (output.statusCode !== 201 && output.statusCode >= 300) {
483
389
  return deserializeAws_restJson1PutSnapshotBlockCommandError(output, context);
484
390
  }
485
- const contents = {
391
+ const contents = map({
486
392
  $metadata: deserializeMetadata(output),
487
- Checksum: undefined,
488
- ChecksumAlgorithm: undefined,
489
- };
490
- if (output.headers["x-amz-checksum"] !== undefined) {
491
- contents.Checksum = output.headers["x-amz-checksum"];
492
- }
493
- if (output.headers["x-amz-checksum-algorithm"] !== undefined) {
494
- contents.ChecksumAlgorithm = output.headers["x-amz-checksum-algorithm"];
495
- }
393
+ Checksum: [, output.headers["x-amz-checksum"]],
394
+ ChecksumAlgorithm: [, output.headers["x-amz-checksum-algorithm"]],
395
+ });
496
396
  await collectBody(output.body, context);
497
- return Promise.resolve(contents);
397
+ return contents;
498
398
  };
499
399
  exports.deserializeAws_restJson1PutSnapshotBlockCommand = deserializeAws_restJson1PutSnapshotBlockCommand;
500
400
  const deserializeAws_restJson1PutSnapshotBlockCommandError = async (output, context) => {
@@ -502,7 +402,6 @@ const deserializeAws_restJson1PutSnapshotBlockCommandError = async (output, cont
502
402
  ...output,
503
403
  body: await parseBody(output.body, context),
504
404
  };
505
- let response;
506
405
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
507
406
  switch (errorCode) {
508
407
  case "AccessDeniedException":
@@ -525,65 +424,53 @@ const deserializeAws_restJson1PutSnapshotBlockCommandError = async (output, cont
525
424
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
526
425
  default:
527
426
  const parsedBody = parsedOutput.body;
528
- const $metadata = deserializeMetadata(output);
529
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
530
- response = new EBSServiceException_1.EBSServiceException({
531
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
532
- $fault: "client",
533
- $metadata,
427
+ (0, smithy_client_1.throwDefaultError)({
428
+ output,
429
+ parsedBody,
430
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
431
+ errorCode,
534
432
  });
535
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
536
433
  }
537
434
  };
538
435
  const deserializeAws_restJson1StartSnapshotCommand = async (output, context) => {
539
436
  if (output.statusCode !== 201 && output.statusCode >= 300) {
540
437
  return deserializeAws_restJson1StartSnapshotCommandError(output, context);
541
438
  }
542
- const contents = {
439
+ const contents = map({
543
440
  $metadata: deserializeMetadata(output),
544
- BlockSize: undefined,
545
- Description: undefined,
546
- KmsKeyArn: undefined,
547
- OwnerId: undefined,
548
- ParentSnapshotId: undefined,
549
- SnapshotId: undefined,
550
- StartTime: undefined,
551
- Status: undefined,
552
- Tags: undefined,
553
- VolumeSize: undefined,
554
- };
441
+ });
555
442
  const data = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.expectObject)(await parseBody(output.body, context)), "body");
556
- if (data.BlockSize !== undefined && data.BlockSize !== null) {
443
+ if (data.BlockSize != null) {
557
444
  contents.BlockSize = (0, smithy_client_1.expectInt32)(data.BlockSize);
558
445
  }
559
- if (data.Description !== undefined && data.Description !== null) {
446
+ if (data.Description != null) {
560
447
  contents.Description = (0, smithy_client_1.expectString)(data.Description);
561
448
  }
562
- if (data.KmsKeyArn !== undefined && data.KmsKeyArn !== null) {
449
+ if (data.KmsKeyArn != null) {
563
450
  contents.KmsKeyArn = (0, smithy_client_1.expectString)(data.KmsKeyArn);
564
451
  }
565
- if (data.OwnerId !== undefined && data.OwnerId !== null) {
452
+ if (data.OwnerId != null) {
566
453
  contents.OwnerId = (0, smithy_client_1.expectString)(data.OwnerId);
567
454
  }
568
- if (data.ParentSnapshotId !== undefined && data.ParentSnapshotId !== null) {
455
+ if (data.ParentSnapshotId != null) {
569
456
  contents.ParentSnapshotId = (0, smithy_client_1.expectString)(data.ParentSnapshotId);
570
457
  }
571
- if (data.SnapshotId !== undefined && data.SnapshotId !== null) {
458
+ if (data.SnapshotId != null) {
572
459
  contents.SnapshotId = (0, smithy_client_1.expectString)(data.SnapshotId);
573
460
  }
574
- if (data.StartTime !== undefined && data.StartTime !== null) {
461
+ if (data.StartTime != null) {
575
462
  contents.StartTime = (0, smithy_client_1.expectNonNull)((0, smithy_client_1.parseEpochTimestamp)((0, smithy_client_1.expectNumber)(data.StartTime)));
576
463
  }
577
- if (data.Status !== undefined && data.Status !== null) {
464
+ if (data.Status != null) {
578
465
  contents.Status = (0, smithy_client_1.expectString)(data.Status);
579
466
  }
580
- if (data.Tags !== undefined && data.Tags !== null) {
467
+ if (data.Tags != null) {
581
468
  contents.Tags = deserializeAws_restJson1Tags(data.Tags, context);
582
469
  }
583
- if (data.VolumeSize !== undefined && data.VolumeSize !== null) {
470
+ if (data.VolumeSize != null) {
584
471
  contents.VolumeSize = (0, smithy_client_1.expectLong)(data.VolumeSize);
585
472
  }
586
- return Promise.resolve(contents);
473
+ return contents;
587
474
  };
588
475
  exports.deserializeAws_restJson1StartSnapshotCommand = deserializeAws_restJson1StartSnapshotCommand;
589
476
  const deserializeAws_restJson1StartSnapshotCommandError = async (output, context) => {
@@ -591,7 +478,6 @@ const deserializeAws_restJson1StartSnapshotCommandError = async (output, context
591
478
  ...output,
592
479
  body: await parseBody(output.body, context),
593
480
  };
594
- let response;
595
481
  const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
596
482
  switch (errorCode) {
597
483
  case "AccessDeniedException":
@@ -620,23 +506,22 @@ const deserializeAws_restJson1StartSnapshotCommandError = async (output, context
620
506
  throw await deserializeAws_restJson1ValidationExceptionResponse(parsedOutput, context);
621
507
  default:
622
508
  const parsedBody = parsedOutput.body;
623
- const $metadata = deserializeMetadata(output);
624
- const statusCode = $metadata.httpStatusCode ? $metadata.httpStatusCode + "" : undefined;
625
- response = new EBSServiceException_1.EBSServiceException({
626
- name: parsedBody.code || parsedBody.Code || errorCode || statusCode || "UnknowError",
627
- $fault: "client",
628
- $metadata,
509
+ (0, smithy_client_1.throwDefaultError)({
510
+ output,
511
+ parsedBody,
512
+ exceptionCtor: EBSServiceException_1.EBSServiceException,
513
+ errorCode,
629
514
  });
630
- throw (0, smithy_client_1.decorateServiceException)(response, parsedBody);
631
515
  }
632
516
  };
517
+ const map = smithy_client_1.map;
633
518
  const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutput, context) => {
634
- const contents = {};
519
+ const contents = map({});
635
520
  const data = parsedOutput.body;
636
- if (data.Message !== undefined && data.Message !== null) {
521
+ if (data.Message != null) {
637
522
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
638
523
  }
639
- if (data.Reason !== undefined && data.Reason !== null) {
524
+ if (data.Reason != null) {
640
525
  contents.Reason = (0, smithy_client_1.expectString)(data.Reason);
641
526
  }
642
527
  const exception = new models_0_1.AccessDeniedException({
@@ -646,9 +531,9 @@ const deserializeAws_restJson1AccessDeniedExceptionResponse = async (parsedOutpu
646
531
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
647
532
  };
648
533
  const deserializeAws_restJson1ConcurrentLimitExceededExceptionResponse = async (parsedOutput, context) => {
649
- const contents = {};
534
+ const contents = map({});
650
535
  const data = parsedOutput.body;
651
- if (data.Message !== undefined && data.Message !== null) {
536
+ if (data.Message != null) {
652
537
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
653
538
  }
654
539
  const exception = new models_0_1.ConcurrentLimitExceededException({
@@ -658,9 +543,9 @@ const deserializeAws_restJson1ConcurrentLimitExceededExceptionResponse = async (
658
543
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
659
544
  };
660
545
  const deserializeAws_restJson1ConflictExceptionResponse = async (parsedOutput, context) => {
661
- const contents = {};
546
+ const contents = map({});
662
547
  const data = parsedOutput.body;
663
- if (data.Message !== undefined && data.Message !== null) {
548
+ if (data.Message != null) {
664
549
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
665
550
  }
666
551
  const exception = new models_0_1.ConflictException({
@@ -670,9 +555,9 @@ const deserializeAws_restJson1ConflictExceptionResponse = async (parsedOutput, c
670
555
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
671
556
  };
672
557
  const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOutput, context) => {
673
- const contents = {};
558
+ const contents = map({});
674
559
  const data = parsedOutput.body;
675
- if (data.Message !== undefined && data.Message !== null) {
560
+ if (data.Message != null) {
676
561
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
677
562
  }
678
563
  const exception = new models_0_1.InternalServerException({
@@ -682,12 +567,12 @@ const deserializeAws_restJson1InternalServerExceptionResponse = async (parsedOut
682
567
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
683
568
  };
684
569
  const deserializeAws_restJson1RequestThrottledExceptionResponse = async (parsedOutput, context) => {
685
- const contents = {};
570
+ const contents = map({});
686
571
  const data = parsedOutput.body;
687
- if (data.Message !== undefined && data.Message !== null) {
572
+ if (data.Message != null) {
688
573
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
689
574
  }
690
- if (data.Reason !== undefined && data.Reason !== null) {
575
+ if (data.Reason != null) {
691
576
  contents.Reason = (0, smithy_client_1.expectString)(data.Reason);
692
577
  }
693
578
  const exception = new models_0_1.RequestThrottledException({
@@ -697,12 +582,12 @@ const deserializeAws_restJson1RequestThrottledExceptionResponse = async (parsedO
697
582
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
698
583
  };
699
584
  const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedOutput, context) => {
700
- const contents = {};
585
+ const contents = map({});
701
586
  const data = parsedOutput.body;
702
- if (data.Message !== undefined && data.Message !== null) {
587
+ if (data.Message != null) {
703
588
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
704
589
  }
705
- if (data.Reason !== undefined && data.Reason !== null) {
590
+ if (data.Reason != null) {
706
591
  contents.Reason = (0, smithy_client_1.expectString)(data.Reason);
707
592
  }
708
593
  const exception = new models_0_1.ResourceNotFoundException({
@@ -712,12 +597,12 @@ const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedO
712
597
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
713
598
  };
714
599
  const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async (parsedOutput, context) => {
715
- const contents = {};
600
+ const contents = map({});
716
601
  const data = parsedOutput.body;
717
- if (data.Message !== undefined && data.Message !== null) {
602
+ if (data.Message != null) {
718
603
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
719
604
  }
720
- if (data.Reason !== undefined && data.Reason !== null) {
605
+ if (data.Reason != null) {
721
606
  contents.Reason = (0, smithy_client_1.expectString)(data.Reason);
722
607
  }
723
608
  const exception = new models_0_1.ServiceQuotaExceededException({
@@ -727,12 +612,12 @@ const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async (par
727
612
  return (0, smithy_client_1.decorateServiceException)(exception, parsedOutput.body);
728
613
  };
729
614
  const deserializeAws_restJson1ValidationExceptionResponse = async (parsedOutput, context) => {
730
- const contents = {};
615
+ const contents = map({});
731
616
  const data = parsedOutput.body;
732
- if (data.Message !== undefined && data.Message !== null) {
617
+ if (data.Message != null) {
733
618
  contents.Message = (0, smithy_client_1.expectString)(data.Message);
734
619
  }
735
- if (data.Reason !== undefined && data.Reason !== null) {
620
+ if (data.Reason != null) {
736
621
  contents.Reason = (0, smithy_client_1.expectString)(data.Reason);
737
622
  }
738
623
  const exception = new models_0_1.ValidationException({
@@ -751,9 +636,6 @@ const serializeAws_restJson1Tags = (input, context) => {
751
636
  return input
752
637
  .filter((e) => e != null)
753
638
  .map((entry) => {
754
- if (entry === null) {
755
- return null;
756
- }
757
639
  return serializeAws_restJson1Tag(entry, context);
758
640
  });
759
641
  };