@aws-sdk/client-sso 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,445 +1,319 @@
1
- import { __assign, __awaiter, __generator } from "tslib";
2
1
  import { HttpRequest as __HttpRequest } from "@aws-sdk/protocol-http";
3
2
  import { decorateServiceException as __decorateServiceException, expectLong as __expectLong, expectNonNull as __expectNonNull, expectObject as __expectObject, expectString as __expectString, map as __map, throwDefaultError, } from "@aws-sdk/smithy-client";
4
3
  import { InvalidRequestException, ResourceNotFoundException, TooManyRequestsException, UnauthorizedException, } from "../models/models_0";
5
4
  import { SSOServiceException as __BaseException } from "../models/SSOServiceException";
6
- export var serializeAws_restJson1GetRoleCredentialsCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
7
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, query, 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
- "x-amz-sso_bearer_token": input.accessToken,
15
- });
16
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/federation/credentials";
17
- query = map({
18
- role_name: [, input.roleName],
19
- account_id: [, input.accountId],
20
- });
21
- return [2, new __HttpRequest({
22
- protocol: protocol,
23
- hostname: hostname,
24
- port: port,
25
- method: "GET",
26
- headers: headers,
27
- path: resolvedPath,
28
- query: query,
29
- body: body,
30
- })];
31
- }
5
+ export const serializeAws_restJson1GetRoleCredentialsCommand = async (input, context) => {
6
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
7
+ const headers = map({}, isSerializableHeaderValue, {
8
+ "x-amz-sso_bearer_token": input.accessToken,
32
9
  });
33
- }); };
34
- export var serializeAws_restJson1ListAccountRolesCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
35
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, query, body;
36
- return __generator(this, function (_c) {
37
- switch (_c.label) {
38
- case 0: return [4, context.endpoint()];
39
- case 1:
40
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
41
- headers = map({}, isSerializableHeaderValue, {
42
- "x-amz-sso_bearer_token": input.accessToken,
43
- });
44
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/assignment/roles";
45
- query = map({
46
- next_token: [, input.nextToken],
47
- max_result: [function () { return input.maxResults !== void 0; }, function () { return input.maxResults.toString(); }],
48
- account_id: [, input.accountId],
49
- });
50
- return [2, new __HttpRequest({
51
- protocol: protocol,
52
- hostname: hostname,
53
- port: port,
54
- method: "GET",
55
- headers: headers,
56
- path: resolvedPath,
57
- query: query,
58
- body: body,
59
- })];
60
- }
10
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/federation/credentials";
11
+ const query = map({
12
+ role_name: [, input.roleName],
13
+ account_id: [, input.accountId],
61
14
  });
62
- }); };
63
- export var serializeAws_restJson1ListAccountsCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
64
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, query, body;
65
- return __generator(this, function (_c) {
66
- switch (_c.label) {
67
- case 0: return [4, context.endpoint()];
68
- case 1:
69
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
70
- headers = map({}, isSerializableHeaderValue, {
71
- "x-amz-sso_bearer_token": input.accessToken,
72
- });
73
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/assignment/accounts";
74
- query = map({
75
- next_token: [, input.nextToken],
76
- max_result: [function () { return input.maxResults !== void 0; }, function () { return input.maxResults.toString(); }],
77
- });
78
- return [2, new __HttpRequest({
79
- protocol: protocol,
80
- hostname: hostname,
81
- port: port,
82
- method: "GET",
83
- headers: headers,
84
- path: resolvedPath,
85
- query: query,
86
- body: body,
87
- })];
88
- }
15
+ let body;
16
+ return new __HttpRequest({
17
+ protocol,
18
+ hostname,
19
+ port,
20
+ method: "GET",
21
+ headers,
22
+ path: resolvedPath,
23
+ query,
24
+ body,
89
25
  });
90
- }); };
91
- export var serializeAws_restJson1LogoutCommand = function (input, context) { return __awaiter(void 0, void 0, void 0, function () {
92
- var _a, hostname, _b, protocol, port, basePath, headers, resolvedPath, body;
93
- return __generator(this, function (_c) {
94
- switch (_c.label) {
95
- case 0: return [4, context.endpoint()];
96
- case 1:
97
- _a = _c.sent(), hostname = _a.hostname, _b = _a.protocol, protocol = _b === void 0 ? "https" : _b, port = _a.port, basePath = _a.path;
98
- headers = map({}, isSerializableHeaderValue, {
99
- "x-amz-sso_bearer_token": input.accessToken,
100
- });
101
- resolvedPath = "".concat((basePath === null || basePath === void 0 ? void 0 : basePath.endsWith("/")) ? basePath.slice(0, -1) : basePath || "") + "/logout";
102
- return [2, new __HttpRequest({
103
- protocol: protocol,
104
- hostname: hostname,
105
- port: port,
106
- method: "POST",
107
- headers: headers,
108
- path: resolvedPath,
109
- body: body,
110
- })];
111
- }
26
+ };
27
+ export const serializeAws_restJson1ListAccountRolesCommand = async (input, context) => {
28
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
29
+ const headers = map({}, isSerializableHeaderValue, {
30
+ "x-amz-sso_bearer_token": input.accessToken,
112
31
  });
113
- }); };
114
- export var deserializeAws_restJson1GetRoleCredentialsCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
115
- var contents, data, _a, _b;
116
- return __generator(this, function (_c) {
117
- switch (_c.label) {
118
- case 0:
119
- if (output.statusCode !== 200 && output.statusCode >= 300) {
120
- return [2, deserializeAws_restJson1GetRoleCredentialsCommandError(output, context)];
121
- }
122
- contents = map({
123
- $metadata: deserializeMetadata(output),
124
- });
125
- _a = __expectNonNull;
126
- _b = __expectObject;
127
- return [4, parseBody(output.body, context)];
128
- case 1:
129
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
130
- if (data.roleCredentials != null) {
131
- contents.roleCredentials = deserializeAws_restJson1RoleCredentials(data.roleCredentials, context);
132
- }
133
- return [2, contents];
134
- }
32
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/assignment/roles";
33
+ const query = map({
34
+ next_token: [, input.nextToken],
35
+ max_result: [() => input.maxResults !== void 0, () => input.maxResults.toString()],
36
+ account_id: [, input.accountId],
135
37
  });
136
- }); };
137
- var deserializeAws_restJson1GetRoleCredentialsCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
138
- var parsedOutput, _a, errorCode, _b, parsedBody;
139
- var _c;
140
- return __generator(this, function (_d) {
141
- switch (_d.label) {
142
- case 0:
143
- _a = [__assign({}, output)];
144
- _c = {};
145
- return [4, parseErrorBody(output.body, context)];
146
- case 1:
147
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
148
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
149
- _b = errorCode;
150
- switch (_b) {
151
- case "InvalidRequestException": return [3, 2];
152
- case "com.amazonaws.sso#InvalidRequestException": return [3, 2];
153
- case "ResourceNotFoundException": return [3, 4];
154
- case "com.amazonaws.sso#ResourceNotFoundException": return [3, 4];
155
- case "TooManyRequestsException": return [3, 6];
156
- case "com.amazonaws.sso#TooManyRequestsException": return [3, 6];
157
- case "UnauthorizedException": return [3, 8];
158
- case "com.amazonaws.sso#UnauthorizedException": return [3, 8];
159
- }
160
- return [3, 10];
161
- case 2: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
162
- case 3: throw _d.sent();
163
- case 4: return [4, deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)];
164
- case 5: throw _d.sent();
165
- case 6: return [4, deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)];
166
- case 7: throw _d.sent();
167
- case 8: return [4, deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)];
168
- case 9: throw _d.sent();
169
- case 10:
170
- parsedBody = parsedOutput.body;
171
- throwDefaultError({
172
- output: output,
173
- parsedBody: parsedBody,
174
- exceptionCtor: __BaseException,
175
- errorCode: errorCode,
176
- });
177
- _d.label = 11;
178
- case 11: return [2];
179
- }
38
+ let body;
39
+ return new __HttpRequest({
40
+ protocol,
41
+ hostname,
42
+ port,
43
+ method: "GET",
44
+ headers,
45
+ path: resolvedPath,
46
+ query,
47
+ body,
180
48
  });
181
- }); };
182
- export var deserializeAws_restJson1ListAccountRolesCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
183
- var contents, data, _a, _b;
184
- return __generator(this, function (_c) {
185
- switch (_c.label) {
186
- case 0:
187
- if (output.statusCode !== 200 && output.statusCode >= 300) {
188
- return [2, deserializeAws_restJson1ListAccountRolesCommandError(output, context)];
189
- }
190
- contents = map({
191
- $metadata: deserializeMetadata(output),
192
- });
193
- _a = __expectNonNull;
194
- _b = __expectObject;
195
- return [4, parseBody(output.body, context)];
196
- case 1:
197
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
198
- if (data.nextToken != null) {
199
- contents.nextToken = __expectString(data.nextToken);
200
- }
201
- if (data.roleList != null) {
202
- contents.roleList = deserializeAws_restJson1RoleListType(data.roleList, context);
203
- }
204
- return [2, contents];
205
- }
49
+ };
50
+ export const serializeAws_restJson1ListAccountsCommand = async (input, context) => {
51
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
52
+ const headers = map({}, isSerializableHeaderValue, {
53
+ "x-amz-sso_bearer_token": input.accessToken,
206
54
  });
207
- }); };
208
- var deserializeAws_restJson1ListAccountRolesCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
209
- var parsedOutput, _a, errorCode, _b, parsedBody;
210
- var _c;
211
- return __generator(this, function (_d) {
212
- switch (_d.label) {
213
- case 0:
214
- _a = [__assign({}, output)];
215
- _c = {};
216
- return [4, parseErrorBody(output.body, context)];
217
- case 1:
218
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
219
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
220
- _b = errorCode;
221
- switch (_b) {
222
- case "InvalidRequestException": return [3, 2];
223
- case "com.amazonaws.sso#InvalidRequestException": return [3, 2];
224
- case "ResourceNotFoundException": return [3, 4];
225
- case "com.amazonaws.sso#ResourceNotFoundException": return [3, 4];
226
- case "TooManyRequestsException": return [3, 6];
227
- case "com.amazonaws.sso#TooManyRequestsException": return [3, 6];
228
- case "UnauthorizedException": return [3, 8];
229
- case "com.amazonaws.sso#UnauthorizedException": return [3, 8];
230
- }
231
- return [3, 10];
232
- case 2: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
233
- case 3: throw _d.sent();
234
- case 4: return [4, deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)];
235
- case 5: throw _d.sent();
236
- case 6: return [4, deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)];
237
- case 7: throw _d.sent();
238
- case 8: return [4, deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)];
239
- case 9: throw _d.sent();
240
- case 10:
241
- parsedBody = parsedOutput.body;
242
- throwDefaultError({
243
- output: output,
244
- parsedBody: parsedBody,
245
- exceptionCtor: __BaseException,
246
- errorCode: errorCode,
247
- });
248
- _d.label = 11;
249
- case 11: return [2];
250
- }
55
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/assignment/accounts";
56
+ const query = map({
57
+ next_token: [, input.nextToken],
58
+ max_result: [() => input.maxResults !== void 0, () => input.maxResults.toString()],
251
59
  });
252
- }); };
253
- export var deserializeAws_restJson1ListAccountsCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
254
- var contents, data, _a, _b;
255
- return __generator(this, function (_c) {
256
- switch (_c.label) {
257
- case 0:
258
- if (output.statusCode !== 200 && output.statusCode >= 300) {
259
- return [2, deserializeAws_restJson1ListAccountsCommandError(output, context)];
260
- }
261
- contents = map({
262
- $metadata: deserializeMetadata(output),
263
- });
264
- _a = __expectNonNull;
265
- _b = __expectObject;
266
- return [4, parseBody(output.body, context)];
267
- case 1:
268
- data = _a.apply(void 0, [_b.apply(void 0, [_c.sent()]), "body"]);
269
- if (data.accountList != null) {
270
- contents.accountList = deserializeAws_restJson1AccountListType(data.accountList, context);
271
- }
272
- if (data.nextToken != null) {
273
- contents.nextToken = __expectString(data.nextToken);
274
- }
275
- return [2, contents];
276
- }
60
+ let body;
61
+ return new __HttpRequest({
62
+ protocol,
63
+ hostname,
64
+ port,
65
+ method: "GET",
66
+ headers,
67
+ path: resolvedPath,
68
+ query,
69
+ body,
277
70
  });
278
- }); };
279
- var deserializeAws_restJson1ListAccountsCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
280
- var parsedOutput, _a, errorCode, _b, parsedBody;
281
- var _c;
282
- return __generator(this, function (_d) {
283
- switch (_d.label) {
284
- case 0:
285
- _a = [__assign({}, output)];
286
- _c = {};
287
- return [4, parseErrorBody(output.body, context)];
288
- case 1:
289
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
290
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
291
- _b = errorCode;
292
- switch (_b) {
293
- case "InvalidRequestException": return [3, 2];
294
- case "com.amazonaws.sso#InvalidRequestException": return [3, 2];
295
- case "ResourceNotFoundException": return [3, 4];
296
- case "com.amazonaws.sso#ResourceNotFoundException": return [3, 4];
297
- case "TooManyRequestsException": return [3, 6];
298
- case "com.amazonaws.sso#TooManyRequestsException": return [3, 6];
299
- case "UnauthorizedException": return [3, 8];
300
- case "com.amazonaws.sso#UnauthorizedException": return [3, 8];
301
- }
302
- return [3, 10];
303
- case 2: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
304
- case 3: throw _d.sent();
305
- case 4: return [4, deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context)];
306
- case 5: throw _d.sent();
307
- case 6: return [4, deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)];
308
- case 7: throw _d.sent();
309
- case 8: return [4, deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)];
310
- case 9: throw _d.sent();
311
- case 10:
312
- parsedBody = parsedOutput.body;
313
- throwDefaultError({
314
- output: output,
315
- parsedBody: parsedBody,
316
- exceptionCtor: __BaseException,
317
- errorCode: errorCode,
318
- });
319
- _d.label = 11;
320
- case 11: return [2];
321
- }
71
+ };
72
+ export const serializeAws_restJson1LogoutCommand = async (input, context) => {
73
+ const { hostname, protocol = "https", port, path: basePath } = await context.endpoint();
74
+ const headers = map({}, isSerializableHeaderValue, {
75
+ "x-amz-sso_bearer_token": input.accessToken,
322
76
  });
323
- }); };
324
- export var deserializeAws_restJson1LogoutCommand = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
325
- var contents;
326
- return __generator(this, function (_a) {
327
- switch (_a.label) {
328
- case 0:
329
- if (output.statusCode !== 200 && output.statusCode >= 300) {
330
- return [2, deserializeAws_restJson1LogoutCommandError(output, context)];
331
- }
332
- contents = map({
333
- $metadata: deserializeMetadata(output),
334
- });
335
- return [4, collectBody(output.body, context)];
336
- case 1:
337
- _a.sent();
338
- return [2, contents];
339
- }
77
+ const resolvedPath = `${basePath?.endsWith("/") ? basePath.slice(0, -1) : basePath || ""}` + "/logout";
78
+ let body;
79
+ return new __HttpRequest({
80
+ protocol,
81
+ hostname,
82
+ port,
83
+ method: "POST",
84
+ headers,
85
+ path: resolvedPath,
86
+ body,
340
87
  });
341
- }); };
342
- var deserializeAws_restJson1LogoutCommandError = function (output, context) { return __awaiter(void 0, void 0, void 0, function () {
343
- var parsedOutput, _a, errorCode, _b, parsedBody;
344
- var _c;
345
- return __generator(this, function (_d) {
346
- switch (_d.label) {
347
- case 0:
348
- _a = [__assign({}, output)];
349
- _c = {};
350
- return [4, parseErrorBody(output.body, context)];
351
- case 1:
352
- parsedOutput = __assign.apply(void 0, _a.concat([(_c.body = _d.sent(), _c)]));
353
- errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
354
- _b = errorCode;
355
- switch (_b) {
356
- case "InvalidRequestException": return [3, 2];
357
- case "com.amazonaws.sso#InvalidRequestException": return [3, 2];
358
- case "TooManyRequestsException": return [3, 4];
359
- case "com.amazonaws.sso#TooManyRequestsException": return [3, 4];
360
- case "UnauthorizedException": return [3, 6];
361
- case "com.amazonaws.sso#UnauthorizedException": return [3, 6];
362
- }
363
- return [3, 8];
364
- case 2: return [4, deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context)];
365
- case 3: throw _d.sent();
366
- case 4: return [4, deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)];
367
- case 5: throw _d.sent();
368
- case 6: return [4, deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)];
369
- case 7: throw _d.sent();
370
- case 8:
371
- parsedBody = parsedOutput.body;
372
- throwDefaultError({
373
- output: output,
374
- parsedBody: parsedBody,
375
- exceptionCtor: __BaseException,
376
- errorCode: errorCode,
377
- });
378
- _d.label = 9;
379
- case 9: return [2];
380
- }
88
+ };
89
+ export const deserializeAws_restJson1GetRoleCredentialsCommand = async (output, context) => {
90
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
91
+ return deserializeAws_restJson1GetRoleCredentialsCommandError(output, context);
92
+ }
93
+ const contents = map({
94
+ $metadata: deserializeMetadata(output),
381
95
  });
382
- }); };
383
- var map = __map;
384
- var deserializeAws_restJson1InvalidRequestExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
385
- var contents, data, exception;
386
- return __generator(this, function (_a) {
387
- contents = map({});
388
- data = parsedOutput.body;
389
- if (data.message != null) {
390
- contents.message = __expectString(data.message);
391
- }
392
- exception = new InvalidRequestException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
393
- return [2, __decorateServiceException(exception, parsedOutput.body)];
96
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
97
+ if (data.roleCredentials != null) {
98
+ contents.roleCredentials = deserializeAws_restJson1RoleCredentials(data.roleCredentials, context);
99
+ }
100
+ return contents;
101
+ };
102
+ const deserializeAws_restJson1GetRoleCredentialsCommandError = async (output, context) => {
103
+ const parsedOutput = {
104
+ ...output,
105
+ body: await parseErrorBody(output.body, context),
106
+ };
107
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
108
+ switch (errorCode) {
109
+ case "InvalidRequestException":
110
+ case "com.amazonaws.sso#InvalidRequestException":
111
+ throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
112
+ case "ResourceNotFoundException":
113
+ case "com.amazonaws.sso#ResourceNotFoundException":
114
+ throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
115
+ case "TooManyRequestsException":
116
+ case "com.amazonaws.sso#TooManyRequestsException":
117
+ throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context);
118
+ case "UnauthorizedException":
119
+ case "com.amazonaws.sso#UnauthorizedException":
120
+ throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context);
121
+ default:
122
+ const parsedBody = parsedOutput.body;
123
+ throwDefaultError({
124
+ output,
125
+ parsedBody,
126
+ exceptionCtor: __BaseException,
127
+ errorCode,
128
+ });
129
+ }
130
+ };
131
+ export const deserializeAws_restJson1ListAccountRolesCommand = async (output, context) => {
132
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
133
+ return deserializeAws_restJson1ListAccountRolesCommandError(output, context);
134
+ }
135
+ const contents = map({
136
+ $metadata: deserializeMetadata(output),
394
137
  });
395
- }); };
396
- var deserializeAws_restJson1ResourceNotFoundExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
397
- var contents, data, exception;
398
- return __generator(this, function (_a) {
399
- contents = map({});
400
- data = parsedOutput.body;
401
- if (data.message != null) {
402
- contents.message = __expectString(data.message);
403
- }
404
- exception = new ResourceNotFoundException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
405
- return [2, __decorateServiceException(exception, parsedOutput.body)];
138
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
139
+ if (data.nextToken != null) {
140
+ contents.nextToken = __expectString(data.nextToken);
141
+ }
142
+ if (data.roleList != null) {
143
+ contents.roleList = deserializeAws_restJson1RoleListType(data.roleList, context);
144
+ }
145
+ return contents;
146
+ };
147
+ const deserializeAws_restJson1ListAccountRolesCommandError = async (output, context) => {
148
+ const parsedOutput = {
149
+ ...output,
150
+ body: await parseErrorBody(output.body, context),
151
+ };
152
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
153
+ switch (errorCode) {
154
+ case "InvalidRequestException":
155
+ case "com.amazonaws.sso#InvalidRequestException":
156
+ throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
157
+ case "ResourceNotFoundException":
158
+ case "com.amazonaws.sso#ResourceNotFoundException":
159
+ throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
160
+ case "TooManyRequestsException":
161
+ case "com.amazonaws.sso#TooManyRequestsException":
162
+ throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context);
163
+ case "UnauthorizedException":
164
+ case "com.amazonaws.sso#UnauthorizedException":
165
+ throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context);
166
+ default:
167
+ const parsedBody = parsedOutput.body;
168
+ throwDefaultError({
169
+ output,
170
+ parsedBody,
171
+ exceptionCtor: __BaseException,
172
+ errorCode,
173
+ });
174
+ }
175
+ };
176
+ export const deserializeAws_restJson1ListAccountsCommand = async (output, context) => {
177
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
178
+ return deserializeAws_restJson1ListAccountsCommandError(output, context);
179
+ }
180
+ const contents = map({
181
+ $metadata: deserializeMetadata(output),
406
182
  });
407
- }); };
408
- var deserializeAws_restJson1TooManyRequestsExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
409
- var contents, data, exception;
410
- return __generator(this, function (_a) {
411
- contents = map({});
412
- data = parsedOutput.body;
413
- if (data.message != null) {
414
- contents.message = __expectString(data.message);
415
- }
416
- exception = new TooManyRequestsException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
417
- return [2, __decorateServiceException(exception, parsedOutput.body)];
183
+ const data = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
184
+ if (data.accountList != null) {
185
+ contents.accountList = deserializeAws_restJson1AccountListType(data.accountList, context);
186
+ }
187
+ if (data.nextToken != null) {
188
+ contents.nextToken = __expectString(data.nextToken);
189
+ }
190
+ return contents;
191
+ };
192
+ const deserializeAws_restJson1ListAccountsCommandError = async (output, context) => {
193
+ const parsedOutput = {
194
+ ...output,
195
+ body: await parseErrorBody(output.body, context),
196
+ };
197
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
198
+ switch (errorCode) {
199
+ case "InvalidRequestException":
200
+ case "com.amazonaws.sso#InvalidRequestException":
201
+ throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
202
+ case "ResourceNotFoundException":
203
+ case "com.amazonaws.sso#ResourceNotFoundException":
204
+ throw await deserializeAws_restJson1ResourceNotFoundExceptionResponse(parsedOutput, context);
205
+ case "TooManyRequestsException":
206
+ case "com.amazonaws.sso#TooManyRequestsException":
207
+ throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context);
208
+ case "UnauthorizedException":
209
+ case "com.amazonaws.sso#UnauthorizedException":
210
+ throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context);
211
+ default:
212
+ const parsedBody = parsedOutput.body;
213
+ throwDefaultError({
214
+ output,
215
+ parsedBody,
216
+ exceptionCtor: __BaseException,
217
+ errorCode,
218
+ });
219
+ }
220
+ };
221
+ export const deserializeAws_restJson1LogoutCommand = async (output, context) => {
222
+ if (output.statusCode !== 200 && output.statusCode >= 300) {
223
+ return deserializeAws_restJson1LogoutCommandError(output, context);
224
+ }
225
+ const contents = map({
226
+ $metadata: deserializeMetadata(output),
418
227
  });
419
- }); };
420
- var deserializeAws_restJson1UnauthorizedExceptionResponse = function (parsedOutput, context) { return __awaiter(void 0, void 0, void 0, function () {
421
- var contents, data, exception;
422
- return __generator(this, function (_a) {
423
- contents = map({});
424
- data = parsedOutput.body;
425
- if (data.message != null) {
426
- contents.message = __expectString(data.message);
427
- }
428
- exception = new UnauthorizedException(__assign({ $metadata: deserializeMetadata(parsedOutput) }, contents));
429
- return [2, __decorateServiceException(exception, parsedOutput.body)];
228
+ await collectBody(output.body, context);
229
+ return contents;
230
+ };
231
+ const deserializeAws_restJson1LogoutCommandError = async (output, context) => {
232
+ const parsedOutput = {
233
+ ...output,
234
+ body: await parseErrorBody(output.body, context),
235
+ };
236
+ const errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
237
+ switch (errorCode) {
238
+ case "InvalidRequestException":
239
+ case "com.amazonaws.sso#InvalidRequestException":
240
+ throw await deserializeAws_restJson1InvalidRequestExceptionResponse(parsedOutput, context);
241
+ case "TooManyRequestsException":
242
+ case "com.amazonaws.sso#TooManyRequestsException":
243
+ throw await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context);
244
+ case "UnauthorizedException":
245
+ case "com.amazonaws.sso#UnauthorizedException":
246
+ throw await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context);
247
+ default:
248
+ const parsedBody = parsedOutput.body;
249
+ throwDefaultError({
250
+ output,
251
+ parsedBody,
252
+ exceptionCtor: __BaseException,
253
+ errorCode,
254
+ });
255
+ }
256
+ };
257
+ const map = __map;
258
+ const deserializeAws_restJson1InvalidRequestExceptionResponse = async (parsedOutput, context) => {
259
+ const contents = map({});
260
+ const data = parsedOutput.body;
261
+ if (data.message != null) {
262
+ contents.message = __expectString(data.message);
263
+ }
264
+ const exception = new InvalidRequestException({
265
+ $metadata: deserializeMetadata(parsedOutput),
266
+ ...contents,
267
+ });
268
+ return __decorateServiceException(exception, parsedOutput.body);
269
+ };
270
+ const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async (parsedOutput, context) => {
271
+ const contents = map({});
272
+ const data = parsedOutput.body;
273
+ if (data.message != null) {
274
+ contents.message = __expectString(data.message);
275
+ }
276
+ const exception = new ResourceNotFoundException({
277
+ $metadata: deserializeMetadata(parsedOutput),
278
+ ...contents,
430
279
  });
431
- }); };
432
- var deserializeAws_restJson1AccountInfo = function (output, context) {
280
+ return __decorateServiceException(exception, parsedOutput.body);
281
+ };
282
+ const deserializeAws_restJson1TooManyRequestsExceptionResponse = async (parsedOutput, context) => {
283
+ const contents = map({});
284
+ const data = parsedOutput.body;
285
+ if (data.message != null) {
286
+ contents.message = __expectString(data.message);
287
+ }
288
+ const exception = new TooManyRequestsException({
289
+ $metadata: deserializeMetadata(parsedOutput),
290
+ ...contents,
291
+ });
292
+ return __decorateServiceException(exception, parsedOutput.body);
293
+ };
294
+ const deserializeAws_restJson1UnauthorizedExceptionResponse = async (parsedOutput, context) => {
295
+ const contents = map({});
296
+ const data = parsedOutput.body;
297
+ if (data.message != null) {
298
+ contents.message = __expectString(data.message);
299
+ }
300
+ const exception = new UnauthorizedException({
301
+ $metadata: deserializeMetadata(parsedOutput),
302
+ ...contents,
303
+ });
304
+ return __decorateServiceException(exception, parsedOutput.body);
305
+ };
306
+ const deserializeAws_restJson1AccountInfo = (output, context) => {
433
307
  return {
434
308
  accountId: __expectString(output.accountId),
435
309
  accountName: __expectString(output.accountName),
436
310
  emailAddress: __expectString(output.emailAddress),
437
311
  };
438
312
  };
439
- var deserializeAws_restJson1AccountListType = function (output, context) {
440
- var retVal = (output || [])
441
- .filter(function (e) { return e != null; })
442
- .map(function (entry) {
313
+ const deserializeAws_restJson1AccountListType = (output, context) => {
314
+ const retVal = (output || [])
315
+ .filter((e) => e != null)
316
+ .map((entry) => {
443
317
  if (entry === null) {
444
318
  return null;
445
319
  }
@@ -447,7 +321,7 @@ var deserializeAws_restJson1AccountListType = function (output, context) {
447
321
  });
448
322
  return retVal;
449
323
  };
450
- var deserializeAws_restJson1RoleCredentials = function (output, context) {
324
+ const deserializeAws_restJson1RoleCredentials = (output, context) => {
451
325
  return {
452
326
  accessKeyId: __expectString(output.accessKeyId),
453
327
  expiration: __expectLong(output.expiration),
@@ -455,16 +329,16 @@ var deserializeAws_restJson1RoleCredentials = function (output, context) {
455
329
  sessionToken: __expectString(output.sessionToken),
456
330
  };
457
331
  };
458
- var deserializeAws_restJson1RoleInfo = function (output, context) {
332
+ const deserializeAws_restJson1RoleInfo = (output, context) => {
459
333
  return {
460
334
  accountId: __expectString(output.accountId),
461
335
  roleName: __expectString(output.roleName),
462
336
  };
463
337
  };
464
- var deserializeAws_restJson1RoleListType = function (output, context) {
465
- var retVal = (output || [])
466
- .filter(function (e) { return e != null; })
467
- .map(function (entry) {
338
+ const deserializeAws_restJson1RoleListType = (output, context) => {
339
+ const retVal = (output || [])
340
+ .filter((e) => e != null)
341
+ .map((entry) => {
468
342
  if (entry === null) {
469
343
  return null;
470
344
  }
@@ -472,57 +346,39 @@ var deserializeAws_restJson1RoleListType = function (output, context) {
472
346
  });
473
347
  return retVal;
474
348
  };
475
- var deserializeMetadata = function (output) {
476
- var _a;
477
- return ({
478
- httpStatusCode: output.statusCode,
479
- requestId: (_a = output.headers["x-amzn-requestid"]) !== null && _a !== void 0 ? _a : output.headers["x-amzn-request-id"],
480
- extendedRequestId: output.headers["x-amz-id-2"],
481
- cfId: output.headers["x-amz-cf-id"],
482
- });
483
- };
484
- var collectBody = function (streamBody, context) {
485
- if (streamBody === void 0) { streamBody = new Uint8Array(); }
349
+ const deserializeMetadata = (output) => ({
350
+ httpStatusCode: output.statusCode,
351
+ requestId: output.headers["x-amzn-requestid"] ?? output.headers["x-amzn-request-id"],
352
+ extendedRequestId: output.headers["x-amz-id-2"],
353
+ cfId: output.headers["x-amz-cf-id"],
354
+ });
355
+ const collectBody = (streamBody = new Uint8Array(), context) => {
486
356
  if (streamBody instanceof Uint8Array) {
487
357
  return Promise.resolve(streamBody);
488
358
  }
489
359
  return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
490
360
  };
491
- var collectBodyString = function (streamBody, context) {
492
- return collectBody(streamBody, context).then(function (body) { return context.utf8Encoder(body); });
493
- };
494
- var isSerializableHeaderValue = function (value) {
495
- return value !== undefined &&
496
- value !== null &&
497
- value !== "" &&
498
- (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
499
- (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
500
- };
501
- var parseBody = function (streamBody, context) {
502
- return collectBodyString(streamBody, context).then(function (encoded) {
503
- if (encoded.length) {
504
- return JSON.parse(encoded);
505
- }
506
- return {};
507
- });
361
+ const collectBodyString = (streamBody, context) => collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
362
+ const isSerializableHeaderValue = (value) => value !== undefined &&
363
+ value !== null &&
364
+ value !== "" &&
365
+ (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
366
+ (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
367
+ const parseBody = (streamBody, context) => collectBodyString(streamBody, context).then((encoded) => {
368
+ if (encoded.length) {
369
+ return JSON.parse(encoded);
370
+ }
371
+ return {};
372
+ });
373
+ const parseErrorBody = async (errorBody, context) => {
374
+ const value = await parseBody(errorBody, context);
375
+ value.message = value.message ?? value.Message;
376
+ return value;
508
377
  };
509
- var parseErrorBody = function (errorBody, context) { return __awaiter(void 0, void 0, void 0, function () {
510
- var value;
511
- var _a;
512
- return __generator(this, function (_b) {
513
- switch (_b.label) {
514
- case 0: return [4, parseBody(errorBody, context)];
515
- case 1:
516
- value = _b.sent();
517
- value.message = (_a = value.message) !== null && _a !== void 0 ? _a : value.Message;
518
- return [2, value];
519
- }
520
- });
521
- }); };
522
- var loadRestJsonErrorCode = function (output, data) {
523
- var findKey = function (object, key) { return Object.keys(object).find(function (k) { return k.toLowerCase() === key.toLowerCase(); }); };
524
- var sanitizeErrorCode = function (rawValue) {
525
- var cleanValue = rawValue;
378
+ const loadRestJsonErrorCode = (output, data) => {
379
+ const findKey = (object, key) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
380
+ const sanitizeErrorCode = (rawValue) => {
381
+ let cleanValue = rawValue;
526
382
  if (typeof cleanValue === "number") {
527
383
  cleanValue = cleanValue.toString();
528
384
  }
@@ -537,7 +393,7 @@ var loadRestJsonErrorCode = function (output, data) {
537
393
  }
538
394
  return cleanValue;
539
395
  };
540
- var headerKey = findKey(output.headers, "x-amzn-errortype");
396
+ const headerKey = findKey(output.headers, "x-amzn-errortype");
541
397
  if (headerKey !== undefined) {
542
398
  return sanitizeErrorCode(output.headers[headerKey]);
543
399
  }