/clients/client-api-gateway/protocols/Aws_restJson1.ts

https://github.com/aws/aws-sdk-js-v3 · TypeScript · 18708 lines · 18236 code · 467 blank · 5 comment · 7969 complexity · ad9dc544741b25018143ae03da46eb9b MD5 · raw file

  1. import { CreateApiKeyCommandInput, CreateApiKeyCommandOutput } from "../commands/CreateApiKeyCommand";
  2. import { CreateAuthorizerCommandInput, CreateAuthorizerCommandOutput } from "../commands/CreateAuthorizerCommand";
  3. import {
  4. CreateBasePathMappingCommandInput,
  5. CreateBasePathMappingCommandOutput,
  6. } from "../commands/CreateBasePathMappingCommand";
  7. import { CreateDeploymentCommandInput, CreateDeploymentCommandOutput } from "../commands/CreateDeploymentCommand";
  8. import {
  9. CreateDocumentationPartCommandInput,
  10. CreateDocumentationPartCommandOutput,
  11. } from "../commands/CreateDocumentationPartCommand";
  12. import {
  13. CreateDocumentationVersionCommandInput,
  14. CreateDocumentationVersionCommandOutput,
  15. } from "../commands/CreateDocumentationVersionCommand";
  16. import { CreateDomainNameCommandInput, CreateDomainNameCommandOutput } from "../commands/CreateDomainNameCommand";
  17. import { CreateModelCommandInput, CreateModelCommandOutput } from "../commands/CreateModelCommand";
  18. import {
  19. CreateRequestValidatorCommandInput,
  20. CreateRequestValidatorCommandOutput,
  21. } from "../commands/CreateRequestValidatorCommand";
  22. import { CreateResourceCommandInput, CreateResourceCommandOutput } from "../commands/CreateResourceCommand";
  23. import { CreateRestApiCommandInput, CreateRestApiCommandOutput } from "../commands/CreateRestApiCommand";
  24. import { CreateStageCommandInput, CreateStageCommandOutput } from "../commands/CreateStageCommand";
  25. import { CreateUsagePlanCommandInput, CreateUsagePlanCommandOutput } from "../commands/CreateUsagePlanCommand";
  26. import { CreateUsagePlanKeyCommandInput, CreateUsagePlanKeyCommandOutput } from "../commands/CreateUsagePlanKeyCommand";
  27. import { CreateVpcLinkCommandInput, CreateVpcLinkCommandOutput } from "../commands/CreateVpcLinkCommand";
  28. import { DeleteApiKeyCommandInput, DeleteApiKeyCommandOutput } from "../commands/DeleteApiKeyCommand";
  29. import { DeleteAuthorizerCommandInput, DeleteAuthorizerCommandOutput } from "../commands/DeleteAuthorizerCommand";
  30. import {
  31. DeleteBasePathMappingCommandInput,
  32. DeleteBasePathMappingCommandOutput,
  33. } from "../commands/DeleteBasePathMappingCommand";
  34. import {
  35. DeleteClientCertificateCommandInput,
  36. DeleteClientCertificateCommandOutput,
  37. } from "../commands/DeleteClientCertificateCommand";
  38. import { DeleteDeploymentCommandInput, DeleteDeploymentCommandOutput } from "../commands/DeleteDeploymentCommand";
  39. import {
  40. DeleteDocumentationPartCommandInput,
  41. DeleteDocumentationPartCommandOutput,
  42. } from "../commands/DeleteDocumentationPartCommand";
  43. import {
  44. DeleteDocumentationVersionCommandInput,
  45. DeleteDocumentationVersionCommandOutput,
  46. } from "../commands/DeleteDocumentationVersionCommand";
  47. import { DeleteDomainNameCommandInput, DeleteDomainNameCommandOutput } from "../commands/DeleteDomainNameCommand";
  48. import {
  49. DeleteGatewayResponseCommandInput,
  50. DeleteGatewayResponseCommandOutput,
  51. } from "../commands/DeleteGatewayResponseCommand";
  52. import { DeleteIntegrationCommandInput, DeleteIntegrationCommandOutput } from "../commands/DeleteIntegrationCommand";
  53. import {
  54. DeleteIntegrationResponseCommandInput,
  55. DeleteIntegrationResponseCommandOutput,
  56. } from "../commands/DeleteIntegrationResponseCommand";
  57. import { DeleteMethodCommandInput, DeleteMethodCommandOutput } from "../commands/DeleteMethodCommand";
  58. import {
  59. DeleteMethodResponseCommandInput,
  60. DeleteMethodResponseCommandOutput,
  61. } from "../commands/DeleteMethodResponseCommand";
  62. import { DeleteModelCommandInput, DeleteModelCommandOutput } from "../commands/DeleteModelCommand";
  63. import {
  64. DeleteRequestValidatorCommandInput,
  65. DeleteRequestValidatorCommandOutput,
  66. } from "../commands/DeleteRequestValidatorCommand";
  67. import { DeleteResourceCommandInput, DeleteResourceCommandOutput } from "../commands/DeleteResourceCommand";
  68. import { DeleteRestApiCommandInput, DeleteRestApiCommandOutput } from "../commands/DeleteRestApiCommand";
  69. import { DeleteStageCommandInput, DeleteStageCommandOutput } from "../commands/DeleteStageCommand";
  70. import { DeleteUsagePlanCommandInput, DeleteUsagePlanCommandOutput } from "../commands/DeleteUsagePlanCommand";
  71. import { DeleteUsagePlanKeyCommandInput, DeleteUsagePlanKeyCommandOutput } from "../commands/DeleteUsagePlanKeyCommand";
  72. import { DeleteVpcLinkCommandInput, DeleteVpcLinkCommandOutput } from "../commands/DeleteVpcLinkCommand";
  73. import {
  74. FlushStageAuthorizersCacheCommandInput,
  75. FlushStageAuthorizersCacheCommandOutput,
  76. } from "../commands/FlushStageAuthorizersCacheCommand";
  77. import { FlushStageCacheCommandInput, FlushStageCacheCommandOutput } from "../commands/FlushStageCacheCommand";
  78. import {
  79. GenerateClientCertificateCommandInput,
  80. GenerateClientCertificateCommandOutput,
  81. } from "../commands/GenerateClientCertificateCommand";
  82. import { GetAccountCommandInput, GetAccountCommandOutput } from "../commands/GetAccountCommand";
  83. import { GetApiKeyCommandInput, GetApiKeyCommandOutput } from "../commands/GetApiKeyCommand";
  84. import { GetApiKeysCommandInput, GetApiKeysCommandOutput } from "../commands/GetApiKeysCommand";
  85. import { GetAuthorizerCommandInput, GetAuthorizerCommandOutput } from "../commands/GetAuthorizerCommand";
  86. import { GetAuthorizersCommandInput, GetAuthorizersCommandOutput } from "../commands/GetAuthorizersCommand";
  87. import { GetBasePathMappingCommandInput, GetBasePathMappingCommandOutput } from "../commands/GetBasePathMappingCommand";
  88. import {
  89. GetBasePathMappingsCommandInput,
  90. GetBasePathMappingsCommandOutput,
  91. } from "../commands/GetBasePathMappingsCommand";
  92. import {
  93. GetClientCertificateCommandInput,
  94. GetClientCertificateCommandOutput,
  95. } from "../commands/GetClientCertificateCommand";
  96. import {
  97. GetClientCertificatesCommandInput,
  98. GetClientCertificatesCommandOutput,
  99. } from "../commands/GetClientCertificatesCommand";
  100. import { GetDeploymentCommandInput, GetDeploymentCommandOutput } from "../commands/GetDeploymentCommand";
  101. import { GetDeploymentsCommandInput, GetDeploymentsCommandOutput } from "../commands/GetDeploymentsCommand";
  102. import {
  103. GetDocumentationPartCommandInput,
  104. GetDocumentationPartCommandOutput,
  105. } from "../commands/GetDocumentationPartCommand";
  106. import {
  107. GetDocumentationPartsCommandInput,
  108. GetDocumentationPartsCommandOutput,
  109. } from "../commands/GetDocumentationPartsCommand";
  110. import {
  111. GetDocumentationVersionCommandInput,
  112. GetDocumentationVersionCommandOutput,
  113. } from "../commands/GetDocumentationVersionCommand";
  114. import {
  115. GetDocumentationVersionsCommandInput,
  116. GetDocumentationVersionsCommandOutput,
  117. } from "../commands/GetDocumentationVersionsCommand";
  118. import { GetDomainNameCommandInput, GetDomainNameCommandOutput } from "../commands/GetDomainNameCommand";
  119. import { GetDomainNamesCommandInput, GetDomainNamesCommandOutput } from "../commands/GetDomainNamesCommand";
  120. import { GetExportCommandInput, GetExportCommandOutput } from "../commands/GetExportCommand";
  121. import { GetGatewayResponseCommandInput, GetGatewayResponseCommandOutput } from "../commands/GetGatewayResponseCommand";
  122. import {
  123. GetGatewayResponsesCommandInput,
  124. GetGatewayResponsesCommandOutput,
  125. } from "../commands/GetGatewayResponsesCommand";
  126. import { GetIntegrationCommandInput, GetIntegrationCommandOutput } from "../commands/GetIntegrationCommand";
  127. import {
  128. GetIntegrationResponseCommandInput,
  129. GetIntegrationResponseCommandOutput,
  130. } from "../commands/GetIntegrationResponseCommand";
  131. import { GetMethodCommandInput, GetMethodCommandOutput } from "../commands/GetMethodCommand";
  132. import { GetMethodResponseCommandInput, GetMethodResponseCommandOutput } from "../commands/GetMethodResponseCommand";
  133. import { GetModelCommandInput, GetModelCommandOutput } from "../commands/GetModelCommand";
  134. import { GetModelTemplateCommandInput, GetModelTemplateCommandOutput } from "../commands/GetModelTemplateCommand";
  135. import { GetModelsCommandInput, GetModelsCommandOutput } from "../commands/GetModelsCommand";
  136. import {
  137. GetRequestValidatorCommandInput,
  138. GetRequestValidatorCommandOutput,
  139. } from "../commands/GetRequestValidatorCommand";
  140. import {
  141. GetRequestValidatorsCommandInput,
  142. GetRequestValidatorsCommandOutput,
  143. } from "../commands/GetRequestValidatorsCommand";
  144. import { GetResourceCommandInput, GetResourceCommandOutput } from "../commands/GetResourceCommand";
  145. import { GetResourcesCommandInput, GetResourcesCommandOutput } from "../commands/GetResourcesCommand";
  146. import { GetRestApiCommandInput, GetRestApiCommandOutput } from "../commands/GetRestApiCommand";
  147. import { GetRestApisCommandInput, GetRestApisCommandOutput } from "../commands/GetRestApisCommand";
  148. import { GetSdkCommandInput, GetSdkCommandOutput } from "../commands/GetSdkCommand";
  149. import { GetSdkTypeCommandInput, GetSdkTypeCommandOutput } from "../commands/GetSdkTypeCommand";
  150. import { GetSdkTypesCommandInput, GetSdkTypesCommandOutput } from "../commands/GetSdkTypesCommand";
  151. import { GetStageCommandInput, GetStageCommandOutput } from "../commands/GetStageCommand";
  152. import { GetStagesCommandInput, GetStagesCommandOutput } from "../commands/GetStagesCommand";
  153. import { GetTagsCommandInput, GetTagsCommandOutput } from "../commands/GetTagsCommand";
  154. import { GetUsageCommandInput, GetUsageCommandOutput } from "../commands/GetUsageCommand";
  155. import { GetUsagePlanCommandInput, GetUsagePlanCommandOutput } from "../commands/GetUsagePlanCommand";
  156. import { GetUsagePlanKeyCommandInput, GetUsagePlanKeyCommandOutput } from "../commands/GetUsagePlanKeyCommand";
  157. import { GetUsagePlanKeysCommandInput, GetUsagePlanKeysCommandOutput } from "../commands/GetUsagePlanKeysCommand";
  158. import { GetUsagePlansCommandInput, GetUsagePlansCommandOutput } from "../commands/GetUsagePlansCommand";
  159. import { GetVpcLinkCommandInput, GetVpcLinkCommandOutput } from "../commands/GetVpcLinkCommand";
  160. import { GetVpcLinksCommandInput, GetVpcLinksCommandOutput } from "../commands/GetVpcLinksCommand";
  161. import { ImportApiKeysCommandInput, ImportApiKeysCommandOutput } from "../commands/ImportApiKeysCommand";
  162. import {
  163. ImportDocumentationPartsCommandInput,
  164. ImportDocumentationPartsCommandOutput,
  165. } from "../commands/ImportDocumentationPartsCommand";
  166. import { ImportRestApiCommandInput, ImportRestApiCommandOutput } from "../commands/ImportRestApiCommand";
  167. import { PutGatewayResponseCommandInput, PutGatewayResponseCommandOutput } from "../commands/PutGatewayResponseCommand";
  168. import { PutIntegrationCommandInput, PutIntegrationCommandOutput } from "../commands/PutIntegrationCommand";
  169. import {
  170. PutIntegrationResponseCommandInput,
  171. PutIntegrationResponseCommandOutput,
  172. } from "../commands/PutIntegrationResponseCommand";
  173. import { PutMethodCommandInput, PutMethodCommandOutput } from "../commands/PutMethodCommand";
  174. import { PutMethodResponseCommandInput, PutMethodResponseCommandOutput } from "../commands/PutMethodResponseCommand";
  175. import { PutRestApiCommandInput, PutRestApiCommandOutput } from "../commands/PutRestApiCommand";
  176. import { TagResourceCommandInput, TagResourceCommandOutput } from "../commands/TagResourceCommand";
  177. import {
  178. TestInvokeAuthorizerCommandInput,
  179. TestInvokeAuthorizerCommandOutput,
  180. } from "../commands/TestInvokeAuthorizerCommand";
  181. import { TestInvokeMethodCommandInput, TestInvokeMethodCommandOutput } from "../commands/TestInvokeMethodCommand";
  182. import { UntagResourceCommandInput, UntagResourceCommandOutput } from "../commands/UntagResourceCommand";
  183. import { UpdateAccountCommandInput, UpdateAccountCommandOutput } from "../commands/UpdateAccountCommand";
  184. import { UpdateApiKeyCommandInput, UpdateApiKeyCommandOutput } from "../commands/UpdateApiKeyCommand";
  185. import { UpdateAuthorizerCommandInput, UpdateAuthorizerCommandOutput } from "../commands/UpdateAuthorizerCommand";
  186. import {
  187. UpdateBasePathMappingCommandInput,
  188. UpdateBasePathMappingCommandOutput,
  189. } from "../commands/UpdateBasePathMappingCommand";
  190. import {
  191. UpdateClientCertificateCommandInput,
  192. UpdateClientCertificateCommandOutput,
  193. } from "../commands/UpdateClientCertificateCommand";
  194. import { UpdateDeploymentCommandInput, UpdateDeploymentCommandOutput } from "../commands/UpdateDeploymentCommand";
  195. import {
  196. UpdateDocumentationPartCommandInput,
  197. UpdateDocumentationPartCommandOutput,
  198. } from "../commands/UpdateDocumentationPartCommand";
  199. import {
  200. UpdateDocumentationVersionCommandInput,
  201. UpdateDocumentationVersionCommandOutput,
  202. } from "../commands/UpdateDocumentationVersionCommand";
  203. import { UpdateDomainNameCommandInput, UpdateDomainNameCommandOutput } from "../commands/UpdateDomainNameCommand";
  204. import {
  205. UpdateGatewayResponseCommandInput,
  206. UpdateGatewayResponseCommandOutput,
  207. } from "../commands/UpdateGatewayResponseCommand";
  208. import { UpdateIntegrationCommandInput, UpdateIntegrationCommandOutput } from "../commands/UpdateIntegrationCommand";
  209. import {
  210. UpdateIntegrationResponseCommandInput,
  211. UpdateIntegrationResponseCommandOutput,
  212. } from "../commands/UpdateIntegrationResponseCommand";
  213. import { UpdateMethodCommandInput, UpdateMethodCommandOutput } from "../commands/UpdateMethodCommand";
  214. import {
  215. UpdateMethodResponseCommandInput,
  216. UpdateMethodResponseCommandOutput,
  217. } from "../commands/UpdateMethodResponseCommand";
  218. import { UpdateModelCommandInput, UpdateModelCommandOutput } from "../commands/UpdateModelCommand";
  219. import {
  220. UpdateRequestValidatorCommandInput,
  221. UpdateRequestValidatorCommandOutput,
  222. } from "../commands/UpdateRequestValidatorCommand";
  223. import { UpdateResourceCommandInput, UpdateResourceCommandOutput } from "../commands/UpdateResourceCommand";
  224. import { UpdateRestApiCommandInput, UpdateRestApiCommandOutput } from "../commands/UpdateRestApiCommand";
  225. import { UpdateStageCommandInput, UpdateStageCommandOutput } from "../commands/UpdateStageCommand";
  226. import { UpdateUsageCommandInput, UpdateUsageCommandOutput } from "../commands/UpdateUsageCommand";
  227. import { UpdateUsagePlanCommandInput, UpdateUsagePlanCommandOutput } from "../commands/UpdateUsagePlanCommand";
  228. import { UpdateVpcLinkCommandInput, UpdateVpcLinkCommandOutput } from "../commands/UpdateVpcLinkCommand";
  229. import {
  230. AccessLogSettings,
  231. ApiKey,
  232. ApiStage,
  233. Authorizer,
  234. BadRequestException,
  235. BasePathMapping,
  236. CanarySettings,
  237. ClientCertificate,
  238. ConflictException,
  239. Deployment,
  240. DeploymentCanarySettings,
  241. DocumentationPart,
  242. DocumentationPartLocation,
  243. DocumentationVersion,
  244. DomainName,
  245. EndpointConfiguration,
  246. EndpointType,
  247. GatewayResponse,
  248. Integration,
  249. IntegrationResponse,
  250. LimitExceededException,
  251. Method,
  252. MethodResponse,
  253. MethodSetting,
  254. MethodSnapshot,
  255. Model,
  256. NotFoundException,
  257. PatchOperation,
  258. QuotaSettings,
  259. RequestValidator,
  260. Resource,
  261. RestApi,
  262. SdkConfigurationProperty,
  263. SdkType,
  264. ServiceUnavailableException,
  265. Stage,
  266. StageKey,
  267. ThrottleSettings,
  268. TlsConfig,
  269. TooManyRequestsException,
  270. UnauthorizedException,
  271. UsagePlan,
  272. UsagePlanKey,
  273. VpcLink,
  274. } from "../models/models_0";
  275. import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
  276. import {
  277. SmithyException as __SmithyException,
  278. extendedEncodeURIComponent as __extendedEncodeURIComponent,
  279. } from "@aws-sdk/smithy-client";
  280. import {
  281. Endpoint as __Endpoint,
  282. MetadataBearer as __MetadataBearer,
  283. ResponseMetadata as __ResponseMetadata,
  284. SerdeContext as __SerdeContext,
  285. } from "@aws-sdk/types";
  286. export const serializeAws_restJson1CreateApiKeyCommand = async (
  287. input: CreateApiKeyCommandInput,
  288. context: __SerdeContext
  289. ): Promise<__HttpRequest> => {
  290. const headers: any = {
  291. "Content-Type": "application/json",
  292. };
  293. let resolvedPath = "/apikeys";
  294. let body: any;
  295. body = JSON.stringify({
  296. ...(input.customerId !== undefined && { customerId: input.customerId }),
  297. ...(input.description !== undefined && { description: input.description }),
  298. ...(input.enabled !== undefined && { enabled: input.enabled }),
  299. ...(input.generateDistinctId !== undefined && { generateDistinctId: input.generateDistinctId }),
  300. ...(input.name !== undefined && { name: input.name }),
  301. ...(input.stageKeys !== undefined && {
  302. stageKeys: serializeAws_restJson1ListOfStageKeys(input.stageKeys, context),
  303. }),
  304. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  305. ...(input.template !== undefined && { template: input.template }),
  306. ...(input.templateSkipList !== undefined && {
  307. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  308. }),
  309. ...(input.title !== undefined && { title: input.title }),
  310. ...(input.value !== undefined && { value: input.value }),
  311. });
  312. const { hostname, protocol = "https", port } = await context.endpoint();
  313. return new __HttpRequest({
  314. protocol,
  315. hostname,
  316. port,
  317. method: "POST",
  318. headers,
  319. path: resolvedPath,
  320. body,
  321. });
  322. };
  323. export const serializeAws_restJson1CreateAuthorizerCommand = async (
  324. input: CreateAuthorizerCommandInput,
  325. context: __SerdeContext
  326. ): Promise<__HttpRequest> => {
  327. const headers: any = {
  328. "Content-Type": "application/json",
  329. };
  330. let resolvedPath = "/restapis/{restApiId}/authorizers";
  331. if (input.restApiId !== undefined) {
  332. const labelValue: string = input.restApiId;
  333. if (labelValue.length <= 0) {
  334. throw new Error("Empty value provided for input HTTP label: restApiId.");
  335. }
  336. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  337. } else {
  338. throw new Error("No value provided for input HTTP label: restApiId.");
  339. }
  340. let body: any;
  341. body = JSON.stringify({
  342. ...(input.authType !== undefined && { authType: input.authType }),
  343. ...(input.authorizerCredentials !== undefined && { authorizerCredentials: input.authorizerCredentials }),
  344. ...(input.authorizerResultTtlInSeconds !== undefined && {
  345. authorizerResultTtlInSeconds: input.authorizerResultTtlInSeconds,
  346. }),
  347. ...(input.authorizerUri !== undefined && { authorizerUri: input.authorizerUri }),
  348. ...(input.identitySource !== undefined && { identitySource: input.identitySource }),
  349. ...(input.identityValidationExpression !== undefined && {
  350. identityValidationExpression: input.identityValidationExpression,
  351. }),
  352. ...(input.name !== undefined && { name: input.name }),
  353. ...(input.providerARNs !== undefined && {
  354. providerARNs: serializeAws_restJson1ListOfARNs(input.providerARNs, context),
  355. }),
  356. ...(input.template !== undefined && { template: input.template }),
  357. ...(input.templateSkipList !== undefined && {
  358. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  359. }),
  360. ...(input.title !== undefined && { title: input.title }),
  361. ...(input.type !== undefined && { type: input.type }),
  362. });
  363. const { hostname, protocol = "https", port } = await context.endpoint();
  364. return new __HttpRequest({
  365. protocol,
  366. hostname,
  367. port,
  368. method: "POST",
  369. headers,
  370. path: resolvedPath,
  371. body,
  372. });
  373. };
  374. export const serializeAws_restJson1CreateBasePathMappingCommand = async (
  375. input: CreateBasePathMappingCommandInput,
  376. context: __SerdeContext
  377. ): Promise<__HttpRequest> => {
  378. const headers: any = {
  379. "Content-Type": "application/json",
  380. };
  381. let resolvedPath = "/domainnames/{domainName}/basepathmappings";
  382. if (input.domainName !== undefined) {
  383. const labelValue: string = input.domainName;
  384. if (labelValue.length <= 0) {
  385. throw new Error("Empty value provided for input HTTP label: domainName.");
  386. }
  387. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  388. } else {
  389. throw new Error("No value provided for input HTTP label: domainName.");
  390. }
  391. let body: any;
  392. body = JSON.stringify({
  393. ...(input.basePath !== undefined && { basePath: input.basePath }),
  394. ...(input.name !== undefined && { name: input.name }),
  395. ...(input.restApiId !== undefined && { restApiId: input.restApiId }),
  396. ...(input.stage !== undefined && { stage: input.stage }),
  397. ...(input.template !== undefined && { template: input.template }),
  398. ...(input.templateSkipList !== undefined && {
  399. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  400. }),
  401. ...(input.title !== undefined && { title: input.title }),
  402. });
  403. const { hostname, protocol = "https", port } = await context.endpoint();
  404. return new __HttpRequest({
  405. protocol,
  406. hostname,
  407. port,
  408. method: "POST",
  409. headers,
  410. path: resolvedPath,
  411. body,
  412. });
  413. };
  414. export const serializeAws_restJson1CreateDeploymentCommand = async (
  415. input: CreateDeploymentCommandInput,
  416. context: __SerdeContext
  417. ): Promise<__HttpRequest> => {
  418. const headers: any = {
  419. "Content-Type": "application/json",
  420. };
  421. let resolvedPath = "/restapis/{restApiId}/deployments";
  422. if (input.restApiId !== undefined) {
  423. const labelValue: string = input.restApiId;
  424. if (labelValue.length <= 0) {
  425. throw new Error("Empty value provided for input HTTP label: restApiId.");
  426. }
  427. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  428. } else {
  429. throw new Error("No value provided for input HTTP label: restApiId.");
  430. }
  431. let body: any;
  432. body = JSON.stringify({
  433. ...(input.cacheClusterEnabled !== undefined && { cacheClusterEnabled: input.cacheClusterEnabled }),
  434. ...(input.cacheClusterSize !== undefined && { cacheClusterSize: input.cacheClusterSize }),
  435. ...(input.canarySettings !== undefined && {
  436. canarySettings: serializeAws_restJson1DeploymentCanarySettings(input.canarySettings, context),
  437. }),
  438. ...(input.description !== undefined && { description: input.description }),
  439. ...(input.name !== undefined && { name: input.name }),
  440. ...(input.stageDescription !== undefined && { stageDescription: input.stageDescription }),
  441. ...(input.stageName !== undefined && { stageName: input.stageName }),
  442. ...(input.template !== undefined && { template: input.template }),
  443. ...(input.templateSkipList !== undefined && {
  444. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  445. }),
  446. ...(input.title !== undefined && { title: input.title }),
  447. ...(input.tracingEnabled !== undefined && { tracingEnabled: input.tracingEnabled }),
  448. ...(input.variables !== undefined && {
  449. variables: serializeAws_restJson1MapOfStringToString(input.variables, context),
  450. }),
  451. });
  452. const { hostname, protocol = "https", port } = await context.endpoint();
  453. return new __HttpRequest({
  454. protocol,
  455. hostname,
  456. port,
  457. method: "POST",
  458. headers,
  459. path: resolvedPath,
  460. body,
  461. });
  462. };
  463. export const serializeAws_restJson1CreateDocumentationPartCommand = async (
  464. input: CreateDocumentationPartCommandInput,
  465. context: __SerdeContext
  466. ): Promise<__HttpRequest> => {
  467. const headers: any = {
  468. "Content-Type": "application/json",
  469. };
  470. let resolvedPath = "/restapis/{restApiId}/documentation/parts";
  471. if (input.restApiId !== undefined) {
  472. const labelValue: string = input.restApiId;
  473. if (labelValue.length <= 0) {
  474. throw new Error("Empty value provided for input HTTP label: restApiId.");
  475. }
  476. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  477. } else {
  478. throw new Error("No value provided for input HTTP label: restApiId.");
  479. }
  480. let body: any;
  481. body = JSON.stringify({
  482. ...(input.location !== undefined && {
  483. location: serializeAws_restJson1DocumentationPartLocation(input.location, context),
  484. }),
  485. ...(input.name !== undefined && { name: input.name }),
  486. ...(input.properties !== undefined && { properties: input.properties }),
  487. ...(input.template !== undefined && { template: input.template }),
  488. ...(input.templateSkipList !== undefined && {
  489. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  490. }),
  491. ...(input.title !== undefined && { title: input.title }),
  492. });
  493. const { hostname, protocol = "https", port } = await context.endpoint();
  494. return new __HttpRequest({
  495. protocol,
  496. hostname,
  497. port,
  498. method: "POST",
  499. headers,
  500. path: resolvedPath,
  501. body,
  502. });
  503. };
  504. export const serializeAws_restJson1CreateDocumentationVersionCommand = async (
  505. input: CreateDocumentationVersionCommandInput,
  506. context: __SerdeContext
  507. ): Promise<__HttpRequest> => {
  508. const headers: any = {
  509. "Content-Type": "application/json",
  510. };
  511. let resolvedPath = "/restapis/{restApiId}/documentation/versions";
  512. if (input.restApiId !== undefined) {
  513. const labelValue: string = input.restApiId;
  514. if (labelValue.length <= 0) {
  515. throw new Error("Empty value provided for input HTTP label: restApiId.");
  516. }
  517. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  518. } else {
  519. throw new Error("No value provided for input HTTP label: restApiId.");
  520. }
  521. let body: any;
  522. body = JSON.stringify({
  523. ...(input.description !== undefined && { description: input.description }),
  524. ...(input.documentationVersion !== undefined && { documentationVersion: input.documentationVersion }),
  525. ...(input.name !== undefined && { name: input.name }),
  526. ...(input.stageName !== undefined && { stageName: input.stageName }),
  527. ...(input.template !== undefined && { template: input.template }),
  528. ...(input.templateSkipList !== undefined && {
  529. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  530. }),
  531. ...(input.title !== undefined && { title: input.title }),
  532. });
  533. const { hostname, protocol = "https", port } = await context.endpoint();
  534. return new __HttpRequest({
  535. protocol,
  536. hostname,
  537. port,
  538. method: "POST",
  539. headers,
  540. path: resolvedPath,
  541. body,
  542. });
  543. };
  544. export const serializeAws_restJson1CreateDomainNameCommand = async (
  545. input: CreateDomainNameCommandInput,
  546. context: __SerdeContext
  547. ): Promise<__HttpRequest> => {
  548. const headers: any = {
  549. "Content-Type": "application/json",
  550. };
  551. let resolvedPath = "/domainnames";
  552. let body: any;
  553. body = JSON.stringify({
  554. ...(input.certificateArn !== undefined && { certificateArn: input.certificateArn }),
  555. ...(input.certificateBody !== undefined && { certificateBody: input.certificateBody }),
  556. ...(input.certificateChain !== undefined && { certificateChain: input.certificateChain }),
  557. ...(input.certificateName !== undefined && { certificateName: input.certificateName }),
  558. ...(input.certificatePrivateKey !== undefined && { certificatePrivateKey: input.certificatePrivateKey }),
  559. ...(input.domainName !== undefined && { domainName: input.domainName }),
  560. ...(input.endpointConfiguration !== undefined && {
  561. endpointConfiguration: serializeAws_restJson1EndpointConfiguration(input.endpointConfiguration, context),
  562. }),
  563. ...(input.name !== undefined && { name: input.name }),
  564. ...(input.regionalCertificateArn !== undefined && { regionalCertificateArn: input.regionalCertificateArn }),
  565. ...(input.regionalCertificateName !== undefined && { regionalCertificateName: input.regionalCertificateName }),
  566. ...(input.securityPolicy !== undefined && { securityPolicy: input.securityPolicy }),
  567. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  568. ...(input.template !== undefined && { template: input.template }),
  569. ...(input.templateSkipList !== undefined && {
  570. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  571. }),
  572. ...(input.title !== undefined && { title: input.title }),
  573. });
  574. const { hostname, protocol = "https", port } = await context.endpoint();
  575. return new __HttpRequest({
  576. protocol,
  577. hostname,
  578. port,
  579. method: "POST",
  580. headers,
  581. path: resolvedPath,
  582. body,
  583. });
  584. };
  585. export const serializeAws_restJson1CreateModelCommand = async (
  586. input: CreateModelCommandInput,
  587. context: __SerdeContext
  588. ): Promise<__HttpRequest> => {
  589. const headers: any = {
  590. "Content-Type": "application/json",
  591. };
  592. let resolvedPath = "/restapis/{restApiId}/models";
  593. if (input.restApiId !== undefined) {
  594. const labelValue: string = input.restApiId;
  595. if (labelValue.length <= 0) {
  596. throw new Error("Empty value provided for input HTTP label: restApiId.");
  597. }
  598. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  599. } else {
  600. throw new Error("No value provided for input HTTP label: restApiId.");
  601. }
  602. let body: any;
  603. body = JSON.stringify({
  604. ...(input.contentType !== undefined && { contentType: input.contentType }),
  605. ...(input.description !== undefined && { description: input.description }),
  606. ...(input.name !== undefined && { name: input.name }),
  607. ...(input.schema !== undefined && { schema: input.schema }),
  608. ...(input.template !== undefined && { template: input.template }),
  609. ...(input.templateSkipList !== undefined && {
  610. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  611. }),
  612. ...(input.title !== undefined && { title: input.title }),
  613. });
  614. const { hostname, protocol = "https", port } = await context.endpoint();
  615. return new __HttpRequest({
  616. protocol,
  617. hostname,
  618. port,
  619. method: "POST",
  620. headers,
  621. path: resolvedPath,
  622. body,
  623. });
  624. };
  625. export const serializeAws_restJson1CreateRequestValidatorCommand = async (
  626. input: CreateRequestValidatorCommandInput,
  627. context: __SerdeContext
  628. ): Promise<__HttpRequest> => {
  629. const headers: any = {
  630. "Content-Type": "application/json",
  631. };
  632. let resolvedPath = "/restapis/{restApiId}/requestvalidators";
  633. if (input.restApiId !== undefined) {
  634. const labelValue: string = input.restApiId;
  635. if (labelValue.length <= 0) {
  636. throw new Error("Empty value provided for input HTTP label: restApiId.");
  637. }
  638. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  639. } else {
  640. throw new Error("No value provided for input HTTP label: restApiId.");
  641. }
  642. let body: any;
  643. body = JSON.stringify({
  644. ...(input.name !== undefined && { name: input.name }),
  645. ...(input.template !== undefined && { template: input.template }),
  646. ...(input.templateSkipList !== undefined && {
  647. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  648. }),
  649. ...(input.title !== undefined && { title: input.title }),
  650. ...(input.validateRequestBody !== undefined && { validateRequestBody: input.validateRequestBody }),
  651. ...(input.validateRequestParameters !== undefined && {
  652. validateRequestParameters: input.validateRequestParameters,
  653. }),
  654. });
  655. const { hostname, protocol = "https", port } = await context.endpoint();
  656. return new __HttpRequest({
  657. protocol,
  658. hostname,
  659. port,
  660. method: "POST",
  661. headers,
  662. path: resolvedPath,
  663. body,
  664. });
  665. };
  666. export const serializeAws_restJson1CreateResourceCommand = async (
  667. input: CreateResourceCommandInput,
  668. context: __SerdeContext
  669. ): Promise<__HttpRequest> => {
  670. const headers: any = {
  671. "Content-Type": "application/json",
  672. };
  673. let resolvedPath = "/restapis/{restApiId}/resources/{parentId}";
  674. if (input.parentId !== undefined) {
  675. const labelValue: string = input.parentId;
  676. if (labelValue.length <= 0) {
  677. throw new Error("Empty value provided for input HTTP label: parentId.");
  678. }
  679. resolvedPath = resolvedPath.replace("{parentId}", __extendedEncodeURIComponent(labelValue));
  680. } else {
  681. throw new Error("No value provided for input HTTP label: parentId.");
  682. }
  683. if (input.restApiId !== undefined) {
  684. const labelValue: string = input.restApiId;
  685. if (labelValue.length <= 0) {
  686. throw new Error("Empty value provided for input HTTP label: restApiId.");
  687. }
  688. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  689. } else {
  690. throw new Error("No value provided for input HTTP label: restApiId.");
  691. }
  692. let body: any;
  693. body = JSON.stringify({
  694. ...(input.name !== undefined && { name: input.name }),
  695. ...(input.pathPart !== undefined && { pathPart: input.pathPart }),
  696. ...(input.template !== undefined && { template: input.template }),
  697. ...(input.templateSkipList !== undefined && {
  698. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  699. }),
  700. ...(input.title !== undefined && { title: input.title }),
  701. });
  702. const { hostname, protocol = "https", port } = await context.endpoint();
  703. return new __HttpRequest({
  704. protocol,
  705. hostname,
  706. port,
  707. method: "POST",
  708. headers,
  709. path: resolvedPath,
  710. body,
  711. });
  712. };
  713. export const serializeAws_restJson1CreateRestApiCommand = async (
  714. input: CreateRestApiCommandInput,
  715. context: __SerdeContext
  716. ): Promise<__HttpRequest> => {
  717. const headers: any = {
  718. "Content-Type": "application/json",
  719. };
  720. let resolvedPath = "/restapis";
  721. let body: any;
  722. body = JSON.stringify({
  723. ...(input.apiKeySource !== undefined && { apiKeySource: input.apiKeySource }),
  724. ...(input.binaryMediaTypes !== undefined && {
  725. binaryMediaTypes: serializeAws_restJson1ListOfString(input.binaryMediaTypes, context),
  726. }),
  727. ...(input.cloneFrom !== undefined && { cloneFrom: input.cloneFrom }),
  728. ...(input.description !== undefined && { description: input.description }),
  729. ...(input.endpointConfiguration !== undefined && {
  730. endpointConfiguration: serializeAws_restJson1EndpointConfiguration(input.endpointConfiguration, context),
  731. }),
  732. ...(input.minimumCompressionSize !== undefined && { minimumCompressionSize: input.minimumCompressionSize }),
  733. ...(input.name !== undefined && { name: input.name }),
  734. ...(input.policy !== undefined && { policy: input.policy }),
  735. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  736. ...(input.template !== undefined && { template: input.template }),
  737. ...(input.templateSkipList !== undefined && {
  738. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  739. }),
  740. ...(input.title !== undefined && { title: input.title }),
  741. ...(input.version !== undefined && { version: input.version }),
  742. });
  743. const { hostname, protocol = "https", port } = await context.endpoint();
  744. return new __HttpRequest({
  745. protocol,
  746. hostname,
  747. port,
  748. method: "POST",
  749. headers,
  750. path: resolvedPath,
  751. body,
  752. });
  753. };
  754. export const serializeAws_restJson1CreateStageCommand = async (
  755. input: CreateStageCommandInput,
  756. context: __SerdeContext
  757. ): Promise<__HttpRequest> => {
  758. const headers: any = {
  759. "Content-Type": "application/json",
  760. };
  761. let resolvedPath = "/restapis/{restApiId}/stages";
  762. if (input.restApiId !== undefined) {
  763. const labelValue: string = input.restApiId;
  764. if (labelValue.length <= 0) {
  765. throw new Error("Empty value provided for input HTTP label: restApiId.");
  766. }
  767. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  768. } else {
  769. throw new Error("No value provided for input HTTP label: restApiId.");
  770. }
  771. let body: any;
  772. body = JSON.stringify({
  773. ...(input.cacheClusterEnabled !== undefined && { cacheClusterEnabled: input.cacheClusterEnabled }),
  774. ...(input.cacheClusterSize !== undefined && { cacheClusterSize: input.cacheClusterSize }),
  775. ...(input.canarySettings !== undefined && {
  776. canarySettings: serializeAws_restJson1CanarySettings(input.canarySettings, context),
  777. }),
  778. ...(input.deploymentId !== undefined && { deploymentId: input.deploymentId }),
  779. ...(input.description !== undefined && { description: input.description }),
  780. ...(input.documentationVersion !== undefined && { documentationVersion: input.documentationVersion }),
  781. ...(input.name !== undefined && { name: input.name }),
  782. ...(input.stageName !== undefined && { stageName: input.stageName }),
  783. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  784. ...(input.template !== undefined && { template: input.template }),
  785. ...(input.templateSkipList !== undefined && {
  786. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  787. }),
  788. ...(input.title !== undefined && { title: input.title }),
  789. ...(input.tracingEnabled !== undefined && { tracingEnabled: input.tracingEnabled }),
  790. ...(input.variables !== undefined && {
  791. variables: serializeAws_restJson1MapOfStringToString(input.variables, context),
  792. }),
  793. });
  794. const { hostname, protocol = "https", port } = await context.endpoint();
  795. return new __HttpRequest({
  796. protocol,
  797. hostname,
  798. port,
  799. method: "POST",
  800. headers,
  801. path: resolvedPath,
  802. body,
  803. });
  804. };
  805. export const serializeAws_restJson1CreateUsagePlanCommand = async (
  806. input: CreateUsagePlanCommandInput,
  807. context: __SerdeContext
  808. ): Promise<__HttpRequest> => {
  809. const headers: any = {
  810. "Content-Type": "application/json",
  811. };
  812. let resolvedPath = "/usageplans";
  813. let body: any;
  814. body = JSON.stringify({
  815. ...(input.apiStages !== undefined && { apiStages: serializeAws_restJson1ListOfApiStage(input.apiStages, context) }),
  816. ...(input.description !== undefined && { description: input.description }),
  817. ...(input.name !== undefined && { name: input.name }),
  818. ...(input.quota !== undefined && { quota: serializeAws_restJson1QuotaSettings(input.quota, context) }),
  819. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  820. ...(input.template !== undefined && { template: input.template }),
  821. ...(input.templateSkipList !== undefined && {
  822. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  823. }),
  824. ...(input.throttle !== undefined && { throttle: serializeAws_restJson1ThrottleSettings(input.throttle, context) }),
  825. ...(input.title !== undefined && { title: input.title }),
  826. });
  827. const { hostname, protocol = "https", port } = await context.endpoint();
  828. return new __HttpRequest({
  829. protocol,
  830. hostname,
  831. port,
  832. method: "POST",
  833. headers,
  834. path: resolvedPath,
  835. body,
  836. });
  837. };
  838. export const serializeAws_restJson1CreateUsagePlanKeyCommand = async (
  839. input: CreateUsagePlanKeyCommandInput,
  840. context: __SerdeContext
  841. ): Promise<__HttpRequest> => {
  842. const headers: any = {
  843. "Content-Type": "application/json",
  844. };
  845. let resolvedPath = "/usageplans/{usagePlanId}/keys";
  846. if (input.usagePlanId !== undefined) {
  847. const labelValue: string = input.usagePlanId;
  848. if (labelValue.length <= 0) {
  849. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  850. }
  851. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  852. } else {
  853. throw new Error("No value provided for input HTTP label: usagePlanId.");
  854. }
  855. let body: any;
  856. body = JSON.stringify({
  857. ...(input.keyId !== undefined && { keyId: input.keyId }),
  858. ...(input.keyType !== undefined && { keyType: input.keyType }),
  859. ...(input.name !== undefined && { name: input.name }),
  860. ...(input.template !== undefined && { template: input.template }),
  861. ...(input.templateSkipList !== undefined && {
  862. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  863. }),
  864. ...(input.title !== undefined && { title: input.title }),
  865. });
  866. const { hostname, protocol = "https", port } = await context.endpoint();
  867. return new __HttpRequest({
  868. protocol,
  869. hostname,
  870. port,
  871. method: "POST",
  872. headers,
  873. path: resolvedPath,
  874. body,
  875. });
  876. };
  877. export const serializeAws_restJson1CreateVpcLinkCommand = async (
  878. input: CreateVpcLinkCommandInput,
  879. context: __SerdeContext
  880. ): Promise<__HttpRequest> => {
  881. const headers: any = {
  882. "Content-Type": "application/json",
  883. };
  884. let resolvedPath = "/vpclinks";
  885. let body: any;
  886. body = JSON.stringify({
  887. ...(input.description !== undefined && { description: input.description }),
  888. ...(input.name !== undefined && { name: input.name }),
  889. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  890. ...(input.targetArns !== undefined && {
  891. targetArns: serializeAws_restJson1ListOfString(input.targetArns, context),
  892. }),
  893. ...(input.template !== undefined && { template: input.template }),
  894. ...(input.templateSkipList !== undefined && {
  895. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  896. }),
  897. ...(input.title !== undefined && { title: input.title }),
  898. });
  899. const { hostname, protocol = "https", port } = await context.endpoint();
  900. return new __HttpRequest({
  901. protocol,
  902. hostname,
  903. port,
  904. method: "POST",
  905. headers,
  906. path: resolvedPath,
  907. body,
  908. });
  909. };
  910. export const serializeAws_restJson1DeleteApiKeyCommand = async (
  911. input: DeleteApiKeyCommandInput,
  912. context: __SerdeContext
  913. ): Promise<__HttpRequest> => {
  914. const headers: any = {
  915. "Content-Type": "application/json",
  916. };
  917. let resolvedPath = "/apikeys/{apiKey}";
  918. if (input.apiKey !== undefined) {
  919. const labelValue: string = input.apiKey;
  920. if (labelValue.length <= 0) {
  921. throw new Error("Empty value provided for input HTTP label: apiKey.");
  922. }
  923. resolvedPath = resolvedPath.replace("{apiKey}", __extendedEncodeURIComponent(labelValue));
  924. } else {
  925. throw new Error("No value provided for input HTTP label: apiKey.");
  926. }
  927. let body: any;
  928. body = JSON.stringify({
  929. ...(input.name !== undefined && { name: input.name }),
  930. ...(input.template !== undefined && { template: input.template }),
  931. ...(input.templateSkipList !== undefined && {
  932. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  933. }),
  934. ...(input.title !== undefined && { title: input.title }),
  935. });
  936. const { hostname, protocol = "https", port } = await context.endpoint();
  937. return new __HttpRequest({
  938. protocol,
  939. hostname,
  940. port,
  941. method: "DELETE",
  942. headers,
  943. path: resolvedPath,
  944. body,
  945. });
  946. };
  947. export const serializeAws_restJson1DeleteAuthorizerCommand = async (
  948. input: DeleteAuthorizerCommandInput,
  949. context: __SerdeContext
  950. ): Promise<__HttpRequest> => {
  951. const headers: any = {
  952. "Content-Type": "application/json",
  953. };
  954. let resolvedPath = "/restapis/{restApiId}/authorizers/{authorizerId}";
  955. if (input.authorizerId !== undefined) {
  956. const labelValue: string = input.authorizerId;
  957. if (labelValue.length <= 0) {
  958. throw new Error("Empty value provided for input HTTP label: authorizerId.");
  959. }
  960. resolvedPath = resolvedPath.replace("{authorizerId}", __extendedEncodeURIComponent(labelValue));
  961. } else {
  962. throw new Error("No value provided for input HTTP label: authorizerId.");
  963. }
  964. if (input.restApiId !== undefined) {
  965. const labelValue: string = input.restApiId;
  966. if (labelValue.length <= 0) {
  967. throw new Error("Empty value provided for input HTTP label: restApiId.");
  968. }
  969. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  970. } else {
  971. throw new Error("No value provided for input HTTP label: restApiId.");
  972. }
  973. let body: any;
  974. body = JSON.stringify({
  975. ...(input.name !== undefined && { name: input.name }),
  976. ...(input.template !== undefined && { template: input.template }),
  977. ...(input.templateSkipList !== undefined && {
  978. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  979. }),
  980. ...(input.title !== undefined && { title: input.title }),
  981. });
  982. const { hostname, protocol = "https", port } = await context.endpoint();
  983. return new __HttpRequest({
  984. protocol,
  985. hostname,
  986. port,
  987. method: "DELETE",
  988. headers,
  989. path: resolvedPath,
  990. body,
  991. });
  992. };
  993. export const serializeAws_restJson1DeleteBasePathMappingCommand = async (
  994. input: DeleteBasePathMappingCommandInput,
  995. context: __SerdeContext
  996. ): Promise<__HttpRequest> => {
  997. const headers: any = {
  998. "Content-Type": "application/json",
  999. };
  1000. let resolvedPath = "/domainnames/{domainName}/basepathmappings/{basePath}";
  1001. if (input.domainName !== undefined) {
  1002. const labelValue: string = input.domainName;
  1003. if (labelValue.length <= 0) {
  1004. throw new Error("Empty value provided for input HTTP label: domainName.");
  1005. }
  1006. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  1007. } else {
  1008. throw new Error("No value provided for input HTTP label: domainName.");
  1009. }
  1010. if (input.basePath !== undefined) {
  1011. const labelValue: string = input.basePath;
  1012. if (labelValue.length <= 0) {
  1013. throw new Error("Empty value provided for input HTTP label: basePath.");
  1014. }
  1015. resolvedPath = resolvedPath.replace("{basePath}", __extendedEncodeURIComponent(labelValue));
  1016. } else {
  1017. throw new Error("No value provided for input HTTP label: basePath.");
  1018. }
  1019. let body: any;
  1020. body = JSON.stringify({
  1021. ...(input.name !== undefined && { name: input.name }),
  1022. ...(input.template !== undefined && { template: input.template }),
  1023. ...(input.templateSkipList !== undefined && {
  1024. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1025. }),
  1026. ...(input.title !== undefined && { title: input.title }),
  1027. });
  1028. const { hostname, protocol = "https", port } = await context.endpoint();
  1029. return new __HttpRequest({
  1030. protocol,
  1031. hostname,
  1032. port,
  1033. method: "DELETE",
  1034. headers,
  1035. path: resolvedPath,
  1036. body,
  1037. });
  1038. };
  1039. export const serializeAws_restJson1DeleteClientCertificateCommand = async (
  1040. input: DeleteClientCertificateCommandInput,
  1041. context: __SerdeContext
  1042. ): Promise<__HttpRequest> => {
  1043. const headers: any = {
  1044. "Content-Type": "application/json",
  1045. };
  1046. let resolvedPath = "/clientcertificates/{clientCertificateId}";
  1047. if (input.clientCertificateId !== undefined) {
  1048. const labelValue: string = input.clientCertificateId;
  1049. if (labelValue.length <= 0) {
  1050. throw new Error("Empty value provided for input HTTP label: clientCertificateId.");
  1051. }
  1052. resolvedPath = resolvedPath.replace("{clientCertificateId}", __extendedEncodeURIComponent(labelValue));
  1053. } else {
  1054. throw new Error("No value provided for input HTTP label: clientCertificateId.");
  1055. }
  1056. let body: any;
  1057. body = JSON.stringify({
  1058. ...(input.name !== undefined && { name: input.name }),
  1059. ...(input.template !== undefined && { template: input.template }),
  1060. ...(input.templateSkipList !== undefined && {
  1061. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1062. }),
  1063. ...(input.title !== undefined && { title: input.title }),
  1064. });
  1065. const { hostname, protocol = "https", port } = await context.endpoint();
  1066. return new __HttpRequest({
  1067. protocol,
  1068. hostname,
  1069. port,
  1070. method: "DELETE",
  1071. headers,
  1072. path: resolvedPath,
  1073. body,
  1074. });
  1075. };
  1076. export const serializeAws_restJson1DeleteDeploymentCommand = async (
  1077. input: DeleteDeploymentCommandInput,
  1078. context: __SerdeContext
  1079. ): Promise<__HttpRequest> => {
  1080. const headers: any = {
  1081. "Content-Type": "application/json",
  1082. };
  1083. let resolvedPath = "/restapis/{restApiId}/deployments/{deploymentId}";
  1084. if (input.deploymentId !== undefined) {
  1085. const labelValue: string = input.deploymentId;
  1086. if (labelValue.length <= 0) {
  1087. throw new Error("Empty value provided for input HTTP label: deploymentId.");
  1088. }
  1089. resolvedPath = resolvedPath.replace("{deploymentId}", __extendedEncodeURIComponent(labelValue));
  1090. } else {
  1091. throw new Error("No value provided for input HTTP label: deploymentId.");
  1092. }
  1093. if (input.restApiId !== undefined) {
  1094. const labelValue: string = input.restApiId;
  1095. if (labelValue.length <= 0) {
  1096. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1097. }
  1098. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1099. } else {
  1100. throw new Error("No value provided for input HTTP label: restApiId.");
  1101. }
  1102. let body: any;
  1103. body = JSON.stringify({
  1104. ...(input.name !== undefined && { name: input.name }),
  1105. ...(input.template !== undefined && { template: input.template }),
  1106. ...(input.templateSkipList !== undefined && {
  1107. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1108. }),
  1109. ...(input.title !== undefined && { title: input.title }),
  1110. });
  1111. const { hostname, protocol = "https", port } = await context.endpoint();
  1112. return new __HttpRequest({
  1113. protocol,
  1114. hostname,
  1115. port,
  1116. method: "DELETE",
  1117. headers,
  1118. path: resolvedPath,
  1119. body,
  1120. });
  1121. };
  1122. export const serializeAws_restJson1DeleteDocumentationPartCommand = async (
  1123. input: DeleteDocumentationPartCommandInput,
  1124. context: __SerdeContext
  1125. ): Promise<__HttpRequest> => {
  1126. const headers: any = {
  1127. "Content-Type": "application/json",
  1128. };
  1129. let resolvedPath = "/restapis/{restApiId}/documentation/parts/{documentationPartId}";
  1130. if (input.restApiId !== undefined) {
  1131. const labelValue: string = input.restApiId;
  1132. if (labelValue.length <= 0) {
  1133. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1134. }
  1135. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1136. } else {
  1137. throw new Error("No value provided for input HTTP label: restApiId.");
  1138. }
  1139. if (input.documentationPartId !== undefined) {
  1140. const labelValue: string = input.documentationPartId;
  1141. if (labelValue.length <= 0) {
  1142. throw new Error("Empty value provided for input HTTP label: documentationPartId.");
  1143. }
  1144. resolvedPath = resolvedPath.replace("{documentationPartId}", __extendedEncodeURIComponent(labelValue));
  1145. } else {
  1146. throw new Error("No value provided for input HTTP label: documentationPartId.");
  1147. }
  1148. let body: any;
  1149. body = JSON.stringify({
  1150. ...(input.name !== undefined && { name: input.name }),
  1151. ...(input.template !== undefined && { template: input.template }),
  1152. ...(input.templateSkipList !== undefined && {
  1153. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1154. }),
  1155. ...(input.title !== undefined && { title: input.title }),
  1156. });
  1157. const { hostname, protocol = "https", port } = await context.endpoint();
  1158. return new __HttpRequest({
  1159. protocol,
  1160. hostname,
  1161. port,
  1162. method: "DELETE",
  1163. headers,
  1164. path: resolvedPath,
  1165. body,
  1166. });
  1167. };
  1168. export const serializeAws_restJson1DeleteDocumentationVersionCommand = async (
  1169. input: DeleteDocumentationVersionCommandInput,
  1170. context: __SerdeContext
  1171. ): Promise<__HttpRequest> => {
  1172. const headers: any = {
  1173. "Content-Type": "application/json",
  1174. };
  1175. let resolvedPath = "/restapis/{restApiId}/documentation/versions/{documentationVersion}";
  1176. if (input.documentationVersion !== undefined) {
  1177. const labelValue: string = input.documentationVersion;
  1178. if (labelValue.length <= 0) {
  1179. throw new Error("Empty value provided for input HTTP label: documentationVersion.");
  1180. }
  1181. resolvedPath = resolvedPath.replace("{documentationVersion}", __extendedEncodeURIComponent(labelValue));
  1182. } else {
  1183. throw new Error("No value provided for input HTTP label: documentationVersion.");
  1184. }
  1185. if (input.restApiId !== undefined) {
  1186. const labelValue: string = input.restApiId;
  1187. if (labelValue.length <= 0) {
  1188. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1189. }
  1190. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1191. } else {
  1192. throw new Error("No value provided for input HTTP label: restApiId.");
  1193. }
  1194. let body: any;
  1195. body = JSON.stringify({
  1196. ...(input.name !== undefined && { name: input.name }),
  1197. ...(input.template !== undefined && { template: input.template }),
  1198. ...(input.templateSkipList !== undefined && {
  1199. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1200. }),
  1201. ...(input.title !== undefined && { title: input.title }),
  1202. });
  1203. const { hostname, protocol = "https", port } = await context.endpoint();
  1204. return new __HttpRequest({
  1205. protocol,
  1206. hostname,
  1207. port,
  1208. method: "DELETE",
  1209. headers,
  1210. path: resolvedPath,
  1211. body,
  1212. });
  1213. };
  1214. export const serializeAws_restJson1DeleteDomainNameCommand = async (
  1215. input: DeleteDomainNameCommandInput,
  1216. context: __SerdeContext
  1217. ): Promise<__HttpRequest> => {
  1218. const headers: any = {
  1219. "Content-Type": "application/json",
  1220. };
  1221. let resolvedPath = "/domainnames/{domainName}";
  1222. if (input.domainName !== undefined) {
  1223. const labelValue: string = input.domainName;
  1224. if (labelValue.length <= 0) {
  1225. throw new Error("Empty value provided for input HTTP label: domainName.");
  1226. }
  1227. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  1228. } else {
  1229. throw new Error("No value provided for input HTTP label: domainName.");
  1230. }
  1231. let body: any;
  1232. body = JSON.stringify({
  1233. ...(input.name !== undefined && { name: input.name }),
  1234. ...(input.template !== undefined && { template: input.template }),
  1235. ...(input.templateSkipList !== undefined && {
  1236. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1237. }),
  1238. ...(input.title !== undefined && { title: input.title }),
  1239. });
  1240. const { hostname, protocol = "https", port } = await context.endpoint();
  1241. return new __HttpRequest({
  1242. protocol,
  1243. hostname,
  1244. port,
  1245. method: "DELETE",
  1246. headers,
  1247. path: resolvedPath,
  1248. body,
  1249. });
  1250. };
  1251. export const serializeAws_restJson1DeleteGatewayResponseCommand = async (
  1252. input: DeleteGatewayResponseCommandInput,
  1253. context: __SerdeContext
  1254. ): Promise<__HttpRequest> => {
  1255. const headers: any = {
  1256. "Content-Type": "application/json",
  1257. };
  1258. let resolvedPath = "/restapis/{restApiId}/gatewayresponses/{responseType}";
  1259. if (input.restApiId !== undefined) {
  1260. const labelValue: string = input.restApiId;
  1261. if (labelValue.length <= 0) {
  1262. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1263. }
  1264. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1265. } else {
  1266. throw new Error("No value provided for input HTTP label: restApiId.");
  1267. }
  1268. if (input.responseType !== undefined) {
  1269. const labelValue: string = input.responseType;
  1270. if (labelValue.length <= 0) {
  1271. throw new Error("Empty value provided for input HTTP label: responseType.");
  1272. }
  1273. resolvedPath = resolvedPath.replace("{responseType}", __extendedEncodeURIComponent(labelValue));
  1274. } else {
  1275. throw new Error("No value provided for input HTTP label: responseType.");
  1276. }
  1277. let body: any;
  1278. body = JSON.stringify({
  1279. ...(input.name !== undefined && { name: input.name }),
  1280. ...(input.template !== undefined && { template: input.template }),
  1281. ...(input.templateSkipList !== undefined && {
  1282. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1283. }),
  1284. ...(input.title !== undefined && { title: input.title }),
  1285. });
  1286. const { hostname, protocol = "https", port } = await context.endpoint();
  1287. return new __HttpRequest({
  1288. protocol,
  1289. hostname,
  1290. port,
  1291. method: "DELETE",
  1292. headers,
  1293. path: resolvedPath,
  1294. body,
  1295. });
  1296. };
  1297. export const serializeAws_restJson1DeleteIntegrationCommand = async (
  1298. input: DeleteIntegrationCommandInput,
  1299. context: __SerdeContext
  1300. ): Promise<__HttpRequest> => {
  1301. const headers: any = {
  1302. "Content-Type": "application/json",
  1303. };
  1304. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration";
  1305. if (input.httpMethod !== undefined) {
  1306. const labelValue: string = input.httpMethod;
  1307. if (labelValue.length <= 0) {
  1308. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  1309. }
  1310. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  1311. } else {
  1312. throw new Error("No value provided for input HTTP label: httpMethod.");
  1313. }
  1314. if (input.restApiId !== undefined) {
  1315. const labelValue: string = input.restApiId;
  1316. if (labelValue.length <= 0) {
  1317. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1318. }
  1319. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1320. } else {
  1321. throw new Error("No value provided for input HTTP label: restApiId.");
  1322. }
  1323. if (input.resourceId !== undefined) {
  1324. const labelValue: string = input.resourceId;
  1325. if (labelValue.length <= 0) {
  1326. throw new Error("Empty value provided for input HTTP label: resourceId.");
  1327. }
  1328. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  1329. } else {
  1330. throw new Error("No value provided for input HTTP label: resourceId.");
  1331. }
  1332. let body: any;
  1333. body = JSON.stringify({
  1334. ...(input.name !== undefined && { name: input.name }),
  1335. ...(input.template !== undefined && { template: input.template }),
  1336. ...(input.templateSkipList !== undefined && {
  1337. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1338. }),
  1339. ...(input.title !== undefined && { title: input.title }),
  1340. });
  1341. const { hostname, protocol = "https", port } = await context.endpoint();
  1342. return new __HttpRequest({
  1343. protocol,
  1344. hostname,
  1345. port,
  1346. method: "DELETE",
  1347. headers,
  1348. path: resolvedPath,
  1349. body,
  1350. });
  1351. };
  1352. export const serializeAws_restJson1DeleteIntegrationResponseCommand = async (
  1353. input: DeleteIntegrationResponseCommandInput,
  1354. context: __SerdeContext
  1355. ): Promise<__HttpRequest> => {
  1356. const headers: any = {
  1357. "Content-Type": "application/json",
  1358. };
  1359. let resolvedPath =
  1360. "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration/responses/{statusCode}";
  1361. if (input.resourceId !== undefined) {
  1362. const labelValue: string = input.resourceId;
  1363. if (labelValue.length <= 0) {
  1364. throw new Error("Empty value provided for input HTTP label: resourceId.");
  1365. }
  1366. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  1367. } else {
  1368. throw new Error("No value provided for input HTTP label: resourceId.");
  1369. }
  1370. if (input.httpMethod !== undefined) {
  1371. const labelValue: string = input.httpMethod;
  1372. if (labelValue.length <= 0) {
  1373. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  1374. }
  1375. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  1376. } else {
  1377. throw new Error("No value provided for input HTTP label: httpMethod.");
  1378. }
  1379. if (input.statusCode !== undefined) {
  1380. const labelValue: string = input.statusCode;
  1381. if (labelValue.length <= 0) {
  1382. throw new Error("Empty value provided for input HTTP label: statusCode.");
  1383. }
  1384. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  1385. } else {
  1386. throw new Error("No value provided for input HTTP label: statusCode.");
  1387. }
  1388. if (input.restApiId !== undefined) {
  1389. const labelValue: string = input.restApiId;
  1390. if (labelValue.length <= 0) {
  1391. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1392. }
  1393. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1394. } else {
  1395. throw new Error("No value provided for input HTTP label: restApiId.");
  1396. }
  1397. let body: any;
  1398. body = JSON.stringify({
  1399. ...(input.name !== undefined && { name: input.name }),
  1400. ...(input.template !== undefined && { template: input.template }),
  1401. ...(input.templateSkipList !== undefined && {
  1402. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1403. }),
  1404. ...(input.title !== undefined && { title: input.title }),
  1405. });
  1406. const { hostname, protocol = "https", port } = await context.endpoint();
  1407. return new __HttpRequest({
  1408. protocol,
  1409. hostname,
  1410. port,
  1411. method: "DELETE",
  1412. headers,
  1413. path: resolvedPath,
  1414. body,
  1415. });
  1416. };
  1417. export const serializeAws_restJson1DeleteMethodCommand = async (
  1418. input: DeleteMethodCommandInput,
  1419. context: __SerdeContext
  1420. ): Promise<__HttpRequest> => {
  1421. const headers: any = {
  1422. "Content-Type": "application/json",
  1423. };
  1424. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}";
  1425. if (input.restApiId !== undefined) {
  1426. const labelValue: string = input.restApiId;
  1427. if (labelValue.length <= 0) {
  1428. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1429. }
  1430. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1431. } else {
  1432. throw new Error("No value provided for input HTTP label: restApiId.");
  1433. }
  1434. if (input.httpMethod !== undefined) {
  1435. const labelValue: string = input.httpMethod;
  1436. if (labelValue.length <= 0) {
  1437. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  1438. }
  1439. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  1440. } else {
  1441. throw new Error("No value provided for input HTTP label: httpMethod.");
  1442. }
  1443. if (input.resourceId !== undefined) {
  1444. const labelValue: string = input.resourceId;
  1445. if (labelValue.length <= 0) {
  1446. throw new Error("Empty value provided for input HTTP label: resourceId.");
  1447. }
  1448. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  1449. } else {
  1450. throw new Error("No value provided for input HTTP label: resourceId.");
  1451. }
  1452. let body: any;
  1453. body = JSON.stringify({
  1454. ...(input.name !== undefined && { name: input.name }),
  1455. ...(input.template !== undefined && { template: input.template }),
  1456. ...(input.templateSkipList !== undefined && {
  1457. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1458. }),
  1459. ...(input.title !== undefined && { title: input.title }),
  1460. });
  1461. const { hostname, protocol = "https", port } = await context.endpoint();
  1462. return new __HttpRequest({
  1463. protocol,
  1464. hostname,
  1465. port,
  1466. method: "DELETE",
  1467. headers,
  1468. path: resolvedPath,
  1469. body,
  1470. });
  1471. };
  1472. export const serializeAws_restJson1DeleteMethodResponseCommand = async (
  1473. input: DeleteMethodResponseCommandInput,
  1474. context: __SerdeContext
  1475. ): Promise<__HttpRequest> => {
  1476. const headers: any = {
  1477. "Content-Type": "application/json",
  1478. };
  1479. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/responses/{statusCode}";
  1480. if (input.httpMethod !== undefined) {
  1481. const labelValue: string = input.httpMethod;
  1482. if (labelValue.length <= 0) {
  1483. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  1484. }
  1485. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  1486. } else {
  1487. throw new Error("No value provided for input HTTP label: httpMethod.");
  1488. }
  1489. if (input.statusCode !== undefined) {
  1490. const labelValue: string = input.statusCode;
  1491. if (labelValue.length <= 0) {
  1492. throw new Error("Empty value provided for input HTTP label: statusCode.");
  1493. }
  1494. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  1495. } else {
  1496. throw new Error("No value provided for input HTTP label: statusCode.");
  1497. }
  1498. if (input.resourceId !== undefined) {
  1499. const labelValue: string = input.resourceId;
  1500. if (labelValue.length <= 0) {
  1501. throw new Error("Empty value provided for input HTTP label: resourceId.");
  1502. }
  1503. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  1504. } else {
  1505. throw new Error("No value provided for input HTTP label: resourceId.");
  1506. }
  1507. if (input.restApiId !== undefined) {
  1508. const labelValue: string = input.restApiId;
  1509. if (labelValue.length <= 0) {
  1510. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1511. }
  1512. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1513. } else {
  1514. throw new Error("No value provided for input HTTP label: restApiId.");
  1515. }
  1516. let body: any;
  1517. body = JSON.stringify({
  1518. ...(input.name !== undefined && { name: input.name }),
  1519. ...(input.template !== undefined && { template: input.template }),
  1520. ...(input.templateSkipList !== undefined && {
  1521. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1522. }),
  1523. ...(input.title !== undefined && { title: input.title }),
  1524. });
  1525. const { hostname, protocol = "https", port } = await context.endpoint();
  1526. return new __HttpRequest({
  1527. protocol,
  1528. hostname,
  1529. port,
  1530. method: "DELETE",
  1531. headers,
  1532. path: resolvedPath,
  1533. body,
  1534. });
  1535. };
  1536. export const serializeAws_restJson1DeleteModelCommand = async (
  1537. input: DeleteModelCommandInput,
  1538. context: __SerdeContext
  1539. ): Promise<__HttpRequest> => {
  1540. const headers: any = {
  1541. "Content-Type": "application/json",
  1542. };
  1543. let resolvedPath = "/restapis/{restApiId}/models/{modelName}";
  1544. if (input.restApiId !== undefined) {
  1545. const labelValue: string = input.restApiId;
  1546. if (labelValue.length <= 0) {
  1547. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1548. }
  1549. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1550. } else {
  1551. throw new Error("No value provided for input HTTP label: restApiId.");
  1552. }
  1553. if (input.modelName !== undefined) {
  1554. const labelValue: string = input.modelName;
  1555. if (labelValue.length <= 0) {
  1556. throw new Error("Empty value provided for input HTTP label: modelName.");
  1557. }
  1558. resolvedPath = resolvedPath.replace("{modelName}", __extendedEncodeURIComponent(labelValue));
  1559. } else {
  1560. throw new Error("No value provided for input HTTP label: modelName.");
  1561. }
  1562. let body: any;
  1563. body = JSON.stringify({
  1564. ...(input.name !== undefined && { name: input.name }),
  1565. ...(input.template !== undefined && { template: input.template }),
  1566. ...(input.templateSkipList !== undefined && {
  1567. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1568. }),
  1569. ...(input.title !== undefined && { title: input.title }),
  1570. });
  1571. const { hostname, protocol = "https", port } = await context.endpoint();
  1572. return new __HttpRequest({
  1573. protocol,
  1574. hostname,
  1575. port,
  1576. method: "DELETE",
  1577. headers,
  1578. path: resolvedPath,
  1579. body,
  1580. });
  1581. };
  1582. export const serializeAws_restJson1DeleteRequestValidatorCommand = async (
  1583. input: DeleteRequestValidatorCommandInput,
  1584. context: __SerdeContext
  1585. ): Promise<__HttpRequest> => {
  1586. const headers: any = {
  1587. "Content-Type": "application/json",
  1588. };
  1589. let resolvedPath = "/restapis/{restApiId}/requestvalidators/{requestValidatorId}";
  1590. if (input.restApiId !== undefined) {
  1591. const labelValue: string = input.restApiId;
  1592. if (labelValue.length <= 0) {
  1593. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1594. }
  1595. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1596. } else {
  1597. throw new Error("No value provided for input HTTP label: restApiId.");
  1598. }
  1599. if (input.requestValidatorId !== undefined) {
  1600. const labelValue: string = input.requestValidatorId;
  1601. if (labelValue.length <= 0) {
  1602. throw new Error("Empty value provided for input HTTP label: requestValidatorId.");
  1603. }
  1604. resolvedPath = resolvedPath.replace("{requestValidatorId}", __extendedEncodeURIComponent(labelValue));
  1605. } else {
  1606. throw new Error("No value provided for input HTTP label: requestValidatorId.");
  1607. }
  1608. let body: any;
  1609. body = JSON.stringify({
  1610. ...(input.name !== undefined && { name: input.name }),
  1611. ...(input.template !== undefined && { template: input.template }),
  1612. ...(input.templateSkipList !== undefined && {
  1613. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1614. }),
  1615. ...(input.title !== undefined && { title: input.title }),
  1616. });
  1617. const { hostname, protocol = "https", port } = await context.endpoint();
  1618. return new __HttpRequest({
  1619. protocol,
  1620. hostname,
  1621. port,
  1622. method: "DELETE",
  1623. headers,
  1624. path: resolvedPath,
  1625. body,
  1626. });
  1627. };
  1628. export const serializeAws_restJson1DeleteResourceCommand = async (
  1629. input: DeleteResourceCommandInput,
  1630. context: __SerdeContext
  1631. ): Promise<__HttpRequest> => {
  1632. const headers: any = {
  1633. "Content-Type": "application/json",
  1634. };
  1635. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}";
  1636. if (input.restApiId !== undefined) {
  1637. const labelValue: string = input.restApiId;
  1638. if (labelValue.length <= 0) {
  1639. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1640. }
  1641. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1642. } else {
  1643. throw new Error("No value provided for input HTTP label: restApiId.");
  1644. }
  1645. if (input.resourceId !== undefined) {
  1646. const labelValue: string = input.resourceId;
  1647. if (labelValue.length <= 0) {
  1648. throw new Error("Empty value provided for input HTTP label: resourceId.");
  1649. }
  1650. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  1651. } else {
  1652. throw new Error("No value provided for input HTTP label: resourceId.");
  1653. }
  1654. let body: any;
  1655. body = JSON.stringify({
  1656. ...(input.name !== undefined && { name: input.name }),
  1657. ...(input.template !== undefined && { template: input.template }),
  1658. ...(input.templateSkipList !== undefined && {
  1659. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1660. }),
  1661. ...(input.title !== undefined && { title: input.title }),
  1662. });
  1663. const { hostname, protocol = "https", port } = await context.endpoint();
  1664. return new __HttpRequest({
  1665. protocol,
  1666. hostname,
  1667. port,
  1668. method: "DELETE",
  1669. headers,
  1670. path: resolvedPath,
  1671. body,
  1672. });
  1673. };
  1674. export const serializeAws_restJson1DeleteRestApiCommand = async (
  1675. input: DeleteRestApiCommandInput,
  1676. context: __SerdeContext
  1677. ): Promise<__HttpRequest> => {
  1678. const headers: any = {
  1679. "Content-Type": "application/json",
  1680. };
  1681. let resolvedPath = "/restapis/{restApiId}";
  1682. if (input.restApiId !== undefined) {
  1683. const labelValue: string = input.restApiId;
  1684. if (labelValue.length <= 0) {
  1685. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1686. }
  1687. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1688. } else {
  1689. throw new Error("No value provided for input HTTP label: restApiId.");
  1690. }
  1691. let body: any;
  1692. body = JSON.stringify({
  1693. ...(input.name !== undefined && { name: input.name }),
  1694. ...(input.template !== undefined && { template: input.template }),
  1695. ...(input.templateSkipList !== undefined && {
  1696. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1697. }),
  1698. ...(input.title !== undefined && { title: input.title }),
  1699. });
  1700. const { hostname, protocol = "https", port } = await context.endpoint();
  1701. return new __HttpRequest({
  1702. protocol,
  1703. hostname,
  1704. port,
  1705. method: "DELETE",
  1706. headers,
  1707. path: resolvedPath,
  1708. body,
  1709. });
  1710. };
  1711. export const serializeAws_restJson1DeleteStageCommand = async (
  1712. input: DeleteStageCommandInput,
  1713. context: __SerdeContext
  1714. ): Promise<__HttpRequest> => {
  1715. const headers: any = {
  1716. "Content-Type": "application/json",
  1717. };
  1718. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}";
  1719. if (input.stageName !== undefined) {
  1720. const labelValue: string = input.stageName;
  1721. if (labelValue.length <= 0) {
  1722. throw new Error("Empty value provided for input HTTP label: stageName.");
  1723. }
  1724. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  1725. } else {
  1726. throw new Error("No value provided for input HTTP label: stageName.");
  1727. }
  1728. if (input.restApiId !== undefined) {
  1729. const labelValue: string = input.restApiId;
  1730. if (labelValue.length <= 0) {
  1731. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1732. }
  1733. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1734. } else {
  1735. throw new Error("No value provided for input HTTP label: restApiId.");
  1736. }
  1737. let body: any;
  1738. body = JSON.stringify({
  1739. ...(input.name !== undefined && { name: input.name }),
  1740. ...(input.template !== undefined && { template: input.template }),
  1741. ...(input.templateSkipList !== undefined && {
  1742. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1743. }),
  1744. ...(input.title !== undefined && { title: input.title }),
  1745. });
  1746. const { hostname, protocol = "https", port } = await context.endpoint();
  1747. return new __HttpRequest({
  1748. protocol,
  1749. hostname,
  1750. port,
  1751. method: "DELETE",
  1752. headers,
  1753. path: resolvedPath,
  1754. body,
  1755. });
  1756. };
  1757. export const serializeAws_restJson1DeleteUsagePlanCommand = async (
  1758. input: DeleteUsagePlanCommandInput,
  1759. context: __SerdeContext
  1760. ): Promise<__HttpRequest> => {
  1761. const headers: any = {
  1762. "Content-Type": "application/json",
  1763. };
  1764. let resolvedPath = "/usageplans/{usagePlanId}";
  1765. if (input.usagePlanId !== undefined) {
  1766. const labelValue: string = input.usagePlanId;
  1767. if (labelValue.length <= 0) {
  1768. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  1769. }
  1770. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  1771. } else {
  1772. throw new Error("No value provided for input HTTP label: usagePlanId.");
  1773. }
  1774. let body: any;
  1775. body = JSON.stringify({
  1776. ...(input.name !== undefined && { name: input.name }),
  1777. ...(input.template !== undefined && { template: input.template }),
  1778. ...(input.templateSkipList !== undefined && {
  1779. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1780. }),
  1781. ...(input.title !== undefined && { title: input.title }),
  1782. });
  1783. const { hostname, protocol = "https", port } = await context.endpoint();
  1784. return new __HttpRequest({
  1785. protocol,
  1786. hostname,
  1787. port,
  1788. method: "DELETE",
  1789. headers,
  1790. path: resolvedPath,
  1791. body,
  1792. });
  1793. };
  1794. export const serializeAws_restJson1DeleteUsagePlanKeyCommand = async (
  1795. input: DeleteUsagePlanKeyCommandInput,
  1796. context: __SerdeContext
  1797. ): Promise<__HttpRequest> => {
  1798. const headers: any = {
  1799. "Content-Type": "application/json",
  1800. };
  1801. let resolvedPath = "/usageplans/{usagePlanId}/keys/{keyId}";
  1802. if (input.keyId !== undefined) {
  1803. const labelValue: string = input.keyId;
  1804. if (labelValue.length <= 0) {
  1805. throw new Error("Empty value provided for input HTTP label: keyId.");
  1806. }
  1807. resolvedPath = resolvedPath.replace("{keyId}", __extendedEncodeURIComponent(labelValue));
  1808. } else {
  1809. throw new Error("No value provided for input HTTP label: keyId.");
  1810. }
  1811. if (input.usagePlanId !== undefined) {
  1812. const labelValue: string = input.usagePlanId;
  1813. if (labelValue.length <= 0) {
  1814. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  1815. }
  1816. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  1817. } else {
  1818. throw new Error("No value provided for input HTTP label: usagePlanId.");
  1819. }
  1820. let body: any;
  1821. body = JSON.stringify({
  1822. ...(input.name !== undefined && { name: input.name }),
  1823. ...(input.template !== undefined && { template: input.template }),
  1824. ...(input.templateSkipList !== undefined && {
  1825. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1826. }),
  1827. ...(input.title !== undefined && { title: input.title }),
  1828. });
  1829. const { hostname, protocol = "https", port } = await context.endpoint();
  1830. return new __HttpRequest({
  1831. protocol,
  1832. hostname,
  1833. port,
  1834. method: "DELETE",
  1835. headers,
  1836. path: resolvedPath,
  1837. body,
  1838. });
  1839. };
  1840. export const serializeAws_restJson1DeleteVpcLinkCommand = async (
  1841. input: DeleteVpcLinkCommandInput,
  1842. context: __SerdeContext
  1843. ): Promise<__HttpRequest> => {
  1844. const headers: any = {
  1845. "Content-Type": "application/json",
  1846. };
  1847. let resolvedPath = "/vpclinks/{vpcLinkId}";
  1848. if (input.vpcLinkId !== undefined) {
  1849. const labelValue: string = input.vpcLinkId;
  1850. if (labelValue.length <= 0) {
  1851. throw new Error("Empty value provided for input HTTP label: vpcLinkId.");
  1852. }
  1853. resolvedPath = resolvedPath.replace("{vpcLinkId}", __extendedEncodeURIComponent(labelValue));
  1854. } else {
  1855. throw new Error("No value provided for input HTTP label: vpcLinkId.");
  1856. }
  1857. let body: any;
  1858. body = JSON.stringify({
  1859. ...(input.name !== undefined && { name: input.name }),
  1860. ...(input.template !== undefined && { template: input.template }),
  1861. ...(input.templateSkipList !== undefined && {
  1862. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1863. }),
  1864. ...(input.title !== undefined && { title: input.title }),
  1865. });
  1866. const { hostname, protocol = "https", port } = await context.endpoint();
  1867. return new __HttpRequest({
  1868. protocol,
  1869. hostname,
  1870. port,
  1871. method: "DELETE",
  1872. headers,
  1873. path: resolvedPath,
  1874. body,
  1875. });
  1876. };
  1877. export const serializeAws_restJson1FlushStageAuthorizersCacheCommand = async (
  1878. input: FlushStageAuthorizersCacheCommandInput,
  1879. context: __SerdeContext
  1880. ): Promise<__HttpRequest> => {
  1881. const headers: any = {
  1882. "Content-Type": "application/json",
  1883. };
  1884. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}/cache/authorizers";
  1885. if (input.stageName !== undefined) {
  1886. const labelValue: string = input.stageName;
  1887. if (labelValue.length <= 0) {
  1888. throw new Error("Empty value provided for input HTTP label: stageName.");
  1889. }
  1890. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  1891. } else {
  1892. throw new Error("No value provided for input HTTP label: stageName.");
  1893. }
  1894. if (input.restApiId !== undefined) {
  1895. const labelValue: string = input.restApiId;
  1896. if (labelValue.length <= 0) {
  1897. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1898. }
  1899. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1900. } else {
  1901. throw new Error("No value provided for input HTTP label: restApiId.");
  1902. }
  1903. let body: any;
  1904. body = JSON.stringify({
  1905. ...(input.name !== undefined && { name: input.name }),
  1906. ...(input.template !== undefined && { template: input.template }),
  1907. ...(input.templateSkipList !== undefined && {
  1908. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1909. }),
  1910. ...(input.title !== undefined && { title: input.title }),
  1911. });
  1912. const { hostname, protocol = "https", port } = await context.endpoint();
  1913. return new __HttpRequest({
  1914. protocol,
  1915. hostname,
  1916. port,
  1917. method: "DELETE",
  1918. headers,
  1919. path: resolvedPath,
  1920. body,
  1921. });
  1922. };
  1923. export const serializeAws_restJson1FlushStageCacheCommand = async (
  1924. input: FlushStageCacheCommandInput,
  1925. context: __SerdeContext
  1926. ): Promise<__HttpRequest> => {
  1927. const headers: any = {
  1928. "Content-Type": "application/json",
  1929. };
  1930. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}/cache/data";
  1931. if (input.stageName !== undefined) {
  1932. const labelValue: string = input.stageName;
  1933. if (labelValue.length <= 0) {
  1934. throw new Error("Empty value provided for input HTTP label: stageName.");
  1935. }
  1936. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  1937. } else {
  1938. throw new Error("No value provided for input HTTP label: stageName.");
  1939. }
  1940. if (input.restApiId !== undefined) {
  1941. const labelValue: string = input.restApiId;
  1942. if (labelValue.length <= 0) {
  1943. throw new Error("Empty value provided for input HTTP label: restApiId.");
  1944. }
  1945. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  1946. } else {
  1947. throw new Error("No value provided for input HTTP label: restApiId.");
  1948. }
  1949. let body: any;
  1950. body = JSON.stringify({
  1951. ...(input.name !== undefined && { name: input.name }),
  1952. ...(input.template !== undefined && { template: input.template }),
  1953. ...(input.templateSkipList !== undefined && {
  1954. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1955. }),
  1956. ...(input.title !== undefined && { title: input.title }),
  1957. });
  1958. const { hostname, protocol = "https", port } = await context.endpoint();
  1959. return new __HttpRequest({
  1960. protocol,
  1961. hostname,
  1962. port,
  1963. method: "DELETE",
  1964. headers,
  1965. path: resolvedPath,
  1966. body,
  1967. });
  1968. };
  1969. export const serializeAws_restJson1GenerateClientCertificateCommand = async (
  1970. input: GenerateClientCertificateCommandInput,
  1971. context: __SerdeContext
  1972. ): Promise<__HttpRequest> => {
  1973. const headers: any = {
  1974. "Content-Type": "application/json",
  1975. };
  1976. let resolvedPath = "/clientcertificates";
  1977. let body: any;
  1978. body = JSON.stringify({
  1979. ...(input.description !== undefined && { description: input.description }),
  1980. ...(input.name !== undefined && { name: input.name }),
  1981. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  1982. ...(input.template !== undefined && { template: input.template }),
  1983. ...(input.templateSkipList !== undefined && {
  1984. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  1985. }),
  1986. ...(input.title !== undefined && { title: input.title }),
  1987. });
  1988. const { hostname, protocol = "https", port } = await context.endpoint();
  1989. return new __HttpRequest({
  1990. protocol,
  1991. hostname,
  1992. port,
  1993. method: "POST",
  1994. headers,
  1995. path: resolvedPath,
  1996. body,
  1997. });
  1998. };
  1999. export const serializeAws_restJson1GetAccountCommand = async (
  2000. input: GetAccountCommandInput,
  2001. context: __SerdeContext
  2002. ): Promise<__HttpRequest> => {
  2003. const headers: any = {
  2004. "Content-Type": "application/json",
  2005. };
  2006. let resolvedPath = "/account";
  2007. let body: any;
  2008. body = JSON.stringify({
  2009. ...(input.name !== undefined && { name: input.name }),
  2010. ...(input.template !== undefined && { template: input.template }),
  2011. ...(input.templateSkipList !== undefined && {
  2012. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2013. }),
  2014. ...(input.title !== undefined && { title: input.title }),
  2015. });
  2016. const { hostname, protocol = "https", port } = await context.endpoint();
  2017. return new __HttpRequest({
  2018. protocol,
  2019. hostname,
  2020. port,
  2021. method: "GET",
  2022. headers,
  2023. path: resolvedPath,
  2024. body,
  2025. });
  2026. };
  2027. export const serializeAws_restJson1GetApiKeyCommand = async (
  2028. input: GetApiKeyCommandInput,
  2029. context: __SerdeContext
  2030. ): Promise<__HttpRequest> => {
  2031. const headers: any = {
  2032. "Content-Type": "application/json",
  2033. };
  2034. let resolvedPath = "/apikeys/{apiKey}";
  2035. if (input.apiKey !== undefined) {
  2036. const labelValue: string = input.apiKey;
  2037. if (labelValue.length <= 0) {
  2038. throw new Error("Empty value provided for input HTTP label: apiKey.");
  2039. }
  2040. resolvedPath = resolvedPath.replace("{apiKey}", __extendedEncodeURIComponent(labelValue));
  2041. } else {
  2042. throw new Error("No value provided for input HTTP label: apiKey.");
  2043. }
  2044. const query: any = {
  2045. ...(input.includeValue !== undefined && { includeValue: input.includeValue.toString() }),
  2046. };
  2047. let body: any;
  2048. body = JSON.stringify({
  2049. ...(input.name !== undefined && { name: input.name }),
  2050. ...(input.template !== undefined && { template: input.template }),
  2051. ...(input.templateSkipList !== undefined && {
  2052. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2053. }),
  2054. ...(input.title !== undefined && { title: input.title }),
  2055. });
  2056. const { hostname, protocol = "https", port } = await context.endpoint();
  2057. return new __HttpRequest({
  2058. protocol,
  2059. hostname,
  2060. port,
  2061. method: "GET",
  2062. headers,
  2063. path: resolvedPath,
  2064. query,
  2065. body,
  2066. });
  2067. };
  2068. export const serializeAws_restJson1GetApiKeysCommand = async (
  2069. input: GetApiKeysCommandInput,
  2070. context: __SerdeContext
  2071. ): Promise<__HttpRequest> => {
  2072. const headers: any = {
  2073. "Content-Type": "application/json",
  2074. };
  2075. let resolvedPath = "/apikeys";
  2076. const query: any = {
  2077. ...(input.nameQuery !== undefined && { name: input.nameQuery }),
  2078. ...(input.position !== undefined && { position: input.position }),
  2079. ...(input.customerId !== undefined && { customerId: input.customerId }),
  2080. ...(input.includeValues !== undefined && { includeValues: input.includeValues.toString() }),
  2081. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2082. };
  2083. let body: any;
  2084. body = JSON.stringify({
  2085. ...(input.name !== undefined && { name: input.name }),
  2086. ...(input.template !== undefined && { template: input.template }),
  2087. ...(input.templateSkipList !== undefined && {
  2088. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2089. }),
  2090. ...(input.title !== undefined && { title: input.title }),
  2091. });
  2092. const { hostname, protocol = "https", port } = await context.endpoint();
  2093. return new __HttpRequest({
  2094. protocol,
  2095. hostname,
  2096. port,
  2097. method: "GET",
  2098. headers,
  2099. path: resolvedPath,
  2100. query,
  2101. body,
  2102. });
  2103. };
  2104. export const serializeAws_restJson1GetAuthorizerCommand = async (
  2105. input: GetAuthorizerCommandInput,
  2106. context: __SerdeContext
  2107. ): Promise<__HttpRequest> => {
  2108. const headers: any = {
  2109. "Content-Type": "application/json",
  2110. };
  2111. let resolvedPath = "/restapis/{restApiId}/authorizers/{authorizerId}";
  2112. if (input.authorizerId !== undefined) {
  2113. const labelValue: string = input.authorizerId;
  2114. if (labelValue.length <= 0) {
  2115. throw new Error("Empty value provided for input HTTP label: authorizerId.");
  2116. }
  2117. resolvedPath = resolvedPath.replace("{authorizerId}", __extendedEncodeURIComponent(labelValue));
  2118. } else {
  2119. throw new Error("No value provided for input HTTP label: authorizerId.");
  2120. }
  2121. if (input.restApiId !== undefined) {
  2122. const labelValue: string = input.restApiId;
  2123. if (labelValue.length <= 0) {
  2124. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2125. }
  2126. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2127. } else {
  2128. throw new Error("No value provided for input HTTP label: restApiId.");
  2129. }
  2130. let body: any;
  2131. body = JSON.stringify({
  2132. ...(input.name !== undefined && { name: input.name }),
  2133. ...(input.template !== undefined && { template: input.template }),
  2134. ...(input.templateSkipList !== undefined && {
  2135. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2136. }),
  2137. ...(input.title !== undefined && { title: input.title }),
  2138. });
  2139. const { hostname, protocol = "https", port } = await context.endpoint();
  2140. return new __HttpRequest({
  2141. protocol,
  2142. hostname,
  2143. port,
  2144. method: "GET",
  2145. headers,
  2146. path: resolvedPath,
  2147. body,
  2148. });
  2149. };
  2150. export const serializeAws_restJson1GetAuthorizersCommand = async (
  2151. input: GetAuthorizersCommandInput,
  2152. context: __SerdeContext
  2153. ): Promise<__HttpRequest> => {
  2154. const headers: any = {
  2155. "Content-Type": "application/json",
  2156. };
  2157. let resolvedPath = "/restapis/{restApiId}/authorizers";
  2158. if (input.restApiId !== undefined) {
  2159. const labelValue: string = input.restApiId;
  2160. if (labelValue.length <= 0) {
  2161. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2162. }
  2163. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2164. } else {
  2165. throw new Error("No value provided for input HTTP label: restApiId.");
  2166. }
  2167. const query: any = {
  2168. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2169. ...(input.position !== undefined && { position: input.position }),
  2170. };
  2171. let body: any;
  2172. body = JSON.stringify({
  2173. ...(input.name !== undefined && { name: input.name }),
  2174. ...(input.template !== undefined && { template: input.template }),
  2175. ...(input.templateSkipList !== undefined && {
  2176. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2177. }),
  2178. ...(input.title !== undefined && { title: input.title }),
  2179. });
  2180. const { hostname, protocol = "https", port } = await context.endpoint();
  2181. return new __HttpRequest({
  2182. protocol,
  2183. hostname,
  2184. port,
  2185. method: "GET",
  2186. headers,
  2187. path: resolvedPath,
  2188. query,
  2189. body,
  2190. });
  2191. };
  2192. export const serializeAws_restJson1GetBasePathMappingCommand = async (
  2193. input: GetBasePathMappingCommandInput,
  2194. context: __SerdeContext
  2195. ): Promise<__HttpRequest> => {
  2196. const headers: any = {
  2197. "Content-Type": "application/json",
  2198. };
  2199. let resolvedPath = "/domainnames/{domainName}/basepathmappings/{basePath}";
  2200. if (input.domainName !== undefined) {
  2201. const labelValue: string = input.domainName;
  2202. if (labelValue.length <= 0) {
  2203. throw new Error("Empty value provided for input HTTP label: domainName.");
  2204. }
  2205. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  2206. } else {
  2207. throw new Error("No value provided for input HTTP label: domainName.");
  2208. }
  2209. if (input.basePath !== undefined) {
  2210. const labelValue: string = input.basePath;
  2211. if (labelValue.length <= 0) {
  2212. throw new Error("Empty value provided for input HTTP label: basePath.");
  2213. }
  2214. resolvedPath = resolvedPath.replace("{basePath}", __extendedEncodeURIComponent(labelValue));
  2215. } else {
  2216. throw new Error("No value provided for input HTTP label: basePath.");
  2217. }
  2218. let body: any;
  2219. body = JSON.stringify({
  2220. ...(input.name !== undefined && { name: input.name }),
  2221. ...(input.template !== undefined && { template: input.template }),
  2222. ...(input.templateSkipList !== undefined && {
  2223. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2224. }),
  2225. ...(input.title !== undefined && { title: input.title }),
  2226. });
  2227. const { hostname, protocol = "https", port } = await context.endpoint();
  2228. return new __HttpRequest({
  2229. protocol,
  2230. hostname,
  2231. port,
  2232. method: "GET",
  2233. headers,
  2234. path: resolvedPath,
  2235. body,
  2236. });
  2237. };
  2238. export const serializeAws_restJson1GetBasePathMappingsCommand = async (
  2239. input: GetBasePathMappingsCommandInput,
  2240. context: __SerdeContext
  2241. ): Promise<__HttpRequest> => {
  2242. const headers: any = {
  2243. "Content-Type": "application/json",
  2244. };
  2245. let resolvedPath = "/domainnames/{domainName}/basepathmappings";
  2246. if (input.domainName !== undefined) {
  2247. const labelValue: string = input.domainName;
  2248. if (labelValue.length <= 0) {
  2249. throw new Error("Empty value provided for input HTTP label: domainName.");
  2250. }
  2251. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  2252. } else {
  2253. throw new Error("No value provided for input HTTP label: domainName.");
  2254. }
  2255. const query: any = {
  2256. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2257. ...(input.position !== undefined && { position: input.position }),
  2258. };
  2259. let body: any;
  2260. body = JSON.stringify({
  2261. ...(input.name !== undefined && { name: input.name }),
  2262. ...(input.template !== undefined && { template: input.template }),
  2263. ...(input.templateSkipList !== undefined && {
  2264. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2265. }),
  2266. ...(input.title !== undefined && { title: input.title }),
  2267. });
  2268. const { hostname, protocol = "https", port } = await context.endpoint();
  2269. return new __HttpRequest({
  2270. protocol,
  2271. hostname,
  2272. port,
  2273. method: "GET",
  2274. headers,
  2275. path: resolvedPath,
  2276. query,
  2277. body,
  2278. });
  2279. };
  2280. export const serializeAws_restJson1GetClientCertificateCommand = async (
  2281. input: GetClientCertificateCommandInput,
  2282. context: __SerdeContext
  2283. ): Promise<__HttpRequest> => {
  2284. const headers: any = {
  2285. "Content-Type": "application/json",
  2286. };
  2287. let resolvedPath = "/clientcertificates/{clientCertificateId}";
  2288. if (input.clientCertificateId !== undefined) {
  2289. const labelValue: string = input.clientCertificateId;
  2290. if (labelValue.length <= 0) {
  2291. throw new Error("Empty value provided for input HTTP label: clientCertificateId.");
  2292. }
  2293. resolvedPath = resolvedPath.replace("{clientCertificateId}", __extendedEncodeURIComponent(labelValue));
  2294. } else {
  2295. throw new Error("No value provided for input HTTP label: clientCertificateId.");
  2296. }
  2297. let body: any;
  2298. body = JSON.stringify({
  2299. ...(input.name !== undefined && { name: input.name }),
  2300. ...(input.template !== undefined && { template: input.template }),
  2301. ...(input.templateSkipList !== undefined && {
  2302. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2303. }),
  2304. ...(input.title !== undefined && { title: input.title }),
  2305. });
  2306. const { hostname, protocol = "https", port } = await context.endpoint();
  2307. return new __HttpRequest({
  2308. protocol,
  2309. hostname,
  2310. port,
  2311. method: "GET",
  2312. headers,
  2313. path: resolvedPath,
  2314. body,
  2315. });
  2316. };
  2317. export const serializeAws_restJson1GetClientCertificatesCommand = async (
  2318. input: GetClientCertificatesCommandInput,
  2319. context: __SerdeContext
  2320. ): Promise<__HttpRequest> => {
  2321. const headers: any = {
  2322. "Content-Type": "application/json",
  2323. };
  2324. let resolvedPath = "/clientcertificates";
  2325. const query: any = {
  2326. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2327. ...(input.position !== undefined && { position: input.position }),
  2328. };
  2329. let body: any;
  2330. body = JSON.stringify({
  2331. ...(input.name !== undefined && { name: input.name }),
  2332. ...(input.template !== undefined && { template: input.template }),
  2333. ...(input.templateSkipList !== undefined && {
  2334. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2335. }),
  2336. ...(input.title !== undefined && { title: input.title }),
  2337. });
  2338. const { hostname, protocol = "https", port } = await context.endpoint();
  2339. return new __HttpRequest({
  2340. protocol,
  2341. hostname,
  2342. port,
  2343. method: "GET",
  2344. headers,
  2345. path: resolvedPath,
  2346. query,
  2347. body,
  2348. });
  2349. };
  2350. export const serializeAws_restJson1GetDeploymentCommand = async (
  2351. input: GetDeploymentCommandInput,
  2352. context: __SerdeContext
  2353. ): Promise<__HttpRequest> => {
  2354. const headers: any = {
  2355. "Content-Type": "application/json",
  2356. };
  2357. let resolvedPath = "/restapis/{restApiId}/deployments/{deploymentId}";
  2358. if (input.restApiId !== undefined) {
  2359. const labelValue: string = input.restApiId;
  2360. if (labelValue.length <= 0) {
  2361. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2362. }
  2363. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2364. } else {
  2365. throw new Error("No value provided for input HTTP label: restApiId.");
  2366. }
  2367. if (input.deploymentId !== undefined) {
  2368. const labelValue: string = input.deploymentId;
  2369. if (labelValue.length <= 0) {
  2370. throw new Error("Empty value provided for input HTTP label: deploymentId.");
  2371. }
  2372. resolvedPath = resolvedPath.replace("{deploymentId}", __extendedEncodeURIComponent(labelValue));
  2373. } else {
  2374. throw new Error("No value provided for input HTTP label: deploymentId.");
  2375. }
  2376. const query: any = {
  2377. ...(input.embed !== undefined && { embed: (input.embed || []).map((_entry) => _entry) }),
  2378. };
  2379. let body: any;
  2380. body = JSON.stringify({
  2381. ...(input.name !== undefined && { name: input.name }),
  2382. ...(input.template !== undefined && { template: input.template }),
  2383. ...(input.templateSkipList !== undefined && {
  2384. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2385. }),
  2386. ...(input.title !== undefined && { title: input.title }),
  2387. });
  2388. const { hostname, protocol = "https", port } = await context.endpoint();
  2389. return new __HttpRequest({
  2390. protocol,
  2391. hostname,
  2392. port,
  2393. method: "GET",
  2394. headers,
  2395. path: resolvedPath,
  2396. query,
  2397. body,
  2398. });
  2399. };
  2400. export const serializeAws_restJson1GetDeploymentsCommand = async (
  2401. input: GetDeploymentsCommandInput,
  2402. context: __SerdeContext
  2403. ): Promise<__HttpRequest> => {
  2404. const headers: any = {
  2405. "Content-Type": "application/json",
  2406. };
  2407. let resolvedPath = "/restapis/{restApiId}/deployments";
  2408. if (input.restApiId !== undefined) {
  2409. const labelValue: string = input.restApiId;
  2410. if (labelValue.length <= 0) {
  2411. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2412. }
  2413. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2414. } else {
  2415. throw new Error("No value provided for input HTTP label: restApiId.");
  2416. }
  2417. const query: any = {
  2418. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2419. ...(input.position !== undefined && { position: input.position }),
  2420. };
  2421. let body: any;
  2422. body = JSON.stringify({
  2423. ...(input.name !== undefined && { name: input.name }),
  2424. ...(input.template !== undefined && { template: input.template }),
  2425. ...(input.templateSkipList !== undefined && {
  2426. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2427. }),
  2428. ...(input.title !== undefined && { title: input.title }),
  2429. });
  2430. const { hostname, protocol = "https", port } = await context.endpoint();
  2431. return new __HttpRequest({
  2432. protocol,
  2433. hostname,
  2434. port,
  2435. method: "GET",
  2436. headers,
  2437. path: resolvedPath,
  2438. query,
  2439. body,
  2440. });
  2441. };
  2442. export const serializeAws_restJson1GetDocumentationPartCommand = async (
  2443. input: GetDocumentationPartCommandInput,
  2444. context: __SerdeContext
  2445. ): Promise<__HttpRequest> => {
  2446. const headers: any = {
  2447. "Content-Type": "application/json",
  2448. };
  2449. let resolvedPath = "/restapis/{restApiId}/documentation/parts/{documentationPartId}";
  2450. if (input.documentationPartId !== undefined) {
  2451. const labelValue: string = input.documentationPartId;
  2452. if (labelValue.length <= 0) {
  2453. throw new Error("Empty value provided for input HTTP label: documentationPartId.");
  2454. }
  2455. resolvedPath = resolvedPath.replace("{documentationPartId}", __extendedEncodeURIComponent(labelValue));
  2456. } else {
  2457. throw new Error("No value provided for input HTTP label: documentationPartId.");
  2458. }
  2459. if (input.restApiId !== undefined) {
  2460. const labelValue: string = input.restApiId;
  2461. if (labelValue.length <= 0) {
  2462. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2463. }
  2464. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2465. } else {
  2466. throw new Error("No value provided for input HTTP label: restApiId.");
  2467. }
  2468. let body: any;
  2469. body = JSON.stringify({
  2470. ...(input.name !== undefined && { name: input.name }),
  2471. ...(input.template !== undefined && { template: input.template }),
  2472. ...(input.templateSkipList !== undefined && {
  2473. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2474. }),
  2475. ...(input.title !== undefined && { title: input.title }),
  2476. });
  2477. const { hostname, protocol = "https", port } = await context.endpoint();
  2478. return new __HttpRequest({
  2479. protocol,
  2480. hostname,
  2481. port,
  2482. method: "GET",
  2483. headers,
  2484. path: resolvedPath,
  2485. body,
  2486. });
  2487. };
  2488. export const serializeAws_restJson1GetDocumentationPartsCommand = async (
  2489. input: GetDocumentationPartsCommandInput,
  2490. context: __SerdeContext
  2491. ): Promise<__HttpRequest> => {
  2492. const headers: any = {
  2493. "Content-Type": "application/json",
  2494. };
  2495. let resolvedPath = "/restapis/{restApiId}/documentation/parts";
  2496. if (input.restApiId !== undefined) {
  2497. const labelValue: string = input.restApiId;
  2498. if (labelValue.length <= 0) {
  2499. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2500. }
  2501. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2502. } else {
  2503. throw new Error("No value provided for input HTTP label: restApiId.");
  2504. }
  2505. const query: any = {
  2506. ...(input.type !== undefined && { type: input.type }),
  2507. ...(input.nameQuery !== undefined && { name: input.nameQuery }),
  2508. ...(input.position !== undefined && { position: input.position }),
  2509. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2510. ...(input.locationStatus !== undefined && { locationStatus: input.locationStatus }),
  2511. ...(input.path !== undefined && { path: input.path }),
  2512. };
  2513. let body: any;
  2514. body = JSON.stringify({
  2515. ...(input.name !== undefined && { name: input.name }),
  2516. ...(input.template !== undefined && { template: input.template }),
  2517. ...(input.templateSkipList !== undefined && {
  2518. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2519. }),
  2520. ...(input.title !== undefined && { title: input.title }),
  2521. });
  2522. const { hostname, protocol = "https", port } = await context.endpoint();
  2523. return new __HttpRequest({
  2524. protocol,
  2525. hostname,
  2526. port,
  2527. method: "GET",
  2528. headers,
  2529. path: resolvedPath,
  2530. query,
  2531. body,
  2532. });
  2533. };
  2534. export const serializeAws_restJson1GetDocumentationVersionCommand = async (
  2535. input: GetDocumentationVersionCommandInput,
  2536. context: __SerdeContext
  2537. ): Promise<__HttpRequest> => {
  2538. const headers: any = {
  2539. "Content-Type": "application/json",
  2540. };
  2541. let resolvedPath = "/restapis/{restApiId}/documentation/versions/{documentationVersion}";
  2542. if (input.restApiId !== undefined) {
  2543. const labelValue: string = input.restApiId;
  2544. if (labelValue.length <= 0) {
  2545. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2546. }
  2547. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2548. } else {
  2549. throw new Error("No value provided for input HTTP label: restApiId.");
  2550. }
  2551. if (input.documentationVersion !== undefined) {
  2552. const labelValue: string = input.documentationVersion;
  2553. if (labelValue.length <= 0) {
  2554. throw new Error("Empty value provided for input HTTP label: documentationVersion.");
  2555. }
  2556. resolvedPath = resolvedPath.replace("{documentationVersion}", __extendedEncodeURIComponent(labelValue));
  2557. } else {
  2558. throw new Error("No value provided for input HTTP label: documentationVersion.");
  2559. }
  2560. let body: any;
  2561. body = JSON.stringify({
  2562. ...(input.name !== undefined && { name: input.name }),
  2563. ...(input.template !== undefined && { template: input.template }),
  2564. ...(input.templateSkipList !== undefined && {
  2565. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2566. }),
  2567. ...(input.title !== undefined && { title: input.title }),
  2568. });
  2569. const { hostname, protocol = "https", port } = await context.endpoint();
  2570. return new __HttpRequest({
  2571. protocol,
  2572. hostname,
  2573. port,
  2574. method: "GET",
  2575. headers,
  2576. path: resolvedPath,
  2577. body,
  2578. });
  2579. };
  2580. export const serializeAws_restJson1GetDocumentationVersionsCommand = async (
  2581. input: GetDocumentationVersionsCommandInput,
  2582. context: __SerdeContext
  2583. ): Promise<__HttpRequest> => {
  2584. const headers: any = {
  2585. "Content-Type": "application/json",
  2586. };
  2587. let resolvedPath = "/restapis/{restApiId}/documentation/versions";
  2588. if (input.restApiId !== undefined) {
  2589. const labelValue: string = input.restApiId;
  2590. if (labelValue.length <= 0) {
  2591. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2592. }
  2593. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2594. } else {
  2595. throw new Error("No value provided for input HTTP label: restApiId.");
  2596. }
  2597. const query: any = {
  2598. ...(input.position !== undefined && { position: input.position }),
  2599. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2600. };
  2601. let body: any;
  2602. body = JSON.stringify({
  2603. ...(input.name !== undefined && { name: input.name }),
  2604. ...(input.template !== undefined && { template: input.template }),
  2605. ...(input.templateSkipList !== undefined && {
  2606. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2607. }),
  2608. ...(input.title !== undefined && { title: input.title }),
  2609. });
  2610. const { hostname, protocol = "https", port } = await context.endpoint();
  2611. return new __HttpRequest({
  2612. protocol,
  2613. hostname,
  2614. port,
  2615. method: "GET",
  2616. headers,
  2617. path: resolvedPath,
  2618. query,
  2619. body,
  2620. });
  2621. };
  2622. export const serializeAws_restJson1GetDomainNameCommand = async (
  2623. input: GetDomainNameCommandInput,
  2624. context: __SerdeContext
  2625. ): Promise<__HttpRequest> => {
  2626. const headers: any = {
  2627. "Content-Type": "application/json",
  2628. };
  2629. let resolvedPath = "/domainnames/{domainName}";
  2630. if (input.domainName !== undefined) {
  2631. const labelValue: string = input.domainName;
  2632. if (labelValue.length <= 0) {
  2633. throw new Error("Empty value provided for input HTTP label: domainName.");
  2634. }
  2635. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  2636. } else {
  2637. throw new Error("No value provided for input HTTP label: domainName.");
  2638. }
  2639. let body: any;
  2640. body = JSON.stringify({
  2641. ...(input.name !== undefined && { name: input.name }),
  2642. ...(input.template !== undefined && { template: input.template }),
  2643. ...(input.templateSkipList !== undefined && {
  2644. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2645. }),
  2646. ...(input.title !== undefined && { title: input.title }),
  2647. });
  2648. const { hostname, protocol = "https", port } = await context.endpoint();
  2649. return new __HttpRequest({
  2650. protocol,
  2651. hostname,
  2652. port,
  2653. method: "GET",
  2654. headers,
  2655. path: resolvedPath,
  2656. body,
  2657. });
  2658. };
  2659. export const serializeAws_restJson1GetDomainNamesCommand = async (
  2660. input: GetDomainNamesCommandInput,
  2661. context: __SerdeContext
  2662. ): Promise<__HttpRequest> => {
  2663. const headers: any = {
  2664. "Content-Type": "application/json",
  2665. };
  2666. let resolvedPath = "/domainnames";
  2667. const query: any = {
  2668. ...(input.position !== undefined && { position: input.position }),
  2669. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2670. };
  2671. let body: any;
  2672. body = JSON.stringify({
  2673. ...(input.name !== undefined && { name: input.name }),
  2674. ...(input.template !== undefined && { template: input.template }),
  2675. ...(input.templateSkipList !== undefined && {
  2676. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2677. }),
  2678. ...(input.title !== undefined && { title: input.title }),
  2679. });
  2680. const { hostname, protocol = "https", port } = await context.endpoint();
  2681. return new __HttpRequest({
  2682. protocol,
  2683. hostname,
  2684. port,
  2685. method: "GET",
  2686. headers,
  2687. path: resolvedPath,
  2688. query,
  2689. body,
  2690. });
  2691. };
  2692. export const serializeAws_restJson1GetExportCommand = async (
  2693. input: GetExportCommandInput,
  2694. context: __SerdeContext
  2695. ): Promise<__HttpRequest> => {
  2696. const headers: any = {
  2697. "Content-Type": "application/json",
  2698. ...(isSerializableHeaderValue(input.accepts) && { Accept: input.accepts! }),
  2699. };
  2700. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}/exports/{exportType}";
  2701. if (input.restApiId !== undefined) {
  2702. const labelValue: string = input.restApiId;
  2703. if (labelValue.length <= 0) {
  2704. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2705. }
  2706. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2707. } else {
  2708. throw new Error("No value provided for input HTTP label: restApiId.");
  2709. }
  2710. if (input.exportType !== undefined) {
  2711. const labelValue: string = input.exportType;
  2712. if (labelValue.length <= 0) {
  2713. throw new Error("Empty value provided for input HTTP label: exportType.");
  2714. }
  2715. resolvedPath = resolvedPath.replace("{exportType}", __extendedEncodeURIComponent(labelValue));
  2716. } else {
  2717. throw new Error("No value provided for input HTTP label: exportType.");
  2718. }
  2719. if (input.stageName !== undefined) {
  2720. const labelValue: string = input.stageName;
  2721. if (labelValue.length <= 0) {
  2722. throw new Error("Empty value provided for input HTTP label: stageName.");
  2723. }
  2724. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  2725. } else {
  2726. throw new Error("No value provided for input HTTP label: stageName.");
  2727. }
  2728. let body: any;
  2729. body = JSON.stringify({
  2730. ...(input.parameters !== undefined && {
  2731. parameters: serializeAws_restJson1MapOfStringToString(input.parameters, context),
  2732. }),
  2733. });
  2734. const { hostname, protocol = "https", port } = await context.endpoint();
  2735. return new __HttpRequest({
  2736. protocol,
  2737. hostname,
  2738. port,
  2739. method: "GET",
  2740. headers,
  2741. path: resolvedPath,
  2742. body,
  2743. });
  2744. };
  2745. export const serializeAws_restJson1GetGatewayResponseCommand = async (
  2746. input: GetGatewayResponseCommandInput,
  2747. context: __SerdeContext
  2748. ): Promise<__HttpRequest> => {
  2749. const headers: any = {
  2750. "Content-Type": "application/json",
  2751. };
  2752. let resolvedPath = "/restapis/{restApiId}/gatewayresponses/{responseType}";
  2753. if (input.responseType !== undefined) {
  2754. const labelValue: string = input.responseType;
  2755. if (labelValue.length <= 0) {
  2756. throw new Error("Empty value provided for input HTTP label: responseType.");
  2757. }
  2758. resolvedPath = resolvedPath.replace("{responseType}", __extendedEncodeURIComponent(labelValue));
  2759. } else {
  2760. throw new Error("No value provided for input HTTP label: responseType.");
  2761. }
  2762. if (input.restApiId !== undefined) {
  2763. const labelValue: string = input.restApiId;
  2764. if (labelValue.length <= 0) {
  2765. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2766. }
  2767. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2768. } else {
  2769. throw new Error("No value provided for input HTTP label: restApiId.");
  2770. }
  2771. let body: any;
  2772. body = JSON.stringify({
  2773. ...(input.name !== undefined && { name: input.name }),
  2774. ...(input.template !== undefined && { template: input.template }),
  2775. ...(input.templateSkipList !== undefined && {
  2776. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2777. }),
  2778. ...(input.title !== undefined && { title: input.title }),
  2779. });
  2780. const { hostname, protocol = "https", port } = await context.endpoint();
  2781. return new __HttpRequest({
  2782. protocol,
  2783. hostname,
  2784. port,
  2785. method: "GET",
  2786. headers,
  2787. path: resolvedPath,
  2788. body,
  2789. });
  2790. };
  2791. export const serializeAws_restJson1GetGatewayResponsesCommand = async (
  2792. input: GetGatewayResponsesCommandInput,
  2793. context: __SerdeContext
  2794. ): Promise<__HttpRequest> => {
  2795. const headers: any = {
  2796. "Content-Type": "application/json",
  2797. };
  2798. let resolvedPath = "/restapis/{restApiId}/gatewayresponses";
  2799. if (input.restApiId !== undefined) {
  2800. const labelValue: string = input.restApiId;
  2801. if (labelValue.length <= 0) {
  2802. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2803. }
  2804. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2805. } else {
  2806. throw new Error("No value provided for input HTTP label: restApiId.");
  2807. }
  2808. const query: any = {
  2809. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  2810. ...(input.position !== undefined && { position: input.position }),
  2811. };
  2812. let body: any;
  2813. body = JSON.stringify({
  2814. ...(input.name !== undefined && { name: input.name }),
  2815. ...(input.template !== undefined && { template: input.template }),
  2816. ...(input.templateSkipList !== undefined && {
  2817. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2818. }),
  2819. ...(input.title !== undefined && { title: input.title }),
  2820. });
  2821. const { hostname, protocol = "https", port } = await context.endpoint();
  2822. return new __HttpRequest({
  2823. protocol,
  2824. hostname,
  2825. port,
  2826. method: "GET",
  2827. headers,
  2828. path: resolvedPath,
  2829. query,
  2830. body,
  2831. });
  2832. };
  2833. export const serializeAws_restJson1GetIntegrationCommand = async (
  2834. input: GetIntegrationCommandInput,
  2835. context: __SerdeContext
  2836. ): Promise<__HttpRequest> => {
  2837. const headers: any = {
  2838. "Content-Type": "application/json",
  2839. };
  2840. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration";
  2841. if (input.restApiId !== undefined) {
  2842. const labelValue: string = input.restApiId;
  2843. if (labelValue.length <= 0) {
  2844. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2845. }
  2846. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2847. } else {
  2848. throw new Error("No value provided for input HTTP label: restApiId.");
  2849. }
  2850. if (input.httpMethod !== undefined) {
  2851. const labelValue: string = input.httpMethod;
  2852. if (labelValue.length <= 0) {
  2853. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  2854. }
  2855. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  2856. } else {
  2857. throw new Error("No value provided for input HTTP label: httpMethod.");
  2858. }
  2859. if (input.resourceId !== undefined) {
  2860. const labelValue: string = input.resourceId;
  2861. if (labelValue.length <= 0) {
  2862. throw new Error("Empty value provided for input HTTP label: resourceId.");
  2863. }
  2864. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  2865. } else {
  2866. throw new Error("No value provided for input HTTP label: resourceId.");
  2867. }
  2868. let body: any;
  2869. body = JSON.stringify({
  2870. ...(input.name !== undefined && { name: input.name }),
  2871. ...(input.template !== undefined && { template: input.template }),
  2872. ...(input.templateSkipList !== undefined && {
  2873. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2874. }),
  2875. ...(input.title !== undefined && { title: input.title }),
  2876. });
  2877. const { hostname, protocol = "https", port } = await context.endpoint();
  2878. return new __HttpRequest({
  2879. protocol,
  2880. hostname,
  2881. port,
  2882. method: "GET",
  2883. headers,
  2884. path: resolvedPath,
  2885. body,
  2886. });
  2887. };
  2888. export const serializeAws_restJson1GetIntegrationResponseCommand = async (
  2889. input: GetIntegrationResponseCommandInput,
  2890. context: __SerdeContext
  2891. ): Promise<__HttpRequest> => {
  2892. const headers: any = {
  2893. "Content-Type": "application/json",
  2894. };
  2895. let resolvedPath =
  2896. "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration/responses/{statusCode}";
  2897. if (input.statusCode !== undefined) {
  2898. const labelValue: string = input.statusCode;
  2899. if (labelValue.length <= 0) {
  2900. throw new Error("Empty value provided for input HTTP label: statusCode.");
  2901. }
  2902. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  2903. } else {
  2904. throw new Error("No value provided for input HTTP label: statusCode.");
  2905. }
  2906. if (input.resourceId !== undefined) {
  2907. const labelValue: string = input.resourceId;
  2908. if (labelValue.length <= 0) {
  2909. throw new Error("Empty value provided for input HTTP label: resourceId.");
  2910. }
  2911. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  2912. } else {
  2913. throw new Error("No value provided for input HTTP label: resourceId.");
  2914. }
  2915. if (input.restApiId !== undefined) {
  2916. const labelValue: string = input.restApiId;
  2917. if (labelValue.length <= 0) {
  2918. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2919. }
  2920. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2921. } else {
  2922. throw new Error("No value provided for input HTTP label: restApiId.");
  2923. }
  2924. if (input.httpMethod !== undefined) {
  2925. const labelValue: string = input.httpMethod;
  2926. if (labelValue.length <= 0) {
  2927. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  2928. }
  2929. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  2930. } else {
  2931. throw new Error("No value provided for input HTTP label: httpMethod.");
  2932. }
  2933. let body: any;
  2934. body = JSON.stringify({
  2935. ...(input.name !== undefined && { name: input.name }),
  2936. ...(input.template !== undefined && { template: input.template }),
  2937. ...(input.templateSkipList !== undefined && {
  2938. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2939. }),
  2940. ...(input.title !== undefined && { title: input.title }),
  2941. });
  2942. const { hostname, protocol = "https", port } = await context.endpoint();
  2943. return new __HttpRequest({
  2944. protocol,
  2945. hostname,
  2946. port,
  2947. method: "GET",
  2948. headers,
  2949. path: resolvedPath,
  2950. body,
  2951. });
  2952. };
  2953. export const serializeAws_restJson1GetMethodCommand = async (
  2954. input: GetMethodCommandInput,
  2955. context: __SerdeContext
  2956. ): Promise<__HttpRequest> => {
  2957. const headers: any = {
  2958. "Content-Type": "application/json",
  2959. };
  2960. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}";
  2961. if (input.resourceId !== undefined) {
  2962. const labelValue: string = input.resourceId;
  2963. if (labelValue.length <= 0) {
  2964. throw new Error("Empty value provided for input HTTP label: resourceId.");
  2965. }
  2966. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  2967. } else {
  2968. throw new Error("No value provided for input HTTP label: resourceId.");
  2969. }
  2970. if (input.restApiId !== undefined) {
  2971. const labelValue: string = input.restApiId;
  2972. if (labelValue.length <= 0) {
  2973. throw new Error("Empty value provided for input HTTP label: restApiId.");
  2974. }
  2975. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  2976. } else {
  2977. throw new Error("No value provided for input HTTP label: restApiId.");
  2978. }
  2979. if (input.httpMethod !== undefined) {
  2980. const labelValue: string = input.httpMethod;
  2981. if (labelValue.length <= 0) {
  2982. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  2983. }
  2984. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  2985. } else {
  2986. throw new Error("No value provided for input HTTP label: httpMethod.");
  2987. }
  2988. let body: any;
  2989. body = JSON.stringify({
  2990. ...(input.name !== undefined && { name: input.name }),
  2991. ...(input.template !== undefined && { template: input.template }),
  2992. ...(input.templateSkipList !== undefined && {
  2993. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  2994. }),
  2995. ...(input.title !== undefined && { title: input.title }),
  2996. });
  2997. const { hostname, protocol = "https", port } = await context.endpoint();
  2998. return new __HttpRequest({
  2999. protocol,
  3000. hostname,
  3001. port,
  3002. method: "GET",
  3003. headers,
  3004. path: resolvedPath,
  3005. body,
  3006. });
  3007. };
  3008. export const serializeAws_restJson1GetMethodResponseCommand = async (
  3009. input: GetMethodResponseCommandInput,
  3010. context: __SerdeContext
  3011. ): Promise<__HttpRequest> => {
  3012. const headers: any = {
  3013. "Content-Type": "application/json",
  3014. };
  3015. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/responses/{statusCode}";
  3016. if (input.resourceId !== undefined) {
  3017. const labelValue: string = input.resourceId;
  3018. if (labelValue.length <= 0) {
  3019. throw new Error("Empty value provided for input HTTP label: resourceId.");
  3020. }
  3021. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  3022. } else {
  3023. throw new Error("No value provided for input HTTP label: resourceId.");
  3024. }
  3025. if (input.statusCode !== undefined) {
  3026. const labelValue: string = input.statusCode;
  3027. if (labelValue.length <= 0) {
  3028. throw new Error("Empty value provided for input HTTP label: statusCode.");
  3029. }
  3030. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  3031. } else {
  3032. throw new Error("No value provided for input HTTP label: statusCode.");
  3033. }
  3034. if (input.httpMethod !== undefined) {
  3035. const labelValue: string = input.httpMethod;
  3036. if (labelValue.length <= 0) {
  3037. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  3038. }
  3039. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  3040. } else {
  3041. throw new Error("No value provided for input HTTP label: httpMethod.");
  3042. }
  3043. if (input.restApiId !== undefined) {
  3044. const labelValue: string = input.restApiId;
  3045. if (labelValue.length <= 0) {
  3046. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3047. }
  3048. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3049. } else {
  3050. throw new Error("No value provided for input HTTP label: restApiId.");
  3051. }
  3052. let body: any;
  3053. body = JSON.stringify({
  3054. ...(input.name !== undefined && { name: input.name }),
  3055. ...(input.template !== undefined && { template: input.template }),
  3056. ...(input.templateSkipList !== undefined && {
  3057. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3058. }),
  3059. ...(input.title !== undefined && { title: input.title }),
  3060. });
  3061. const { hostname, protocol = "https", port } = await context.endpoint();
  3062. return new __HttpRequest({
  3063. protocol,
  3064. hostname,
  3065. port,
  3066. method: "GET",
  3067. headers,
  3068. path: resolvedPath,
  3069. body,
  3070. });
  3071. };
  3072. export const serializeAws_restJson1GetModelCommand = async (
  3073. input: GetModelCommandInput,
  3074. context: __SerdeContext
  3075. ): Promise<__HttpRequest> => {
  3076. const headers: any = {
  3077. "Content-Type": "application/json",
  3078. };
  3079. let resolvedPath = "/restapis/{restApiId}/models/{modelName}";
  3080. if (input.restApiId !== undefined) {
  3081. const labelValue: string = input.restApiId;
  3082. if (labelValue.length <= 0) {
  3083. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3084. }
  3085. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3086. } else {
  3087. throw new Error("No value provided for input HTTP label: restApiId.");
  3088. }
  3089. if (input.modelName !== undefined) {
  3090. const labelValue: string = input.modelName;
  3091. if (labelValue.length <= 0) {
  3092. throw new Error("Empty value provided for input HTTP label: modelName.");
  3093. }
  3094. resolvedPath = resolvedPath.replace("{modelName}", __extendedEncodeURIComponent(labelValue));
  3095. } else {
  3096. throw new Error("No value provided for input HTTP label: modelName.");
  3097. }
  3098. const query: any = {
  3099. ...(input.flatten !== undefined && { flatten: input.flatten.toString() }),
  3100. };
  3101. let body: any;
  3102. body = JSON.stringify({
  3103. ...(input.name !== undefined && { name: input.name }),
  3104. ...(input.template !== undefined && { template: input.template }),
  3105. ...(input.templateSkipList !== undefined && {
  3106. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3107. }),
  3108. ...(input.title !== undefined && { title: input.title }),
  3109. });
  3110. const { hostname, protocol = "https", port } = await context.endpoint();
  3111. return new __HttpRequest({
  3112. protocol,
  3113. hostname,
  3114. port,
  3115. method: "GET",
  3116. headers,
  3117. path: resolvedPath,
  3118. query,
  3119. body,
  3120. });
  3121. };
  3122. export const serializeAws_restJson1GetModelsCommand = async (
  3123. input: GetModelsCommandInput,
  3124. context: __SerdeContext
  3125. ): Promise<__HttpRequest> => {
  3126. const headers: any = {
  3127. "Content-Type": "application/json",
  3128. };
  3129. let resolvedPath = "/restapis/{restApiId}/models";
  3130. if (input.restApiId !== undefined) {
  3131. const labelValue: string = input.restApiId;
  3132. if (labelValue.length <= 0) {
  3133. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3134. }
  3135. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3136. } else {
  3137. throw new Error("No value provided for input HTTP label: restApiId.");
  3138. }
  3139. const query: any = {
  3140. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3141. ...(input.position !== undefined && { position: input.position }),
  3142. };
  3143. let body: any;
  3144. body = JSON.stringify({
  3145. ...(input.name !== undefined && { name: input.name }),
  3146. ...(input.template !== undefined && { template: input.template }),
  3147. ...(input.templateSkipList !== undefined && {
  3148. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3149. }),
  3150. ...(input.title !== undefined && { title: input.title }),
  3151. });
  3152. const { hostname, protocol = "https", port } = await context.endpoint();
  3153. return new __HttpRequest({
  3154. protocol,
  3155. hostname,
  3156. port,
  3157. method: "GET",
  3158. headers,
  3159. path: resolvedPath,
  3160. query,
  3161. body,
  3162. });
  3163. };
  3164. export const serializeAws_restJson1GetModelTemplateCommand = async (
  3165. input: GetModelTemplateCommandInput,
  3166. context: __SerdeContext
  3167. ): Promise<__HttpRequest> => {
  3168. const headers: any = {
  3169. "Content-Type": "application/json",
  3170. };
  3171. let resolvedPath = "/restapis/{restApiId}/models/{modelName}/default_template";
  3172. if (input.modelName !== undefined) {
  3173. const labelValue: string = input.modelName;
  3174. if (labelValue.length <= 0) {
  3175. throw new Error("Empty value provided for input HTTP label: modelName.");
  3176. }
  3177. resolvedPath = resolvedPath.replace("{modelName}", __extendedEncodeURIComponent(labelValue));
  3178. } else {
  3179. throw new Error("No value provided for input HTTP label: modelName.");
  3180. }
  3181. if (input.restApiId !== undefined) {
  3182. const labelValue: string = input.restApiId;
  3183. if (labelValue.length <= 0) {
  3184. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3185. }
  3186. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3187. } else {
  3188. throw new Error("No value provided for input HTTP label: restApiId.");
  3189. }
  3190. let body: any;
  3191. body = JSON.stringify({
  3192. ...(input.name !== undefined && { name: input.name }),
  3193. ...(input.template !== undefined && { template: input.template }),
  3194. ...(input.templateSkipList !== undefined && {
  3195. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3196. }),
  3197. ...(input.title !== undefined && { title: input.title }),
  3198. });
  3199. const { hostname, protocol = "https", port } = await context.endpoint();
  3200. return new __HttpRequest({
  3201. protocol,
  3202. hostname,
  3203. port,
  3204. method: "GET",
  3205. headers,
  3206. path: resolvedPath,
  3207. body,
  3208. });
  3209. };
  3210. export const serializeAws_restJson1GetRequestValidatorCommand = async (
  3211. input: GetRequestValidatorCommandInput,
  3212. context: __SerdeContext
  3213. ): Promise<__HttpRequest> => {
  3214. const headers: any = {
  3215. "Content-Type": "application/json",
  3216. };
  3217. let resolvedPath = "/restapis/{restApiId}/requestvalidators/{requestValidatorId}";
  3218. if (input.requestValidatorId !== undefined) {
  3219. const labelValue: string = input.requestValidatorId;
  3220. if (labelValue.length <= 0) {
  3221. throw new Error("Empty value provided for input HTTP label: requestValidatorId.");
  3222. }
  3223. resolvedPath = resolvedPath.replace("{requestValidatorId}", __extendedEncodeURIComponent(labelValue));
  3224. } else {
  3225. throw new Error("No value provided for input HTTP label: requestValidatorId.");
  3226. }
  3227. if (input.restApiId !== undefined) {
  3228. const labelValue: string = input.restApiId;
  3229. if (labelValue.length <= 0) {
  3230. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3231. }
  3232. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3233. } else {
  3234. throw new Error("No value provided for input HTTP label: restApiId.");
  3235. }
  3236. let body: any;
  3237. body = JSON.stringify({
  3238. ...(input.name !== undefined && { name: input.name }),
  3239. ...(input.template !== undefined && { template: input.template }),
  3240. ...(input.templateSkipList !== undefined && {
  3241. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3242. }),
  3243. ...(input.title !== undefined && { title: input.title }),
  3244. });
  3245. const { hostname, protocol = "https", port } = await context.endpoint();
  3246. return new __HttpRequest({
  3247. protocol,
  3248. hostname,
  3249. port,
  3250. method: "GET",
  3251. headers,
  3252. path: resolvedPath,
  3253. body,
  3254. });
  3255. };
  3256. export const serializeAws_restJson1GetRequestValidatorsCommand = async (
  3257. input: GetRequestValidatorsCommandInput,
  3258. context: __SerdeContext
  3259. ): Promise<__HttpRequest> => {
  3260. const headers: any = {
  3261. "Content-Type": "application/json",
  3262. };
  3263. let resolvedPath = "/restapis/{restApiId}/requestvalidators";
  3264. if (input.restApiId !== undefined) {
  3265. const labelValue: string = input.restApiId;
  3266. if (labelValue.length <= 0) {
  3267. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3268. }
  3269. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3270. } else {
  3271. throw new Error("No value provided for input HTTP label: restApiId.");
  3272. }
  3273. const query: any = {
  3274. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3275. ...(input.position !== undefined && { position: input.position }),
  3276. };
  3277. let body: any;
  3278. body = JSON.stringify({
  3279. ...(input.name !== undefined && { name: input.name }),
  3280. ...(input.template !== undefined && { template: input.template }),
  3281. ...(input.templateSkipList !== undefined && {
  3282. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3283. }),
  3284. ...(input.title !== undefined && { title: input.title }),
  3285. });
  3286. const { hostname, protocol = "https", port } = await context.endpoint();
  3287. return new __HttpRequest({
  3288. protocol,
  3289. hostname,
  3290. port,
  3291. method: "GET",
  3292. headers,
  3293. path: resolvedPath,
  3294. query,
  3295. body,
  3296. });
  3297. };
  3298. export const serializeAws_restJson1GetResourceCommand = async (
  3299. input: GetResourceCommandInput,
  3300. context: __SerdeContext
  3301. ): Promise<__HttpRequest> => {
  3302. const headers: any = {
  3303. "Content-Type": "application/json",
  3304. };
  3305. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}";
  3306. if (input.restApiId !== undefined) {
  3307. const labelValue: string = input.restApiId;
  3308. if (labelValue.length <= 0) {
  3309. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3310. }
  3311. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3312. } else {
  3313. throw new Error("No value provided for input HTTP label: restApiId.");
  3314. }
  3315. if (input.resourceId !== undefined) {
  3316. const labelValue: string = input.resourceId;
  3317. if (labelValue.length <= 0) {
  3318. throw new Error("Empty value provided for input HTTP label: resourceId.");
  3319. }
  3320. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  3321. } else {
  3322. throw new Error("No value provided for input HTTP label: resourceId.");
  3323. }
  3324. const query: any = {
  3325. ...(input.embed !== undefined && { embed: (input.embed || []).map((_entry) => _entry) }),
  3326. };
  3327. let body: any;
  3328. body = JSON.stringify({
  3329. ...(input.name !== undefined && { name: input.name }),
  3330. ...(input.template !== undefined && { template: input.template }),
  3331. ...(input.templateSkipList !== undefined && {
  3332. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3333. }),
  3334. ...(input.title !== undefined && { title: input.title }),
  3335. });
  3336. const { hostname, protocol = "https", port } = await context.endpoint();
  3337. return new __HttpRequest({
  3338. protocol,
  3339. hostname,
  3340. port,
  3341. method: "GET",
  3342. headers,
  3343. path: resolvedPath,
  3344. query,
  3345. body,
  3346. });
  3347. };
  3348. export const serializeAws_restJson1GetResourcesCommand = async (
  3349. input: GetResourcesCommandInput,
  3350. context: __SerdeContext
  3351. ): Promise<__HttpRequest> => {
  3352. const headers: any = {
  3353. "Content-Type": "application/json",
  3354. };
  3355. let resolvedPath = "/restapis/{restApiId}/resources";
  3356. if (input.restApiId !== undefined) {
  3357. const labelValue: string = input.restApiId;
  3358. if (labelValue.length <= 0) {
  3359. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3360. }
  3361. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3362. } else {
  3363. throw new Error("No value provided for input HTTP label: restApiId.");
  3364. }
  3365. const query: any = {
  3366. ...(input.embed !== undefined && { embed: (input.embed || []).map((_entry) => _entry) }),
  3367. ...(input.position !== undefined && { position: input.position }),
  3368. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3369. };
  3370. let body: any;
  3371. body = JSON.stringify({
  3372. ...(input.name !== undefined && { name: input.name }),
  3373. ...(input.template !== undefined && { template: input.template }),
  3374. ...(input.templateSkipList !== undefined && {
  3375. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3376. }),
  3377. ...(input.title !== undefined && { title: input.title }),
  3378. });
  3379. const { hostname, protocol = "https", port } = await context.endpoint();
  3380. return new __HttpRequest({
  3381. protocol,
  3382. hostname,
  3383. port,
  3384. method: "GET",
  3385. headers,
  3386. path: resolvedPath,
  3387. query,
  3388. body,
  3389. });
  3390. };
  3391. export const serializeAws_restJson1GetRestApiCommand = async (
  3392. input: GetRestApiCommandInput,
  3393. context: __SerdeContext
  3394. ): Promise<__HttpRequest> => {
  3395. const headers: any = {
  3396. "Content-Type": "application/json",
  3397. };
  3398. let resolvedPath = "/restapis/{restApiId}";
  3399. if (input.restApiId !== undefined) {
  3400. const labelValue: string = input.restApiId;
  3401. if (labelValue.length <= 0) {
  3402. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3403. }
  3404. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3405. } else {
  3406. throw new Error("No value provided for input HTTP label: restApiId.");
  3407. }
  3408. let body: any;
  3409. body = JSON.stringify({
  3410. ...(input.name !== undefined && { name: input.name }),
  3411. ...(input.template !== undefined && { template: input.template }),
  3412. ...(input.templateSkipList !== undefined && {
  3413. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3414. }),
  3415. ...(input.title !== undefined && { title: input.title }),
  3416. });
  3417. const { hostname, protocol = "https", port } = await context.endpoint();
  3418. return new __HttpRequest({
  3419. protocol,
  3420. hostname,
  3421. port,
  3422. method: "GET",
  3423. headers,
  3424. path: resolvedPath,
  3425. body,
  3426. });
  3427. };
  3428. export const serializeAws_restJson1GetRestApisCommand = async (
  3429. input: GetRestApisCommandInput,
  3430. context: __SerdeContext
  3431. ): Promise<__HttpRequest> => {
  3432. const headers: any = {
  3433. "Content-Type": "application/json",
  3434. };
  3435. let resolvedPath = "/restapis";
  3436. const query: any = {
  3437. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3438. ...(input.position !== undefined && { position: input.position }),
  3439. };
  3440. let body: any;
  3441. body = JSON.stringify({
  3442. ...(input.name !== undefined && { name: input.name }),
  3443. ...(input.template !== undefined && { template: input.template }),
  3444. ...(input.templateSkipList !== undefined && {
  3445. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3446. }),
  3447. ...(input.title !== undefined && { title: input.title }),
  3448. });
  3449. const { hostname, protocol = "https", port } = await context.endpoint();
  3450. return new __HttpRequest({
  3451. protocol,
  3452. hostname,
  3453. port,
  3454. method: "GET",
  3455. headers,
  3456. path: resolvedPath,
  3457. query,
  3458. body,
  3459. });
  3460. };
  3461. export const serializeAws_restJson1GetSdkCommand = async (
  3462. input: GetSdkCommandInput,
  3463. context: __SerdeContext
  3464. ): Promise<__HttpRequest> => {
  3465. const headers: any = {
  3466. "Content-Type": "application/json",
  3467. };
  3468. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}/sdks/{sdkType}";
  3469. if (input.restApiId !== undefined) {
  3470. const labelValue: string = input.restApiId;
  3471. if (labelValue.length <= 0) {
  3472. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3473. }
  3474. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3475. } else {
  3476. throw new Error("No value provided for input HTTP label: restApiId.");
  3477. }
  3478. if (input.sdkType !== undefined) {
  3479. const labelValue: string = input.sdkType;
  3480. if (labelValue.length <= 0) {
  3481. throw new Error("Empty value provided for input HTTP label: sdkType.");
  3482. }
  3483. resolvedPath = resolvedPath.replace("{sdkType}", __extendedEncodeURIComponent(labelValue));
  3484. } else {
  3485. throw new Error("No value provided for input HTTP label: sdkType.");
  3486. }
  3487. if (input.stageName !== undefined) {
  3488. const labelValue: string = input.stageName;
  3489. if (labelValue.length <= 0) {
  3490. throw new Error("Empty value provided for input HTTP label: stageName.");
  3491. }
  3492. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  3493. } else {
  3494. throw new Error("No value provided for input HTTP label: stageName.");
  3495. }
  3496. let body: any;
  3497. body = JSON.stringify({
  3498. ...(input.parameters !== undefined && {
  3499. parameters: serializeAws_restJson1MapOfStringToString(input.parameters, context),
  3500. }),
  3501. });
  3502. const { hostname, protocol = "https", port } = await context.endpoint();
  3503. return new __HttpRequest({
  3504. protocol,
  3505. hostname,
  3506. port,
  3507. method: "GET",
  3508. headers,
  3509. path: resolvedPath,
  3510. body,
  3511. });
  3512. };
  3513. export const serializeAws_restJson1GetSdkTypeCommand = async (
  3514. input: GetSdkTypeCommandInput,
  3515. context: __SerdeContext
  3516. ): Promise<__HttpRequest> => {
  3517. const headers: any = {
  3518. "Content-Type": "application/json",
  3519. };
  3520. let resolvedPath = "/sdktypes/{id}";
  3521. if (input.id !== undefined) {
  3522. const labelValue: string = input.id;
  3523. if (labelValue.length <= 0) {
  3524. throw new Error("Empty value provided for input HTTP label: id.");
  3525. }
  3526. resolvedPath = resolvedPath.replace("{id}", __extendedEncodeURIComponent(labelValue));
  3527. } else {
  3528. throw new Error("No value provided for input HTTP label: id.");
  3529. }
  3530. let body: any;
  3531. body = JSON.stringify({
  3532. ...(input.name !== undefined && { name: input.name }),
  3533. ...(input.template !== undefined && { template: input.template }),
  3534. ...(input.templateSkipList !== undefined && {
  3535. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3536. }),
  3537. ...(input.title !== undefined && { title: input.title }),
  3538. });
  3539. const { hostname, protocol = "https", port } = await context.endpoint();
  3540. return new __HttpRequest({
  3541. protocol,
  3542. hostname,
  3543. port,
  3544. method: "GET",
  3545. headers,
  3546. path: resolvedPath,
  3547. body,
  3548. });
  3549. };
  3550. export const serializeAws_restJson1GetSdkTypesCommand = async (
  3551. input: GetSdkTypesCommandInput,
  3552. context: __SerdeContext
  3553. ): Promise<__HttpRequest> => {
  3554. const headers: any = {
  3555. "Content-Type": "application/json",
  3556. };
  3557. let resolvedPath = "/sdktypes";
  3558. const query: any = {
  3559. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3560. ...(input.position !== undefined && { position: input.position }),
  3561. };
  3562. let body: any;
  3563. body = JSON.stringify({
  3564. ...(input.name !== undefined && { name: input.name }),
  3565. ...(input.template !== undefined && { template: input.template }),
  3566. ...(input.templateSkipList !== undefined && {
  3567. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3568. }),
  3569. ...(input.title !== undefined && { title: input.title }),
  3570. });
  3571. const { hostname, protocol = "https", port } = await context.endpoint();
  3572. return new __HttpRequest({
  3573. protocol,
  3574. hostname,
  3575. port,
  3576. method: "GET",
  3577. headers,
  3578. path: resolvedPath,
  3579. query,
  3580. body,
  3581. });
  3582. };
  3583. export const serializeAws_restJson1GetStageCommand = async (
  3584. input: GetStageCommandInput,
  3585. context: __SerdeContext
  3586. ): Promise<__HttpRequest> => {
  3587. const headers: any = {
  3588. "Content-Type": "application/json",
  3589. };
  3590. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}";
  3591. if (input.stageName !== undefined) {
  3592. const labelValue: string = input.stageName;
  3593. if (labelValue.length <= 0) {
  3594. throw new Error("Empty value provided for input HTTP label: stageName.");
  3595. }
  3596. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  3597. } else {
  3598. throw new Error("No value provided for input HTTP label: stageName.");
  3599. }
  3600. if (input.restApiId !== undefined) {
  3601. const labelValue: string = input.restApiId;
  3602. if (labelValue.length <= 0) {
  3603. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3604. }
  3605. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3606. } else {
  3607. throw new Error("No value provided for input HTTP label: restApiId.");
  3608. }
  3609. let body: any;
  3610. body = JSON.stringify({
  3611. ...(input.name !== undefined && { name: input.name }),
  3612. ...(input.template !== undefined && { template: input.template }),
  3613. ...(input.templateSkipList !== undefined && {
  3614. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3615. }),
  3616. ...(input.title !== undefined && { title: input.title }),
  3617. });
  3618. const { hostname, protocol = "https", port } = await context.endpoint();
  3619. return new __HttpRequest({
  3620. protocol,
  3621. hostname,
  3622. port,
  3623. method: "GET",
  3624. headers,
  3625. path: resolvedPath,
  3626. body,
  3627. });
  3628. };
  3629. export const serializeAws_restJson1GetStagesCommand = async (
  3630. input: GetStagesCommandInput,
  3631. context: __SerdeContext
  3632. ): Promise<__HttpRequest> => {
  3633. const headers: any = {
  3634. "Content-Type": "application/json",
  3635. };
  3636. let resolvedPath = "/restapis/{restApiId}/stages";
  3637. if (input.restApiId !== undefined) {
  3638. const labelValue: string = input.restApiId;
  3639. if (labelValue.length <= 0) {
  3640. throw new Error("Empty value provided for input HTTP label: restApiId.");
  3641. }
  3642. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  3643. } else {
  3644. throw new Error("No value provided for input HTTP label: restApiId.");
  3645. }
  3646. const query: any = {
  3647. ...(input.deploymentId !== undefined && { deploymentId: input.deploymentId }),
  3648. };
  3649. let body: any;
  3650. body = JSON.stringify({
  3651. ...(input.name !== undefined && { name: input.name }),
  3652. ...(input.template !== undefined && { template: input.template }),
  3653. ...(input.templateSkipList !== undefined && {
  3654. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3655. }),
  3656. ...(input.title !== undefined && { title: input.title }),
  3657. });
  3658. const { hostname, protocol = "https", port } = await context.endpoint();
  3659. return new __HttpRequest({
  3660. protocol,
  3661. hostname,
  3662. port,
  3663. method: "GET",
  3664. headers,
  3665. path: resolvedPath,
  3666. query,
  3667. body,
  3668. });
  3669. };
  3670. export const serializeAws_restJson1GetTagsCommand = async (
  3671. input: GetTagsCommandInput,
  3672. context: __SerdeContext
  3673. ): Promise<__HttpRequest> => {
  3674. const headers: any = {
  3675. "Content-Type": "application/json",
  3676. };
  3677. let resolvedPath = "/tags/{resourceArn}";
  3678. if (input.resourceArn !== undefined) {
  3679. const labelValue: string = input.resourceArn;
  3680. if (labelValue.length <= 0) {
  3681. throw new Error("Empty value provided for input HTTP label: resourceArn.");
  3682. }
  3683. resolvedPath = resolvedPath.replace("{resourceArn}", __extendedEncodeURIComponent(labelValue));
  3684. } else {
  3685. throw new Error("No value provided for input HTTP label: resourceArn.");
  3686. }
  3687. const query: any = {
  3688. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3689. ...(input.position !== undefined && { position: input.position }),
  3690. };
  3691. let body: any;
  3692. body = JSON.stringify({
  3693. ...(input.name !== undefined && { name: input.name }),
  3694. ...(input.template !== undefined && { template: input.template }),
  3695. ...(input.templateSkipList !== undefined && {
  3696. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3697. }),
  3698. ...(input.title !== undefined && { title: input.title }),
  3699. });
  3700. const { hostname, protocol = "https", port } = await context.endpoint();
  3701. return new __HttpRequest({
  3702. protocol,
  3703. hostname,
  3704. port,
  3705. method: "GET",
  3706. headers,
  3707. path: resolvedPath,
  3708. query,
  3709. body,
  3710. });
  3711. };
  3712. export const serializeAws_restJson1GetUsageCommand = async (
  3713. input: GetUsageCommandInput,
  3714. context: __SerdeContext
  3715. ): Promise<__HttpRequest> => {
  3716. const headers: any = {
  3717. "Content-Type": "application/json",
  3718. };
  3719. let resolvedPath = "/usageplans/{usagePlanId}/usage";
  3720. if (input.usagePlanId !== undefined) {
  3721. const labelValue: string = input.usagePlanId;
  3722. if (labelValue.length <= 0) {
  3723. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  3724. }
  3725. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  3726. } else {
  3727. throw new Error("No value provided for input HTTP label: usagePlanId.");
  3728. }
  3729. const query: any = {
  3730. ...(input.position !== undefined && { position: input.position }),
  3731. ...(input.endDate !== undefined && { endDate: input.endDate }),
  3732. ...(input.startDate !== undefined && { startDate: input.startDate }),
  3733. ...(input.keyId !== undefined && { keyId: input.keyId }),
  3734. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3735. };
  3736. let body: any;
  3737. body = JSON.stringify({
  3738. ...(input.name !== undefined && { name: input.name }),
  3739. ...(input.template !== undefined && { template: input.template }),
  3740. ...(input.templateSkipList !== undefined && {
  3741. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3742. }),
  3743. ...(input.title !== undefined && { title: input.title }),
  3744. });
  3745. const { hostname, protocol = "https", port } = await context.endpoint();
  3746. return new __HttpRequest({
  3747. protocol,
  3748. hostname,
  3749. port,
  3750. method: "GET",
  3751. headers,
  3752. path: resolvedPath,
  3753. query,
  3754. body,
  3755. });
  3756. };
  3757. export const serializeAws_restJson1GetUsagePlanCommand = async (
  3758. input: GetUsagePlanCommandInput,
  3759. context: __SerdeContext
  3760. ): Promise<__HttpRequest> => {
  3761. const headers: any = {
  3762. "Content-Type": "application/json",
  3763. };
  3764. let resolvedPath = "/usageplans/{usagePlanId}";
  3765. if (input.usagePlanId !== undefined) {
  3766. const labelValue: string = input.usagePlanId;
  3767. if (labelValue.length <= 0) {
  3768. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  3769. }
  3770. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  3771. } else {
  3772. throw new Error("No value provided for input HTTP label: usagePlanId.");
  3773. }
  3774. let body: any;
  3775. body = JSON.stringify({
  3776. ...(input.name !== undefined && { name: input.name }),
  3777. ...(input.template !== undefined && { template: input.template }),
  3778. ...(input.templateSkipList !== undefined && {
  3779. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3780. }),
  3781. ...(input.title !== undefined && { title: input.title }),
  3782. });
  3783. const { hostname, protocol = "https", port } = await context.endpoint();
  3784. return new __HttpRequest({
  3785. protocol,
  3786. hostname,
  3787. port,
  3788. method: "GET",
  3789. headers,
  3790. path: resolvedPath,
  3791. body,
  3792. });
  3793. };
  3794. export const serializeAws_restJson1GetUsagePlanKeyCommand = async (
  3795. input: GetUsagePlanKeyCommandInput,
  3796. context: __SerdeContext
  3797. ): Promise<__HttpRequest> => {
  3798. const headers: any = {
  3799. "Content-Type": "application/json",
  3800. };
  3801. let resolvedPath = "/usageplans/{usagePlanId}/keys/{keyId}";
  3802. if (input.keyId !== undefined) {
  3803. const labelValue: string = input.keyId;
  3804. if (labelValue.length <= 0) {
  3805. throw new Error("Empty value provided for input HTTP label: keyId.");
  3806. }
  3807. resolvedPath = resolvedPath.replace("{keyId}", __extendedEncodeURIComponent(labelValue));
  3808. } else {
  3809. throw new Error("No value provided for input HTTP label: keyId.");
  3810. }
  3811. if (input.usagePlanId !== undefined) {
  3812. const labelValue: string = input.usagePlanId;
  3813. if (labelValue.length <= 0) {
  3814. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  3815. }
  3816. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  3817. } else {
  3818. throw new Error("No value provided for input HTTP label: usagePlanId.");
  3819. }
  3820. let body: any;
  3821. body = JSON.stringify({
  3822. ...(input.name !== undefined && { name: input.name }),
  3823. ...(input.template !== undefined && { template: input.template }),
  3824. ...(input.templateSkipList !== undefined && {
  3825. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3826. }),
  3827. ...(input.title !== undefined && { title: input.title }),
  3828. });
  3829. const { hostname, protocol = "https", port } = await context.endpoint();
  3830. return new __HttpRequest({
  3831. protocol,
  3832. hostname,
  3833. port,
  3834. method: "GET",
  3835. headers,
  3836. path: resolvedPath,
  3837. body,
  3838. });
  3839. };
  3840. export const serializeAws_restJson1GetUsagePlanKeysCommand = async (
  3841. input: GetUsagePlanKeysCommandInput,
  3842. context: __SerdeContext
  3843. ): Promise<__HttpRequest> => {
  3844. const headers: any = {
  3845. "Content-Type": "application/json",
  3846. };
  3847. let resolvedPath = "/usageplans/{usagePlanId}/keys";
  3848. if (input.usagePlanId !== undefined) {
  3849. const labelValue: string = input.usagePlanId;
  3850. if (labelValue.length <= 0) {
  3851. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  3852. }
  3853. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  3854. } else {
  3855. throw new Error("No value provided for input HTTP label: usagePlanId.");
  3856. }
  3857. const query: any = {
  3858. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3859. ...(input.nameQuery !== undefined && { name: input.nameQuery }),
  3860. ...(input.position !== undefined && { position: input.position }),
  3861. };
  3862. let body: any;
  3863. body = JSON.stringify({
  3864. ...(input.name !== undefined && { name: input.name }),
  3865. ...(input.template !== undefined && { template: input.template }),
  3866. ...(input.templateSkipList !== undefined && {
  3867. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3868. }),
  3869. ...(input.title !== undefined && { title: input.title }),
  3870. });
  3871. const { hostname, protocol = "https", port } = await context.endpoint();
  3872. return new __HttpRequest({
  3873. protocol,
  3874. hostname,
  3875. port,
  3876. method: "GET",
  3877. headers,
  3878. path: resolvedPath,
  3879. query,
  3880. body,
  3881. });
  3882. };
  3883. export const serializeAws_restJson1GetUsagePlansCommand = async (
  3884. input: GetUsagePlansCommandInput,
  3885. context: __SerdeContext
  3886. ): Promise<__HttpRequest> => {
  3887. const headers: any = {
  3888. "Content-Type": "application/json",
  3889. };
  3890. let resolvedPath = "/usageplans";
  3891. const query: any = {
  3892. ...(input.position !== undefined && { position: input.position }),
  3893. ...(input.keyId !== undefined && { keyId: input.keyId }),
  3894. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3895. };
  3896. let body: any;
  3897. body = JSON.stringify({
  3898. ...(input.name !== undefined && { name: input.name }),
  3899. ...(input.template !== undefined && { template: input.template }),
  3900. ...(input.templateSkipList !== undefined && {
  3901. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3902. }),
  3903. ...(input.title !== undefined && { title: input.title }),
  3904. });
  3905. const { hostname, protocol = "https", port } = await context.endpoint();
  3906. return new __HttpRequest({
  3907. protocol,
  3908. hostname,
  3909. port,
  3910. method: "GET",
  3911. headers,
  3912. path: resolvedPath,
  3913. query,
  3914. body,
  3915. });
  3916. };
  3917. export const serializeAws_restJson1GetVpcLinkCommand = async (
  3918. input: GetVpcLinkCommandInput,
  3919. context: __SerdeContext
  3920. ): Promise<__HttpRequest> => {
  3921. const headers: any = {
  3922. "Content-Type": "application/json",
  3923. };
  3924. let resolvedPath = "/vpclinks/{vpcLinkId}";
  3925. if (input.vpcLinkId !== undefined) {
  3926. const labelValue: string = input.vpcLinkId;
  3927. if (labelValue.length <= 0) {
  3928. throw new Error("Empty value provided for input HTTP label: vpcLinkId.");
  3929. }
  3930. resolvedPath = resolvedPath.replace("{vpcLinkId}", __extendedEncodeURIComponent(labelValue));
  3931. } else {
  3932. throw new Error("No value provided for input HTTP label: vpcLinkId.");
  3933. }
  3934. let body: any;
  3935. body = JSON.stringify({
  3936. ...(input.name !== undefined && { name: input.name }),
  3937. ...(input.template !== undefined && { template: input.template }),
  3938. ...(input.templateSkipList !== undefined && {
  3939. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3940. }),
  3941. ...(input.title !== undefined && { title: input.title }),
  3942. });
  3943. const { hostname, protocol = "https", port } = await context.endpoint();
  3944. return new __HttpRequest({
  3945. protocol,
  3946. hostname,
  3947. port,
  3948. method: "GET",
  3949. headers,
  3950. path: resolvedPath,
  3951. body,
  3952. });
  3953. };
  3954. export const serializeAws_restJson1GetVpcLinksCommand = async (
  3955. input: GetVpcLinksCommandInput,
  3956. context: __SerdeContext
  3957. ): Promise<__HttpRequest> => {
  3958. const headers: any = {
  3959. "Content-Type": "application/json",
  3960. };
  3961. let resolvedPath = "/vpclinks";
  3962. const query: any = {
  3963. ...(input.position !== undefined && { position: input.position }),
  3964. ...(input.limit !== undefined && { limit: input.limit.toString() }),
  3965. };
  3966. let body: any;
  3967. body = JSON.stringify({
  3968. ...(input.name !== undefined && { name: input.name }),
  3969. ...(input.template !== undefined && { template: input.template }),
  3970. ...(input.templateSkipList !== undefined && {
  3971. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  3972. }),
  3973. ...(input.title !== undefined && { title: input.title }),
  3974. });
  3975. const { hostname, protocol = "https", port } = await context.endpoint();
  3976. return new __HttpRequest({
  3977. protocol,
  3978. hostname,
  3979. port,
  3980. method: "GET",
  3981. headers,
  3982. path: resolvedPath,
  3983. query,
  3984. body,
  3985. });
  3986. };
  3987. export const serializeAws_restJson1ImportApiKeysCommand = async (
  3988. input: ImportApiKeysCommandInput,
  3989. context: __SerdeContext
  3990. ): Promise<__HttpRequest> => {
  3991. const headers: any = {
  3992. "Content-Type": "application/json",
  3993. };
  3994. let resolvedPath = "/apikeys";
  3995. const query: any = {
  3996. mode: "import",
  3997. ...(input.format !== undefined && { format: input.format }),
  3998. ...(input.failOnWarnings !== undefined && { failonwarnings: input.failOnWarnings.toString() }),
  3999. };
  4000. let body: any;
  4001. body = JSON.stringify({
  4002. ...(input.name !== undefined && { name: input.name }),
  4003. ...(input.template !== undefined && { template: input.template }),
  4004. ...(input.templateSkipList !== undefined && {
  4005. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4006. }),
  4007. ...(input.title !== undefined && { title: input.title }),
  4008. });
  4009. const { hostname, protocol = "https", port } = await context.endpoint();
  4010. return new __HttpRequest({
  4011. protocol,
  4012. hostname,
  4013. port,
  4014. method: "POST",
  4015. headers,
  4016. path: resolvedPath,
  4017. query,
  4018. body,
  4019. });
  4020. };
  4021. export const serializeAws_restJson1ImportDocumentationPartsCommand = async (
  4022. input: ImportDocumentationPartsCommandInput,
  4023. context: __SerdeContext
  4024. ): Promise<__HttpRequest> => {
  4025. const headers: any = {
  4026. "Content-Type": "application/json",
  4027. };
  4028. let resolvedPath = "/restapis/{restApiId}/documentation/parts";
  4029. if (input.restApiId !== undefined) {
  4030. const labelValue: string = input.restApiId;
  4031. if (labelValue.length <= 0) {
  4032. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4033. }
  4034. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4035. } else {
  4036. throw new Error("No value provided for input HTTP label: restApiId.");
  4037. }
  4038. const query: any = {
  4039. ...(input.failOnWarnings !== undefined && { failonwarnings: input.failOnWarnings.toString() }),
  4040. ...(input.mode !== undefined && { mode: input.mode }),
  4041. };
  4042. let body: any;
  4043. body = JSON.stringify({
  4044. ...(input.name !== undefined && { name: input.name }),
  4045. ...(input.template !== undefined && { template: input.template }),
  4046. ...(input.templateSkipList !== undefined && {
  4047. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4048. }),
  4049. ...(input.title !== undefined && { title: input.title }),
  4050. });
  4051. const { hostname, protocol = "https", port } = await context.endpoint();
  4052. return new __HttpRequest({
  4053. protocol,
  4054. hostname,
  4055. port,
  4056. method: "PUT",
  4057. headers,
  4058. path: resolvedPath,
  4059. query,
  4060. body,
  4061. });
  4062. };
  4063. export const serializeAws_restJson1ImportRestApiCommand = async (
  4064. input: ImportRestApiCommandInput,
  4065. context: __SerdeContext
  4066. ): Promise<__HttpRequest> => {
  4067. const headers: any = {
  4068. "Content-Type": "application/json",
  4069. };
  4070. let resolvedPath = "/restapis";
  4071. const query: any = {
  4072. mode: "import",
  4073. ...(input.failOnWarnings !== undefined && { failonwarnings: input.failOnWarnings.toString() }),
  4074. };
  4075. let body: any;
  4076. body = JSON.stringify({
  4077. ...(input.name !== undefined && { name: input.name }),
  4078. ...(input.parameters !== undefined && {
  4079. parameters: serializeAws_restJson1MapOfStringToString(input.parameters, context),
  4080. }),
  4081. ...(input.template !== undefined && { template: input.template }),
  4082. ...(input.templateSkipList !== undefined && {
  4083. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4084. }),
  4085. ...(input.title !== undefined && { title: input.title }),
  4086. });
  4087. const { hostname, protocol = "https", port } = await context.endpoint();
  4088. return new __HttpRequest({
  4089. protocol,
  4090. hostname,
  4091. port,
  4092. method: "POST",
  4093. headers,
  4094. path: resolvedPath,
  4095. query,
  4096. body,
  4097. });
  4098. };
  4099. export const serializeAws_restJson1PutGatewayResponseCommand = async (
  4100. input: PutGatewayResponseCommandInput,
  4101. context: __SerdeContext
  4102. ): Promise<__HttpRequest> => {
  4103. const headers: any = {
  4104. "Content-Type": "application/json",
  4105. };
  4106. let resolvedPath = "/restapis/{restApiId}/gatewayresponses/{responseType}";
  4107. if (input.responseType !== undefined) {
  4108. const labelValue: string = input.responseType;
  4109. if (labelValue.length <= 0) {
  4110. throw new Error("Empty value provided for input HTTP label: responseType.");
  4111. }
  4112. resolvedPath = resolvedPath.replace("{responseType}", __extendedEncodeURIComponent(labelValue));
  4113. } else {
  4114. throw new Error("No value provided for input HTTP label: responseType.");
  4115. }
  4116. if (input.restApiId !== undefined) {
  4117. const labelValue: string = input.restApiId;
  4118. if (labelValue.length <= 0) {
  4119. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4120. }
  4121. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4122. } else {
  4123. throw new Error("No value provided for input HTTP label: restApiId.");
  4124. }
  4125. let body: any;
  4126. body = JSON.stringify({
  4127. ...(input.name !== undefined && { name: input.name }),
  4128. ...(input.responseParameters !== undefined && {
  4129. responseParameters: serializeAws_restJson1MapOfStringToString(input.responseParameters, context),
  4130. }),
  4131. ...(input.responseTemplates !== undefined && {
  4132. responseTemplates: serializeAws_restJson1MapOfStringToString(input.responseTemplates, context),
  4133. }),
  4134. ...(input.statusCode !== undefined && { statusCode: input.statusCode }),
  4135. ...(input.template !== undefined && { template: input.template }),
  4136. ...(input.templateSkipList !== undefined && {
  4137. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4138. }),
  4139. ...(input.title !== undefined && { title: input.title }),
  4140. });
  4141. const { hostname, protocol = "https", port } = await context.endpoint();
  4142. return new __HttpRequest({
  4143. protocol,
  4144. hostname,
  4145. port,
  4146. method: "PUT",
  4147. headers,
  4148. path: resolvedPath,
  4149. body,
  4150. });
  4151. };
  4152. export const serializeAws_restJson1PutIntegrationCommand = async (
  4153. input: PutIntegrationCommandInput,
  4154. context: __SerdeContext
  4155. ): Promise<__HttpRequest> => {
  4156. const headers: any = {
  4157. "Content-Type": "application/json",
  4158. };
  4159. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration";
  4160. if (input.resourceId !== undefined) {
  4161. const labelValue: string = input.resourceId;
  4162. if (labelValue.length <= 0) {
  4163. throw new Error("Empty value provided for input HTTP label: resourceId.");
  4164. }
  4165. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  4166. } else {
  4167. throw new Error("No value provided for input HTTP label: resourceId.");
  4168. }
  4169. if (input.restApiId !== undefined) {
  4170. const labelValue: string = input.restApiId;
  4171. if (labelValue.length <= 0) {
  4172. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4173. }
  4174. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4175. } else {
  4176. throw new Error("No value provided for input HTTP label: restApiId.");
  4177. }
  4178. if (input.httpMethod !== undefined) {
  4179. const labelValue: string = input.httpMethod;
  4180. if (labelValue.length <= 0) {
  4181. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  4182. }
  4183. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  4184. } else {
  4185. throw new Error("No value provided for input HTTP label: httpMethod.");
  4186. }
  4187. let body: any;
  4188. body = JSON.stringify({
  4189. ...(input.cacheKeyParameters !== undefined && {
  4190. cacheKeyParameters: serializeAws_restJson1ListOfString(input.cacheKeyParameters, context),
  4191. }),
  4192. ...(input.cacheNamespace !== undefined && { cacheNamespace: input.cacheNamespace }),
  4193. ...(input.connectionId !== undefined && { connectionId: input.connectionId }),
  4194. ...(input.connectionType !== undefined && { connectionType: input.connectionType }),
  4195. ...(input.contentHandling !== undefined && { contentHandling: input.contentHandling }),
  4196. ...(input.credentials !== undefined && { credentials: input.credentials }),
  4197. ...(input.integrationHttpMethod !== undefined && { httpMethod: input.integrationHttpMethod }),
  4198. ...(input.name !== undefined && { name: input.name }),
  4199. ...(input.passthroughBehavior !== undefined && { passthroughBehavior: input.passthroughBehavior }),
  4200. ...(input.requestParameters !== undefined && {
  4201. requestParameters: serializeAws_restJson1MapOfStringToString(input.requestParameters, context),
  4202. }),
  4203. ...(input.requestTemplates !== undefined && {
  4204. requestTemplates: serializeAws_restJson1MapOfStringToString(input.requestTemplates, context),
  4205. }),
  4206. ...(input.template !== undefined && { template: input.template }),
  4207. ...(input.templateSkipList !== undefined && {
  4208. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4209. }),
  4210. ...(input.timeoutInMillis !== undefined && { timeoutInMillis: input.timeoutInMillis }),
  4211. ...(input.title !== undefined && { title: input.title }),
  4212. ...(input.tlsConfig !== undefined && { tlsConfig: serializeAws_restJson1TlsConfig(input.tlsConfig, context) }),
  4213. ...(input.type !== undefined && { type: input.type }),
  4214. ...(input.uri !== undefined && { uri: input.uri }),
  4215. });
  4216. const { hostname, protocol = "https", port } = await context.endpoint();
  4217. return new __HttpRequest({
  4218. protocol,
  4219. hostname,
  4220. port,
  4221. method: "PUT",
  4222. headers,
  4223. path: resolvedPath,
  4224. body,
  4225. });
  4226. };
  4227. export const serializeAws_restJson1PutIntegrationResponseCommand = async (
  4228. input: PutIntegrationResponseCommandInput,
  4229. context: __SerdeContext
  4230. ): Promise<__HttpRequest> => {
  4231. const headers: any = {
  4232. "Content-Type": "application/json",
  4233. };
  4234. let resolvedPath =
  4235. "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration/responses/{statusCode}";
  4236. if (input.statusCode !== undefined) {
  4237. const labelValue: string = input.statusCode;
  4238. if (labelValue.length <= 0) {
  4239. throw new Error("Empty value provided for input HTTP label: statusCode.");
  4240. }
  4241. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  4242. } else {
  4243. throw new Error("No value provided for input HTTP label: statusCode.");
  4244. }
  4245. if (input.resourceId !== undefined) {
  4246. const labelValue: string = input.resourceId;
  4247. if (labelValue.length <= 0) {
  4248. throw new Error("Empty value provided for input HTTP label: resourceId.");
  4249. }
  4250. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  4251. } else {
  4252. throw new Error("No value provided for input HTTP label: resourceId.");
  4253. }
  4254. if (input.restApiId !== undefined) {
  4255. const labelValue: string = input.restApiId;
  4256. if (labelValue.length <= 0) {
  4257. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4258. }
  4259. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4260. } else {
  4261. throw new Error("No value provided for input HTTP label: restApiId.");
  4262. }
  4263. if (input.httpMethod !== undefined) {
  4264. const labelValue: string = input.httpMethod;
  4265. if (labelValue.length <= 0) {
  4266. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  4267. }
  4268. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  4269. } else {
  4270. throw new Error("No value provided for input HTTP label: httpMethod.");
  4271. }
  4272. let body: any;
  4273. body = JSON.stringify({
  4274. ...(input.contentHandling !== undefined && { contentHandling: input.contentHandling }),
  4275. ...(input.name !== undefined && { name: input.name }),
  4276. ...(input.responseParameters !== undefined && {
  4277. responseParameters: serializeAws_restJson1MapOfStringToString(input.responseParameters, context),
  4278. }),
  4279. ...(input.responseTemplates !== undefined && {
  4280. responseTemplates: serializeAws_restJson1MapOfStringToString(input.responseTemplates, context),
  4281. }),
  4282. ...(input.selectionPattern !== undefined && { selectionPattern: input.selectionPattern }),
  4283. ...(input.template !== undefined && { template: input.template }),
  4284. ...(input.templateSkipList !== undefined && {
  4285. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4286. }),
  4287. ...(input.title !== undefined && { title: input.title }),
  4288. });
  4289. const { hostname, protocol = "https", port } = await context.endpoint();
  4290. return new __HttpRequest({
  4291. protocol,
  4292. hostname,
  4293. port,
  4294. method: "PUT",
  4295. headers,
  4296. path: resolvedPath,
  4297. body,
  4298. });
  4299. };
  4300. export const serializeAws_restJson1PutMethodCommand = async (
  4301. input: PutMethodCommandInput,
  4302. context: __SerdeContext
  4303. ): Promise<__HttpRequest> => {
  4304. const headers: any = {
  4305. "Content-Type": "application/json",
  4306. };
  4307. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}";
  4308. if (input.restApiId !== undefined) {
  4309. const labelValue: string = input.restApiId;
  4310. if (labelValue.length <= 0) {
  4311. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4312. }
  4313. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4314. } else {
  4315. throw new Error("No value provided for input HTTP label: restApiId.");
  4316. }
  4317. if (input.resourceId !== undefined) {
  4318. const labelValue: string = input.resourceId;
  4319. if (labelValue.length <= 0) {
  4320. throw new Error("Empty value provided for input HTTP label: resourceId.");
  4321. }
  4322. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  4323. } else {
  4324. throw new Error("No value provided for input HTTP label: resourceId.");
  4325. }
  4326. if (input.httpMethod !== undefined) {
  4327. const labelValue: string = input.httpMethod;
  4328. if (labelValue.length <= 0) {
  4329. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  4330. }
  4331. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  4332. } else {
  4333. throw new Error("No value provided for input HTTP label: httpMethod.");
  4334. }
  4335. let body: any;
  4336. body = JSON.stringify({
  4337. ...(input.apiKeyRequired !== undefined && { apiKeyRequired: input.apiKeyRequired }),
  4338. ...(input.authorizationScopes !== undefined && {
  4339. authorizationScopes: serializeAws_restJson1ListOfString(input.authorizationScopes, context),
  4340. }),
  4341. ...(input.authorizationType !== undefined && { authorizationType: input.authorizationType }),
  4342. ...(input.authorizerId !== undefined && { authorizerId: input.authorizerId }),
  4343. ...(input.name !== undefined && { name: input.name }),
  4344. ...(input.operationName !== undefined && { operationName: input.operationName }),
  4345. ...(input.requestModels !== undefined && {
  4346. requestModels: serializeAws_restJson1MapOfStringToString(input.requestModels, context),
  4347. }),
  4348. ...(input.requestParameters !== undefined && {
  4349. requestParameters: serializeAws_restJson1MapOfStringToBoolean(input.requestParameters, context),
  4350. }),
  4351. ...(input.requestValidatorId !== undefined && { requestValidatorId: input.requestValidatorId }),
  4352. ...(input.template !== undefined && { template: input.template }),
  4353. ...(input.templateSkipList !== undefined && {
  4354. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4355. }),
  4356. ...(input.title !== undefined && { title: input.title }),
  4357. });
  4358. const { hostname, protocol = "https", port } = await context.endpoint();
  4359. return new __HttpRequest({
  4360. protocol,
  4361. hostname,
  4362. port,
  4363. method: "PUT",
  4364. headers,
  4365. path: resolvedPath,
  4366. body,
  4367. });
  4368. };
  4369. export const serializeAws_restJson1PutMethodResponseCommand = async (
  4370. input: PutMethodResponseCommandInput,
  4371. context: __SerdeContext
  4372. ): Promise<__HttpRequest> => {
  4373. const headers: any = {
  4374. "Content-Type": "application/json",
  4375. };
  4376. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/responses/{statusCode}";
  4377. if (input.restApiId !== undefined) {
  4378. const labelValue: string = input.restApiId;
  4379. if (labelValue.length <= 0) {
  4380. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4381. }
  4382. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4383. } else {
  4384. throw new Error("No value provided for input HTTP label: restApiId.");
  4385. }
  4386. if (input.resourceId !== undefined) {
  4387. const labelValue: string = input.resourceId;
  4388. if (labelValue.length <= 0) {
  4389. throw new Error("Empty value provided for input HTTP label: resourceId.");
  4390. }
  4391. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  4392. } else {
  4393. throw new Error("No value provided for input HTTP label: resourceId.");
  4394. }
  4395. if (input.statusCode !== undefined) {
  4396. const labelValue: string = input.statusCode;
  4397. if (labelValue.length <= 0) {
  4398. throw new Error("Empty value provided for input HTTP label: statusCode.");
  4399. }
  4400. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  4401. } else {
  4402. throw new Error("No value provided for input HTTP label: statusCode.");
  4403. }
  4404. if (input.httpMethod !== undefined) {
  4405. const labelValue: string = input.httpMethod;
  4406. if (labelValue.length <= 0) {
  4407. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  4408. }
  4409. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  4410. } else {
  4411. throw new Error("No value provided for input HTTP label: httpMethod.");
  4412. }
  4413. let body: any;
  4414. body = JSON.stringify({
  4415. ...(input.name !== undefined && { name: input.name }),
  4416. ...(input.responseModels !== undefined && {
  4417. responseModels: serializeAws_restJson1MapOfStringToString(input.responseModels, context),
  4418. }),
  4419. ...(input.responseParameters !== undefined && {
  4420. responseParameters: serializeAws_restJson1MapOfStringToBoolean(input.responseParameters, context),
  4421. }),
  4422. ...(input.template !== undefined && { template: input.template }),
  4423. ...(input.templateSkipList !== undefined && {
  4424. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4425. }),
  4426. ...(input.title !== undefined && { title: input.title }),
  4427. });
  4428. const { hostname, protocol = "https", port } = await context.endpoint();
  4429. return new __HttpRequest({
  4430. protocol,
  4431. hostname,
  4432. port,
  4433. method: "PUT",
  4434. headers,
  4435. path: resolvedPath,
  4436. body,
  4437. });
  4438. };
  4439. export const serializeAws_restJson1PutRestApiCommand = async (
  4440. input: PutRestApiCommandInput,
  4441. context: __SerdeContext
  4442. ): Promise<__HttpRequest> => {
  4443. const headers: any = {
  4444. "Content-Type": "application/json",
  4445. };
  4446. let resolvedPath = "/restapis/{restApiId}";
  4447. if (input.restApiId !== undefined) {
  4448. const labelValue: string = input.restApiId;
  4449. if (labelValue.length <= 0) {
  4450. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4451. }
  4452. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4453. } else {
  4454. throw new Error("No value provided for input HTTP label: restApiId.");
  4455. }
  4456. const query: any = {
  4457. ...(input.mode !== undefined && { mode: input.mode }),
  4458. ...(input.failOnWarnings !== undefined && { failonwarnings: input.failOnWarnings.toString() }),
  4459. };
  4460. let body: any;
  4461. body = JSON.stringify({
  4462. ...(input.name !== undefined && { name: input.name }),
  4463. ...(input.parameters !== undefined && {
  4464. parameters: serializeAws_restJson1MapOfStringToString(input.parameters, context),
  4465. }),
  4466. ...(input.template !== undefined && { template: input.template }),
  4467. ...(input.templateSkipList !== undefined && {
  4468. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4469. }),
  4470. ...(input.title !== undefined && { title: input.title }),
  4471. });
  4472. const { hostname, protocol = "https", port } = await context.endpoint();
  4473. return new __HttpRequest({
  4474. protocol,
  4475. hostname,
  4476. port,
  4477. method: "PUT",
  4478. headers,
  4479. path: resolvedPath,
  4480. query,
  4481. body,
  4482. });
  4483. };
  4484. export const serializeAws_restJson1TagResourceCommand = async (
  4485. input: TagResourceCommandInput,
  4486. context: __SerdeContext
  4487. ): Promise<__HttpRequest> => {
  4488. const headers: any = {
  4489. "Content-Type": "application/json",
  4490. };
  4491. let resolvedPath = "/tags/{resourceArn}";
  4492. if (input.resourceArn !== undefined) {
  4493. const labelValue: string = input.resourceArn;
  4494. if (labelValue.length <= 0) {
  4495. throw new Error("Empty value provided for input HTTP label: resourceArn.");
  4496. }
  4497. resolvedPath = resolvedPath.replace("{resourceArn}", __extendedEncodeURIComponent(labelValue));
  4498. } else {
  4499. throw new Error("No value provided for input HTTP label: resourceArn.");
  4500. }
  4501. let body: any;
  4502. body = JSON.stringify({
  4503. ...(input.name !== undefined && { name: input.name }),
  4504. ...(input.tags !== undefined && { tags: serializeAws_restJson1MapOfStringToString(input.tags, context) }),
  4505. ...(input.template !== undefined && { template: input.template }),
  4506. ...(input.templateSkipList !== undefined && {
  4507. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4508. }),
  4509. ...(input.title !== undefined && { title: input.title }),
  4510. });
  4511. const { hostname, protocol = "https", port } = await context.endpoint();
  4512. return new __HttpRequest({
  4513. protocol,
  4514. hostname,
  4515. port,
  4516. method: "PUT",
  4517. headers,
  4518. path: resolvedPath,
  4519. body,
  4520. });
  4521. };
  4522. export const serializeAws_restJson1TestInvokeAuthorizerCommand = async (
  4523. input: TestInvokeAuthorizerCommandInput,
  4524. context: __SerdeContext
  4525. ): Promise<__HttpRequest> => {
  4526. const headers: any = {
  4527. "Content-Type": "application/json",
  4528. };
  4529. let resolvedPath = "/restapis/{restApiId}/authorizers/{authorizerId}";
  4530. if (input.restApiId !== undefined) {
  4531. const labelValue: string = input.restApiId;
  4532. if (labelValue.length <= 0) {
  4533. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4534. }
  4535. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4536. } else {
  4537. throw new Error("No value provided for input HTTP label: restApiId.");
  4538. }
  4539. if (input.authorizerId !== undefined) {
  4540. const labelValue: string = input.authorizerId;
  4541. if (labelValue.length <= 0) {
  4542. throw new Error("Empty value provided for input HTTP label: authorizerId.");
  4543. }
  4544. resolvedPath = resolvedPath.replace("{authorizerId}", __extendedEncodeURIComponent(labelValue));
  4545. } else {
  4546. throw new Error("No value provided for input HTTP label: authorizerId.");
  4547. }
  4548. let body: any;
  4549. body = JSON.stringify({
  4550. ...(input.additionalContext !== undefined && {
  4551. additionalContext: serializeAws_restJson1MapOfStringToString(input.additionalContext, context),
  4552. }),
  4553. ...(input.body !== undefined && { body: input.body }),
  4554. ...(input.headers !== undefined && { headers: serializeAws_restJson1MapOfStringToString(input.headers, context) }),
  4555. ...(input.multiValueHeaders !== undefined && {
  4556. multiValueHeaders: serializeAws_restJson1MapOfStringToList(input.multiValueHeaders, context),
  4557. }),
  4558. ...(input.pathWithQueryString !== undefined && { pathWithQueryString: input.pathWithQueryString }),
  4559. ...(input.stageVariables !== undefined && {
  4560. stageVariables: serializeAws_restJson1MapOfStringToString(input.stageVariables, context),
  4561. }),
  4562. });
  4563. const { hostname, protocol = "https", port } = await context.endpoint();
  4564. return new __HttpRequest({
  4565. protocol,
  4566. hostname,
  4567. port,
  4568. method: "POST",
  4569. headers,
  4570. path: resolvedPath,
  4571. body,
  4572. });
  4573. };
  4574. export const serializeAws_restJson1TestInvokeMethodCommand = async (
  4575. input: TestInvokeMethodCommandInput,
  4576. context: __SerdeContext
  4577. ): Promise<__HttpRequest> => {
  4578. const headers: any = {
  4579. "Content-Type": "application/json",
  4580. };
  4581. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}";
  4582. if (input.restApiId !== undefined) {
  4583. const labelValue: string = input.restApiId;
  4584. if (labelValue.length <= 0) {
  4585. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4586. }
  4587. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4588. } else {
  4589. throw new Error("No value provided for input HTTP label: restApiId.");
  4590. }
  4591. if (input.resourceId !== undefined) {
  4592. const labelValue: string = input.resourceId;
  4593. if (labelValue.length <= 0) {
  4594. throw new Error("Empty value provided for input HTTP label: resourceId.");
  4595. }
  4596. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  4597. } else {
  4598. throw new Error("No value provided for input HTTP label: resourceId.");
  4599. }
  4600. if (input.httpMethod !== undefined) {
  4601. const labelValue: string = input.httpMethod;
  4602. if (labelValue.length <= 0) {
  4603. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  4604. }
  4605. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  4606. } else {
  4607. throw new Error("No value provided for input HTTP label: httpMethod.");
  4608. }
  4609. let body: any;
  4610. body = JSON.stringify({
  4611. ...(input.body !== undefined && { body: input.body }),
  4612. ...(input.clientCertificateId !== undefined && { clientCertificateId: input.clientCertificateId }),
  4613. ...(input.headers !== undefined && { headers: serializeAws_restJson1MapOfStringToString(input.headers, context) }),
  4614. ...(input.multiValueHeaders !== undefined && {
  4615. multiValueHeaders: serializeAws_restJson1MapOfStringToList(input.multiValueHeaders, context),
  4616. }),
  4617. ...(input.pathWithQueryString !== undefined && { pathWithQueryString: input.pathWithQueryString }),
  4618. ...(input.stageVariables !== undefined && {
  4619. stageVariables: serializeAws_restJson1MapOfStringToString(input.stageVariables, context),
  4620. }),
  4621. });
  4622. const { hostname, protocol = "https", port } = await context.endpoint();
  4623. return new __HttpRequest({
  4624. protocol,
  4625. hostname,
  4626. port,
  4627. method: "POST",
  4628. headers,
  4629. path: resolvedPath,
  4630. body,
  4631. });
  4632. };
  4633. export const serializeAws_restJson1UntagResourceCommand = async (
  4634. input: UntagResourceCommandInput,
  4635. context: __SerdeContext
  4636. ): Promise<__HttpRequest> => {
  4637. const headers: any = {
  4638. "Content-Type": "application/json",
  4639. };
  4640. let resolvedPath = "/tags/{resourceArn}";
  4641. if (input.resourceArn !== undefined) {
  4642. const labelValue: string = input.resourceArn;
  4643. if (labelValue.length <= 0) {
  4644. throw new Error("Empty value provided for input HTTP label: resourceArn.");
  4645. }
  4646. resolvedPath = resolvedPath.replace("{resourceArn}", __extendedEncodeURIComponent(labelValue));
  4647. } else {
  4648. throw new Error("No value provided for input HTTP label: resourceArn.");
  4649. }
  4650. const query: any = {
  4651. ...(input.tagKeys !== undefined && { tagKeys: (input.tagKeys || []).map((_entry) => _entry) }),
  4652. };
  4653. let body: any;
  4654. body = JSON.stringify({
  4655. ...(input.name !== undefined && { name: input.name }),
  4656. ...(input.template !== undefined && { template: input.template }),
  4657. ...(input.templateSkipList !== undefined && {
  4658. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4659. }),
  4660. ...(input.title !== undefined && { title: input.title }),
  4661. });
  4662. const { hostname, protocol = "https", port } = await context.endpoint();
  4663. return new __HttpRequest({
  4664. protocol,
  4665. hostname,
  4666. port,
  4667. method: "DELETE",
  4668. headers,
  4669. path: resolvedPath,
  4670. query,
  4671. body,
  4672. });
  4673. };
  4674. export const serializeAws_restJson1UpdateAccountCommand = async (
  4675. input: UpdateAccountCommandInput,
  4676. context: __SerdeContext
  4677. ): Promise<__HttpRequest> => {
  4678. const headers: any = {
  4679. "Content-Type": "application/json",
  4680. };
  4681. let resolvedPath = "/account";
  4682. let body: any;
  4683. body = JSON.stringify({
  4684. ...(input.name !== undefined && { name: input.name }),
  4685. ...(input.patchOperations !== undefined && {
  4686. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4687. }),
  4688. ...(input.template !== undefined && { template: input.template }),
  4689. ...(input.templateSkipList !== undefined && {
  4690. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4691. }),
  4692. ...(input.title !== undefined && { title: input.title }),
  4693. });
  4694. const { hostname, protocol = "https", port } = await context.endpoint();
  4695. return new __HttpRequest({
  4696. protocol,
  4697. hostname,
  4698. port,
  4699. method: "PATCH",
  4700. headers,
  4701. path: resolvedPath,
  4702. body,
  4703. });
  4704. };
  4705. export const serializeAws_restJson1UpdateApiKeyCommand = async (
  4706. input: UpdateApiKeyCommandInput,
  4707. context: __SerdeContext
  4708. ): Promise<__HttpRequest> => {
  4709. const headers: any = {
  4710. "Content-Type": "application/json",
  4711. };
  4712. let resolvedPath = "/apikeys/{apiKey}";
  4713. if (input.apiKey !== undefined) {
  4714. const labelValue: string = input.apiKey;
  4715. if (labelValue.length <= 0) {
  4716. throw new Error("Empty value provided for input HTTP label: apiKey.");
  4717. }
  4718. resolvedPath = resolvedPath.replace("{apiKey}", __extendedEncodeURIComponent(labelValue));
  4719. } else {
  4720. throw new Error("No value provided for input HTTP label: apiKey.");
  4721. }
  4722. let body: any;
  4723. body = JSON.stringify({
  4724. ...(input.name !== undefined && { name: input.name }),
  4725. ...(input.patchOperations !== undefined && {
  4726. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4727. }),
  4728. ...(input.template !== undefined && { template: input.template }),
  4729. ...(input.templateSkipList !== undefined && {
  4730. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4731. }),
  4732. ...(input.title !== undefined && { title: input.title }),
  4733. });
  4734. const { hostname, protocol = "https", port } = await context.endpoint();
  4735. return new __HttpRequest({
  4736. protocol,
  4737. hostname,
  4738. port,
  4739. method: "PATCH",
  4740. headers,
  4741. path: resolvedPath,
  4742. body,
  4743. });
  4744. };
  4745. export const serializeAws_restJson1UpdateAuthorizerCommand = async (
  4746. input: UpdateAuthorizerCommandInput,
  4747. context: __SerdeContext
  4748. ): Promise<__HttpRequest> => {
  4749. const headers: any = {
  4750. "Content-Type": "application/json",
  4751. };
  4752. let resolvedPath = "/restapis/{restApiId}/authorizers/{authorizerId}";
  4753. if (input.restApiId !== undefined) {
  4754. const labelValue: string = input.restApiId;
  4755. if (labelValue.length <= 0) {
  4756. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4757. }
  4758. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4759. } else {
  4760. throw new Error("No value provided for input HTTP label: restApiId.");
  4761. }
  4762. if (input.authorizerId !== undefined) {
  4763. const labelValue: string = input.authorizerId;
  4764. if (labelValue.length <= 0) {
  4765. throw new Error("Empty value provided for input HTTP label: authorizerId.");
  4766. }
  4767. resolvedPath = resolvedPath.replace("{authorizerId}", __extendedEncodeURIComponent(labelValue));
  4768. } else {
  4769. throw new Error("No value provided for input HTTP label: authorizerId.");
  4770. }
  4771. let body: any;
  4772. body = JSON.stringify({
  4773. ...(input.name !== undefined && { name: input.name }),
  4774. ...(input.patchOperations !== undefined && {
  4775. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4776. }),
  4777. ...(input.template !== undefined && { template: input.template }),
  4778. ...(input.templateSkipList !== undefined && {
  4779. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4780. }),
  4781. ...(input.title !== undefined && { title: input.title }),
  4782. });
  4783. const { hostname, protocol = "https", port } = await context.endpoint();
  4784. return new __HttpRequest({
  4785. protocol,
  4786. hostname,
  4787. port,
  4788. method: "PATCH",
  4789. headers,
  4790. path: resolvedPath,
  4791. body,
  4792. });
  4793. };
  4794. export const serializeAws_restJson1UpdateBasePathMappingCommand = async (
  4795. input: UpdateBasePathMappingCommandInput,
  4796. context: __SerdeContext
  4797. ): Promise<__HttpRequest> => {
  4798. const headers: any = {
  4799. "Content-Type": "application/json",
  4800. };
  4801. let resolvedPath = "/domainnames/{domainName}/basepathmappings/{basePath}";
  4802. if (input.basePath !== undefined) {
  4803. const labelValue: string = input.basePath;
  4804. if (labelValue.length <= 0) {
  4805. throw new Error("Empty value provided for input HTTP label: basePath.");
  4806. }
  4807. resolvedPath = resolvedPath.replace("{basePath}", __extendedEncodeURIComponent(labelValue));
  4808. } else {
  4809. throw new Error("No value provided for input HTTP label: basePath.");
  4810. }
  4811. if (input.domainName !== undefined) {
  4812. const labelValue: string = input.domainName;
  4813. if (labelValue.length <= 0) {
  4814. throw new Error("Empty value provided for input HTTP label: domainName.");
  4815. }
  4816. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  4817. } else {
  4818. throw new Error("No value provided for input HTTP label: domainName.");
  4819. }
  4820. let body: any;
  4821. body = JSON.stringify({
  4822. ...(input.name !== undefined && { name: input.name }),
  4823. ...(input.patchOperations !== undefined && {
  4824. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4825. }),
  4826. ...(input.template !== undefined && { template: input.template }),
  4827. ...(input.templateSkipList !== undefined && {
  4828. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4829. }),
  4830. ...(input.title !== undefined && { title: input.title }),
  4831. });
  4832. const { hostname, protocol = "https", port } = await context.endpoint();
  4833. return new __HttpRequest({
  4834. protocol,
  4835. hostname,
  4836. port,
  4837. method: "PATCH",
  4838. headers,
  4839. path: resolvedPath,
  4840. body,
  4841. });
  4842. };
  4843. export const serializeAws_restJson1UpdateClientCertificateCommand = async (
  4844. input: UpdateClientCertificateCommandInput,
  4845. context: __SerdeContext
  4846. ): Promise<__HttpRequest> => {
  4847. const headers: any = {
  4848. "Content-Type": "application/json",
  4849. };
  4850. let resolvedPath = "/clientcertificates/{clientCertificateId}";
  4851. if (input.clientCertificateId !== undefined) {
  4852. const labelValue: string = input.clientCertificateId;
  4853. if (labelValue.length <= 0) {
  4854. throw new Error("Empty value provided for input HTTP label: clientCertificateId.");
  4855. }
  4856. resolvedPath = resolvedPath.replace("{clientCertificateId}", __extendedEncodeURIComponent(labelValue));
  4857. } else {
  4858. throw new Error("No value provided for input HTTP label: clientCertificateId.");
  4859. }
  4860. let body: any;
  4861. body = JSON.stringify({
  4862. ...(input.name !== undefined && { name: input.name }),
  4863. ...(input.patchOperations !== undefined && {
  4864. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4865. }),
  4866. ...(input.template !== undefined && { template: input.template }),
  4867. ...(input.templateSkipList !== undefined && {
  4868. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4869. }),
  4870. ...(input.title !== undefined && { title: input.title }),
  4871. });
  4872. const { hostname, protocol = "https", port } = await context.endpoint();
  4873. return new __HttpRequest({
  4874. protocol,
  4875. hostname,
  4876. port,
  4877. method: "PATCH",
  4878. headers,
  4879. path: resolvedPath,
  4880. body,
  4881. });
  4882. };
  4883. export const serializeAws_restJson1UpdateDeploymentCommand = async (
  4884. input: UpdateDeploymentCommandInput,
  4885. context: __SerdeContext
  4886. ): Promise<__HttpRequest> => {
  4887. const headers: any = {
  4888. "Content-Type": "application/json",
  4889. };
  4890. let resolvedPath = "/restapis/{restApiId}/deployments/{deploymentId}";
  4891. if (input.deploymentId !== undefined) {
  4892. const labelValue: string = input.deploymentId;
  4893. if (labelValue.length <= 0) {
  4894. throw new Error("Empty value provided for input HTTP label: deploymentId.");
  4895. }
  4896. resolvedPath = resolvedPath.replace("{deploymentId}", __extendedEncodeURIComponent(labelValue));
  4897. } else {
  4898. throw new Error("No value provided for input HTTP label: deploymentId.");
  4899. }
  4900. if (input.restApiId !== undefined) {
  4901. const labelValue: string = input.restApiId;
  4902. if (labelValue.length <= 0) {
  4903. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4904. }
  4905. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4906. } else {
  4907. throw new Error("No value provided for input HTTP label: restApiId.");
  4908. }
  4909. let body: any;
  4910. body = JSON.stringify({
  4911. ...(input.name !== undefined && { name: input.name }),
  4912. ...(input.patchOperations !== undefined && {
  4913. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4914. }),
  4915. ...(input.template !== undefined && { template: input.template }),
  4916. ...(input.templateSkipList !== undefined && {
  4917. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4918. }),
  4919. ...(input.title !== undefined && { title: input.title }),
  4920. });
  4921. const { hostname, protocol = "https", port } = await context.endpoint();
  4922. return new __HttpRequest({
  4923. protocol,
  4924. hostname,
  4925. port,
  4926. method: "PATCH",
  4927. headers,
  4928. path: resolvedPath,
  4929. body,
  4930. });
  4931. };
  4932. export const serializeAws_restJson1UpdateDocumentationPartCommand = async (
  4933. input: UpdateDocumentationPartCommandInput,
  4934. context: __SerdeContext
  4935. ): Promise<__HttpRequest> => {
  4936. const headers: any = {
  4937. "Content-Type": "application/json",
  4938. };
  4939. let resolvedPath = "/restapis/{restApiId}/documentation/parts/{documentationPartId}";
  4940. if (input.documentationPartId !== undefined) {
  4941. const labelValue: string = input.documentationPartId;
  4942. if (labelValue.length <= 0) {
  4943. throw new Error("Empty value provided for input HTTP label: documentationPartId.");
  4944. }
  4945. resolvedPath = resolvedPath.replace("{documentationPartId}", __extendedEncodeURIComponent(labelValue));
  4946. } else {
  4947. throw new Error("No value provided for input HTTP label: documentationPartId.");
  4948. }
  4949. if (input.restApiId !== undefined) {
  4950. const labelValue: string = input.restApiId;
  4951. if (labelValue.length <= 0) {
  4952. throw new Error("Empty value provided for input HTTP label: restApiId.");
  4953. }
  4954. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  4955. } else {
  4956. throw new Error("No value provided for input HTTP label: restApiId.");
  4957. }
  4958. let body: any;
  4959. body = JSON.stringify({
  4960. ...(input.name !== undefined && { name: input.name }),
  4961. ...(input.patchOperations !== undefined && {
  4962. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  4963. }),
  4964. ...(input.template !== undefined && { template: input.template }),
  4965. ...(input.templateSkipList !== undefined && {
  4966. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  4967. }),
  4968. ...(input.title !== undefined && { title: input.title }),
  4969. });
  4970. const { hostname, protocol = "https", port } = await context.endpoint();
  4971. return new __HttpRequest({
  4972. protocol,
  4973. hostname,
  4974. port,
  4975. method: "PATCH",
  4976. headers,
  4977. path: resolvedPath,
  4978. body,
  4979. });
  4980. };
  4981. export const serializeAws_restJson1UpdateDocumentationVersionCommand = async (
  4982. input: UpdateDocumentationVersionCommandInput,
  4983. context: __SerdeContext
  4984. ): Promise<__HttpRequest> => {
  4985. const headers: any = {
  4986. "Content-Type": "application/json",
  4987. };
  4988. let resolvedPath = "/restapis/{restApiId}/documentation/versions/{documentationVersion}";
  4989. if (input.documentationVersion !== undefined) {
  4990. const labelValue: string = input.documentationVersion;
  4991. if (labelValue.length <= 0) {
  4992. throw new Error("Empty value provided for input HTTP label: documentationVersion.");
  4993. }
  4994. resolvedPath = resolvedPath.replace("{documentationVersion}", __extendedEncodeURIComponent(labelValue));
  4995. } else {
  4996. throw new Error("No value provided for input HTTP label: documentationVersion.");
  4997. }
  4998. if (input.restApiId !== undefined) {
  4999. const labelValue: string = input.restApiId;
  5000. if (labelValue.length <= 0) {
  5001. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5002. }
  5003. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5004. } else {
  5005. throw new Error("No value provided for input HTTP label: restApiId.");
  5006. }
  5007. let body: any;
  5008. body = JSON.stringify({
  5009. ...(input.name !== undefined && { name: input.name }),
  5010. ...(input.patchOperations !== undefined && {
  5011. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5012. }),
  5013. ...(input.template !== undefined && { template: input.template }),
  5014. ...(input.templateSkipList !== undefined && {
  5015. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5016. }),
  5017. ...(input.title !== undefined && { title: input.title }),
  5018. });
  5019. const { hostname, protocol = "https", port } = await context.endpoint();
  5020. return new __HttpRequest({
  5021. protocol,
  5022. hostname,
  5023. port,
  5024. method: "PATCH",
  5025. headers,
  5026. path: resolvedPath,
  5027. body,
  5028. });
  5029. };
  5030. export const serializeAws_restJson1UpdateDomainNameCommand = async (
  5031. input: UpdateDomainNameCommandInput,
  5032. context: __SerdeContext
  5033. ): Promise<__HttpRequest> => {
  5034. const headers: any = {
  5035. "Content-Type": "application/json",
  5036. };
  5037. let resolvedPath = "/domainnames/{domainName}";
  5038. if (input.domainName !== undefined) {
  5039. const labelValue: string = input.domainName;
  5040. if (labelValue.length <= 0) {
  5041. throw new Error("Empty value provided for input HTTP label: domainName.");
  5042. }
  5043. resolvedPath = resolvedPath.replace("{domainName}", __extendedEncodeURIComponent(labelValue));
  5044. } else {
  5045. throw new Error("No value provided for input HTTP label: domainName.");
  5046. }
  5047. let body: any;
  5048. body = JSON.stringify({
  5049. ...(input.name !== undefined && { name: input.name }),
  5050. ...(input.patchOperations !== undefined && {
  5051. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5052. }),
  5053. ...(input.template !== undefined && { template: input.template }),
  5054. ...(input.templateSkipList !== undefined && {
  5055. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5056. }),
  5057. ...(input.title !== undefined && { title: input.title }),
  5058. });
  5059. const { hostname, protocol = "https", port } = await context.endpoint();
  5060. return new __HttpRequest({
  5061. protocol,
  5062. hostname,
  5063. port,
  5064. method: "PATCH",
  5065. headers,
  5066. path: resolvedPath,
  5067. body,
  5068. });
  5069. };
  5070. export const serializeAws_restJson1UpdateGatewayResponseCommand = async (
  5071. input: UpdateGatewayResponseCommandInput,
  5072. context: __SerdeContext
  5073. ): Promise<__HttpRequest> => {
  5074. const headers: any = {
  5075. "Content-Type": "application/json",
  5076. };
  5077. let resolvedPath = "/restapis/{restApiId}/gatewayresponses/{responseType}";
  5078. if (input.responseType !== undefined) {
  5079. const labelValue: string = input.responseType;
  5080. if (labelValue.length <= 0) {
  5081. throw new Error("Empty value provided for input HTTP label: responseType.");
  5082. }
  5083. resolvedPath = resolvedPath.replace("{responseType}", __extendedEncodeURIComponent(labelValue));
  5084. } else {
  5085. throw new Error("No value provided for input HTTP label: responseType.");
  5086. }
  5087. if (input.restApiId !== undefined) {
  5088. const labelValue: string = input.restApiId;
  5089. if (labelValue.length <= 0) {
  5090. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5091. }
  5092. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5093. } else {
  5094. throw new Error("No value provided for input HTTP label: restApiId.");
  5095. }
  5096. let body: any;
  5097. body = JSON.stringify({
  5098. ...(input.name !== undefined && { name: input.name }),
  5099. ...(input.patchOperations !== undefined && {
  5100. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5101. }),
  5102. ...(input.template !== undefined && { template: input.template }),
  5103. ...(input.templateSkipList !== undefined && {
  5104. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5105. }),
  5106. ...(input.title !== undefined && { title: input.title }),
  5107. });
  5108. const { hostname, protocol = "https", port } = await context.endpoint();
  5109. return new __HttpRequest({
  5110. protocol,
  5111. hostname,
  5112. port,
  5113. method: "PATCH",
  5114. headers,
  5115. path: resolvedPath,
  5116. body,
  5117. });
  5118. };
  5119. export const serializeAws_restJson1UpdateIntegrationCommand = async (
  5120. input: UpdateIntegrationCommandInput,
  5121. context: __SerdeContext
  5122. ): Promise<__HttpRequest> => {
  5123. const headers: any = {
  5124. "Content-Type": "application/json",
  5125. };
  5126. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration";
  5127. if (input.httpMethod !== undefined) {
  5128. const labelValue: string = input.httpMethod;
  5129. if (labelValue.length <= 0) {
  5130. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  5131. }
  5132. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  5133. } else {
  5134. throw new Error("No value provided for input HTTP label: httpMethod.");
  5135. }
  5136. if (input.restApiId !== undefined) {
  5137. const labelValue: string = input.restApiId;
  5138. if (labelValue.length <= 0) {
  5139. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5140. }
  5141. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5142. } else {
  5143. throw new Error("No value provided for input HTTP label: restApiId.");
  5144. }
  5145. if (input.resourceId !== undefined) {
  5146. const labelValue: string = input.resourceId;
  5147. if (labelValue.length <= 0) {
  5148. throw new Error("Empty value provided for input HTTP label: resourceId.");
  5149. }
  5150. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  5151. } else {
  5152. throw new Error("No value provided for input HTTP label: resourceId.");
  5153. }
  5154. let body: any;
  5155. body = JSON.stringify({
  5156. ...(input.name !== undefined && { name: input.name }),
  5157. ...(input.patchOperations !== undefined && {
  5158. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5159. }),
  5160. ...(input.template !== undefined && { template: input.template }),
  5161. ...(input.templateSkipList !== undefined && {
  5162. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5163. }),
  5164. ...(input.title !== undefined && { title: input.title }),
  5165. });
  5166. const { hostname, protocol = "https", port } = await context.endpoint();
  5167. return new __HttpRequest({
  5168. protocol,
  5169. hostname,
  5170. port,
  5171. method: "PATCH",
  5172. headers,
  5173. path: resolvedPath,
  5174. body,
  5175. });
  5176. };
  5177. export const serializeAws_restJson1UpdateIntegrationResponseCommand = async (
  5178. input: UpdateIntegrationResponseCommandInput,
  5179. context: __SerdeContext
  5180. ): Promise<__HttpRequest> => {
  5181. const headers: any = {
  5182. "Content-Type": "application/json",
  5183. };
  5184. let resolvedPath =
  5185. "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/integration/responses/{statusCode}";
  5186. if (input.statusCode !== undefined) {
  5187. const labelValue: string = input.statusCode;
  5188. if (labelValue.length <= 0) {
  5189. throw new Error("Empty value provided for input HTTP label: statusCode.");
  5190. }
  5191. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  5192. } else {
  5193. throw new Error("No value provided for input HTTP label: statusCode.");
  5194. }
  5195. if (input.httpMethod !== undefined) {
  5196. const labelValue: string = input.httpMethod;
  5197. if (labelValue.length <= 0) {
  5198. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  5199. }
  5200. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  5201. } else {
  5202. throw new Error("No value provided for input HTTP label: httpMethod.");
  5203. }
  5204. if (input.resourceId !== undefined) {
  5205. const labelValue: string = input.resourceId;
  5206. if (labelValue.length <= 0) {
  5207. throw new Error("Empty value provided for input HTTP label: resourceId.");
  5208. }
  5209. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  5210. } else {
  5211. throw new Error("No value provided for input HTTP label: resourceId.");
  5212. }
  5213. if (input.restApiId !== undefined) {
  5214. const labelValue: string = input.restApiId;
  5215. if (labelValue.length <= 0) {
  5216. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5217. }
  5218. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5219. } else {
  5220. throw new Error("No value provided for input HTTP label: restApiId.");
  5221. }
  5222. let body: any;
  5223. body = JSON.stringify({
  5224. ...(input.name !== undefined && { name: input.name }),
  5225. ...(input.patchOperations !== undefined && {
  5226. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5227. }),
  5228. ...(input.template !== undefined && { template: input.template }),
  5229. ...(input.templateSkipList !== undefined && {
  5230. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5231. }),
  5232. ...(input.title !== undefined && { title: input.title }),
  5233. });
  5234. const { hostname, protocol = "https", port } = await context.endpoint();
  5235. return new __HttpRequest({
  5236. protocol,
  5237. hostname,
  5238. port,
  5239. method: "PATCH",
  5240. headers,
  5241. path: resolvedPath,
  5242. body,
  5243. });
  5244. };
  5245. export const serializeAws_restJson1UpdateMethodCommand = async (
  5246. input: UpdateMethodCommandInput,
  5247. context: __SerdeContext
  5248. ): Promise<__HttpRequest> => {
  5249. const headers: any = {
  5250. "Content-Type": "application/json",
  5251. };
  5252. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}";
  5253. if (input.httpMethod !== undefined) {
  5254. const labelValue: string = input.httpMethod;
  5255. if (labelValue.length <= 0) {
  5256. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  5257. }
  5258. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  5259. } else {
  5260. throw new Error("No value provided for input HTTP label: httpMethod.");
  5261. }
  5262. if (input.restApiId !== undefined) {
  5263. const labelValue: string = input.restApiId;
  5264. if (labelValue.length <= 0) {
  5265. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5266. }
  5267. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5268. } else {
  5269. throw new Error("No value provided for input HTTP label: restApiId.");
  5270. }
  5271. if (input.resourceId !== undefined) {
  5272. const labelValue: string = input.resourceId;
  5273. if (labelValue.length <= 0) {
  5274. throw new Error("Empty value provided for input HTTP label: resourceId.");
  5275. }
  5276. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  5277. } else {
  5278. throw new Error("No value provided for input HTTP label: resourceId.");
  5279. }
  5280. let body: any;
  5281. body = JSON.stringify({
  5282. ...(input.name !== undefined && { name: input.name }),
  5283. ...(input.patchOperations !== undefined && {
  5284. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5285. }),
  5286. ...(input.template !== undefined && { template: input.template }),
  5287. ...(input.templateSkipList !== undefined && {
  5288. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5289. }),
  5290. ...(input.title !== undefined && { title: input.title }),
  5291. });
  5292. const { hostname, protocol = "https", port } = await context.endpoint();
  5293. return new __HttpRequest({
  5294. protocol,
  5295. hostname,
  5296. port,
  5297. method: "PATCH",
  5298. headers,
  5299. path: resolvedPath,
  5300. body,
  5301. });
  5302. };
  5303. export const serializeAws_restJson1UpdateMethodResponseCommand = async (
  5304. input: UpdateMethodResponseCommandInput,
  5305. context: __SerdeContext
  5306. ): Promise<__HttpRequest> => {
  5307. const headers: any = {
  5308. "Content-Type": "application/json",
  5309. };
  5310. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}/methods/{httpMethod}/responses/{statusCode}";
  5311. if (input.resourceId !== undefined) {
  5312. const labelValue: string = input.resourceId;
  5313. if (labelValue.length <= 0) {
  5314. throw new Error("Empty value provided for input HTTP label: resourceId.");
  5315. }
  5316. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  5317. } else {
  5318. throw new Error("No value provided for input HTTP label: resourceId.");
  5319. }
  5320. if (input.httpMethod !== undefined) {
  5321. const labelValue: string = input.httpMethod;
  5322. if (labelValue.length <= 0) {
  5323. throw new Error("Empty value provided for input HTTP label: httpMethod.");
  5324. }
  5325. resolvedPath = resolvedPath.replace("{httpMethod}", __extendedEncodeURIComponent(labelValue));
  5326. } else {
  5327. throw new Error("No value provided for input HTTP label: httpMethod.");
  5328. }
  5329. if (input.statusCode !== undefined) {
  5330. const labelValue: string = input.statusCode;
  5331. if (labelValue.length <= 0) {
  5332. throw new Error("Empty value provided for input HTTP label: statusCode.");
  5333. }
  5334. resolvedPath = resolvedPath.replace("{statusCode}", __extendedEncodeURIComponent(labelValue));
  5335. } else {
  5336. throw new Error("No value provided for input HTTP label: statusCode.");
  5337. }
  5338. if (input.restApiId !== undefined) {
  5339. const labelValue: string = input.restApiId;
  5340. if (labelValue.length <= 0) {
  5341. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5342. }
  5343. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5344. } else {
  5345. throw new Error("No value provided for input HTTP label: restApiId.");
  5346. }
  5347. let body: any;
  5348. body = JSON.stringify({
  5349. ...(input.name !== undefined && { name: input.name }),
  5350. ...(input.patchOperations !== undefined && {
  5351. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5352. }),
  5353. ...(input.template !== undefined && { template: input.template }),
  5354. ...(input.templateSkipList !== undefined && {
  5355. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5356. }),
  5357. ...(input.title !== undefined && { title: input.title }),
  5358. });
  5359. const { hostname, protocol = "https", port } = await context.endpoint();
  5360. return new __HttpRequest({
  5361. protocol,
  5362. hostname,
  5363. port,
  5364. method: "PATCH",
  5365. headers,
  5366. path: resolvedPath,
  5367. body,
  5368. });
  5369. };
  5370. export const serializeAws_restJson1UpdateModelCommand = async (
  5371. input: UpdateModelCommandInput,
  5372. context: __SerdeContext
  5373. ): Promise<__HttpRequest> => {
  5374. const headers: any = {
  5375. "Content-Type": "application/json",
  5376. };
  5377. let resolvedPath = "/restapis/{restApiId}/models/{modelName}";
  5378. if (input.modelName !== undefined) {
  5379. const labelValue: string = input.modelName;
  5380. if (labelValue.length <= 0) {
  5381. throw new Error("Empty value provided for input HTTP label: modelName.");
  5382. }
  5383. resolvedPath = resolvedPath.replace("{modelName}", __extendedEncodeURIComponent(labelValue));
  5384. } else {
  5385. throw new Error("No value provided for input HTTP label: modelName.");
  5386. }
  5387. if (input.restApiId !== undefined) {
  5388. const labelValue: string = input.restApiId;
  5389. if (labelValue.length <= 0) {
  5390. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5391. }
  5392. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5393. } else {
  5394. throw new Error("No value provided for input HTTP label: restApiId.");
  5395. }
  5396. let body: any;
  5397. body = JSON.stringify({
  5398. ...(input.name !== undefined && { name: input.name }),
  5399. ...(input.patchOperations !== undefined && {
  5400. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5401. }),
  5402. ...(input.template !== undefined && { template: input.template }),
  5403. ...(input.templateSkipList !== undefined && {
  5404. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5405. }),
  5406. ...(input.title !== undefined && { title: input.title }),
  5407. });
  5408. const { hostname, protocol = "https", port } = await context.endpoint();
  5409. return new __HttpRequest({
  5410. protocol,
  5411. hostname,
  5412. port,
  5413. method: "PATCH",
  5414. headers,
  5415. path: resolvedPath,
  5416. body,
  5417. });
  5418. };
  5419. export const serializeAws_restJson1UpdateRequestValidatorCommand = async (
  5420. input: UpdateRequestValidatorCommandInput,
  5421. context: __SerdeContext
  5422. ): Promise<__HttpRequest> => {
  5423. const headers: any = {
  5424. "Content-Type": "application/json",
  5425. };
  5426. let resolvedPath = "/restapis/{restApiId}/requestvalidators/{requestValidatorId}";
  5427. if (input.restApiId !== undefined) {
  5428. const labelValue: string = input.restApiId;
  5429. if (labelValue.length <= 0) {
  5430. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5431. }
  5432. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5433. } else {
  5434. throw new Error("No value provided for input HTTP label: restApiId.");
  5435. }
  5436. if (input.requestValidatorId !== undefined) {
  5437. const labelValue: string = input.requestValidatorId;
  5438. if (labelValue.length <= 0) {
  5439. throw new Error("Empty value provided for input HTTP label: requestValidatorId.");
  5440. }
  5441. resolvedPath = resolvedPath.replace("{requestValidatorId}", __extendedEncodeURIComponent(labelValue));
  5442. } else {
  5443. throw new Error("No value provided for input HTTP label: requestValidatorId.");
  5444. }
  5445. let body: any;
  5446. body = JSON.stringify({
  5447. ...(input.name !== undefined && { name: input.name }),
  5448. ...(input.patchOperations !== undefined && {
  5449. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5450. }),
  5451. ...(input.template !== undefined && { template: input.template }),
  5452. ...(input.templateSkipList !== undefined && {
  5453. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5454. }),
  5455. ...(input.title !== undefined && { title: input.title }),
  5456. });
  5457. const { hostname, protocol = "https", port } = await context.endpoint();
  5458. return new __HttpRequest({
  5459. protocol,
  5460. hostname,
  5461. port,
  5462. method: "PATCH",
  5463. headers,
  5464. path: resolvedPath,
  5465. body,
  5466. });
  5467. };
  5468. export const serializeAws_restJson1UpdateResourceCommand = async (
  5469. input: UpdateResourceCommandInput,
  5470. context: __SerdeContext
  5471. ): Promise<__HttpRequest> => {
  5472. const headers: any = {
  5473. "Content-Type": "application/json",
  5474. };
  5475. let resolvedPath = "/restapis/{restApiId}/resources/{resourceId}";
  5476. if (input.resourceId !== undefined) {
  5477. const labelValue: string = input.resourceId;
  5478. if (labelValue.length <= 0) {
  5479. throw new Error("Empty value provided for input HTTP label: resourceId.");
  5480. }
  5481. resolvedPath = resolvedPath.replace("{resourceId}", __extendedEncodeURIComponent(labelValue));
  5482. } else {
  5483. throw new Error("No value provided for input HTTP label: resourceId.");
  5484. }
  5485. if (input.restApiId !== undefined) {
  5486. const labelValue: string = input.restApiId;
  5487. if (labelValue.length <= 0) {
  5488. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5489. }
  5490. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5491. } else {
  5492. throw new Error("No value provided for input HTTP label: restApiId.");
  5493. }
  5494. let body: any;
  5495. body = JSON.stringify({
  5496. ...(input.name !== undefined && { name: input.name }),
  5497. ...(input.patchOperations !== undefined && {
  5498. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5499. }),
  5500. ...(input.template !== undefined && { template: input.template }),
  5501. ...(input.templateSkipList !== undefined && {
  5502. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5503. }),
  5504. ...(input.title !== undefined && { title: input.title }),
  5505. });
  5506. const { hostname, protocol = "https", port } = await context.endpoint();
  5507. return new __HttpRequest({
  5508. protocol,
  5509. hostname,
  5510. port,
  5511. method: "PATCH",
  5512. headers,
  5513. path: resolvedPath,
  5514. body,
  5515. });
  5516. };
  5517. export const serializeAws_restJson1UpdateRestApiCommand = async (
  5518. input: UpdateRestApiCommandInput,
  5519. context: __SerdeContext
  5520. ): Promise<__HttpRequest> => {
  5521. const headers: any = {
  5522. "Content-Type": "application/json",
  5523. };
  5524. let resolvedPath = "/restapis/{restApiId}";
  5525. if (input.restApiId !== undefined) {
  5526. const labelValue: string = input.restApiId;
  5527. if (labelValue.length <= 0) {
  5528. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5529. }
  5530. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5531. } else {
  5532. throw new Error("No value provided for input HTTP label: restApiId.");
  5533. }
  5534. let body: any;
  5535. body = JSON.stringify({
  5536. ...(input.name !== undefined && { name: input.name }),
  5537. ...(input.patchOperations !== undefined && {
  5538. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5539. }),
  5540. ...(input.template !== undefined && { template: input.template }),
  5541. ...(input.templateSkipList !== undefined && {
  5542. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5543. }),
  5544. ...(input.title !== undefined && { title: input.title }),
  5545. });
  5546. const { hostname, protocol = "https", port } = await context.endpoint();
  5547. return new __HttpRequest({
  5548. protocol,
  5549. hostname,
  5550. port,
  5551. method: "PATCH",
  5552. headers,
  5553. path: resolvedPath,
  5554. body,
  5555. });
  5556. };
  5557. export const serializeAws_restJson1UpdateStageCommand = async (
  5558. input: UpdateStageCommandInput,
  5559. context: __SerdeContext
  5560. ): Promise<__HttpRequest> => {
  5561. const headers: any = {
  5562. "Content-Type": "application/json",
  5563. };
  5564. let resolvedPath = "/restapis/{restApiId}/stages/{stageName}";
  5565. if (input.stageName !== undefined) {
  5566. const labelValue: string = input.stageName;
  5567. if (labelValue.length <= 0) {
  5568. throw new Error("Empty value provided for input HTTP label: stageName.");
  5569. }
  5570. resolvedPath = resolvedPath.replace("{stageName}", __extendedEncodeURIComponent(labelValue));
  5571. } else {
  5572. throw new Error("No value provided for input HTTP label: stageName.");
  5573. }
  5574. if (input.restApiId !== undefined) {
  5575. const labelValue: string = input.restApiId;
  5576. if (labelValue.length <= 0) {
  5577. throw new Error("Empty value provided for input HTTP label: restApiId.");
  5578. }
  5579. resolvedPath = resolvedPath.replace("{restApiId}", __extendedEncodeURIComponent(labelValue));
  5580. } else {
  5581. throw new Error("No value provided for input HTTP label: restApiId.");
  5582. }
  5583. let body: any;
  5584. body = JSON.stringify({
  5585. ...(input.name !== undefined && { name: input.name }),
  5586. ...(input.patchOperations !== undefined && {
  5587. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5588. }),
  5589. ...(input.template !== undefined && { template: input.template }),
  5590. ...(input.templateSkipList !== undefined && {
  5591. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5592. }),
  5593. ...(input.title !== undefined && { title: input.title }),
  5594. });
  5595. const { hostname, protocol = "https", port } = await context.endpoint();
  5596. return new __HttpRequest({
  5597. protocol,
  5598. hostname,
  5599. port,
  5600. method: "PATCH",
  5601. headers,
  5602. path: resolvedPath,
  5603. body,
  5604. });
  5605. };
  5606. export const serializeAws_restJson1UpdateUsageCommand = async (
  5607. input: UpdateUsageCommandInput,
  5608. context: __SerdeContext
  5609. ): Promise<__HttpRequest> => {
  5610. const headers: any = {
  5611. "Content-Type": "application/json",
  5612. };
  5613. let resolvedPath = "/usageplans/{usagePlanId}/keys/{keyId}/usage";
  5614. if (input.usagePlanId !== undefined) {
  5615. const labelValue: string = input.usagePlanId;
  5616. if (labelValue.length <= 0) {
  5617. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  5618. }
  5619. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  5620. } else {
  5621. throw new Error("No value provided for input HTTP label: usagePlanId.");
  5622. }
  5623. if (input.keyId !== undefined) {
  5624. const labelValue: string = input.keyId;
  5625. if (labelValue.length <= 0) {
  5626. throw new Error("Empty value provided for input HTTP label: keyId.");
  5627. }
  5628. resolvedPath = resolvedPath.replace("{keyId}", __extendedEncodeURIComponent(labelValue));
  5629. } else {
  5630. throw new Error("No value provided for input HTTP label: keyId.");
  5631. }
  5632. let body: any;
  5633. body = JSON.stringify({
  5634. ...(input.name !== undefined && { name: input.name }),
  5635. ...(input.patchOperations !== undefined && {
  5636. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5637. }),
  5638. ...(input.template !== undefined && { template: input.template }),
  5639. ...(input.templateSkipList !== undefined && {
  5640. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5641. }),
  5642. ...(input.title !== undefined && { title: input.title }),
  5643. });
  5644. const { hostname, protocol = "https", port } = await context.endpoint();
  5645. return new __HttpRequest({
  5646. protocol,
  5647. hostname,
  5648. port,
  5649. method: "PATCH",
  5650. headers,
  5651. path: resolvedPath,
  5652. body,
  5653. });
  5654. };
  5655. export const serializeAws_restJson1UpdateUsagePlanCommand = async (
  5656. input: UpdateUsagePlanCommandInput,
  5657. context: __SerdeContext
  5658. ): Promise<__HttpRequest> => {
  5659. const headers: any = {
  5660. "Content-Type": "application/json",
  5661. };
  5662. let resolvedPath = "/usageplans/{usagePlanId}";
  5663. if (input.usagePlanId !== undefined) {
  5664. const labelValue: string = input.usagePlanId;
  5665. if (labelValue.length <= 0) {
  5666. throw new Error("Empty value provided for input HTTP label: usagePlanId.");
  5667. }
  5668. resolvedPath = resolvedPath.replace("{usagePlanId}", __extendedEncodeURIComponent(labelValue));
  5669. } else {
  5670. throw new Error("No value provided for input HTTP label: usagePlanId.");
  5671. }
  5672. let body: any;
  5673. body = JSON.stringify({
  5674. ...(input.name !== undefined && { name: input.name }),
  5675. ...(input.patchOperations !== undefined && {
  5676. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5677. }),
  5678. ...(input.template !== undefined && { template: input.template }),
  5679. ...(input.templateSkipList !== undefined && {
  5680. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5681. }),
  5682. ...(input.title !== undefined && { title: input.title }),
  5683. });
  5684. const { hostname, protocol = "https", port } = await context.endpoint();
  5685. return new __HttpRequest({
  5686. protocol,
  5687. hostname,
  5688. port,
  5689. method: "PATCH",
  5690. headers,
  5691. path: resolvedPath,
  5692. body,
  5693. });
  5694. };
  5695. export const serializeAws_restJson1UpdateVpcLinkCommand = async (
  5696. input: UpdateVpcLinkCommandInput,
  5697. context: __SerdeContext
  5698. ): Promise<__HttpRequest> => {
  5699. const headers: any = {
  5700. "Content-Type": "application/json",
  5701. };
  5702. let resolvedPath = "/vpclinks/{vpcLinkId}";
  5703. if (input.vpcLinkId !== undefined) {
  5704. const labelValue: string = input.vpcLinkId;
  5705. if (labelValue.length <= 0) {
  5706. throw new Error("Empty value provided for input HTTP label: vpcLinkId.");
  5707. }
  5708. resolvedPath = resolvedPath.replace("{vpcLinkId}", __extendedEncodeURIComponent(labelValue));
  5709. } else {
  5710. throw new Error("No value provided for input HTTP label: vpcLinkId.");
  5711. }
  5712. let body: any;
  5713. body = JSON.stringify({
  5714. ...(input.name !== undefined && { name: input.name }),
  5715. ...(input.patchOperations !== undefined && {
  5716. patchOperations: serializeAws_restJson1ListOfPatchOperation(input.patchOperations, context),
  5717. }),
  5718. ...(input.template !== undefined && { template: input.template }),
  5719. ...(input.templateSkipList !== undefined && {
  5720. templateSkipList: serializeAws_restJson1ListOfString(input.templateSkipList, context),
  5721. }),
  5722. ...(input.title !== undefined && { title: input.title }),
  5723. });
  5724. const { hostname, protocol = "https", port } = await context.endpoint();
  5725. return new __HttpRequest({
  5726. protocol,
  5727. hostname,
  5728. port,
  5729. method: "PATCH",
  5730. headers,
  5731. path: resolvedPath,
  5732. body,
  5733. });
  5734. };
  5735. export const deserializeAws_restJson1CreateApiKeyCommand = async (
  5736. output: __HttpResponse,
  5737. context: __SerdeContext
  5738. ): Promise<CreateApiKeyCommandOutput> => {
  5739. if (output.statusCode !== 201 && output.statusCode >= 400) {
  5740. return deserializeAws_restJson1CreateApiKeyCommandError(output, context);
  5741. }
  5742. const contents: CreateApiKeyCommandOutput = {
  5743. $metadata: deserializeMetadata(output),
  5744. createdDate: undefined,
  5745. customerId: undefined,
  5746. description: undefined,
  5747. enabled: undefined,
  5748. id: undefined,
  5749. lastUpdatedDate: undefined,
  5750. name: undefined,
  5751. stageKeys: undefined,
  5752. tags: undefined,
  5753. value: undefined,
  5754. };
  5755. const data: any = await parseBody(output.body, context);
  5756. if (data.createdDate !== undefined && data.createdDate !== null) {
  5757. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  5758. }
  5759. if (data.customerId !== undefined && data.customerId !== null) {
  5760. contents.customerId = data.customerId;
  5761. }
  5762. if (data.description !== undefined && data.description !== null) {
  5763. contents.description = data.description;
  5764. }
  5765. if (data.enabled !== undefined && data.enabled !== null) {
  5766. contents.enabled = data.enabled;
  5767. }
  5768. if (data.id !== undefined && data.id !== null) {
  5769. contents.id = data.id;
  5770. }
  5771. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  5772. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  5773. }
  5774. if (data.name !== undefined && data.name !== null) {
  5775. contents.name = data.name;
  5776. }
  5777. if (data.stageKeys !== undefined && data.stageKeys !== null) {
  5778. contents.stageKeys = deserializeAws_restJson1ListOfString(data.stageKeys, context);
  5779. }
  5780. if (data.tags !== undefined && data.tags !== null) {
  5781. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  5782. }
  5783. if (data.value !== undefined && data.value !== null) {
  5784. contents.value = data.value;
  5785. }
  5786. return Promise.resolve(contents);
  5787. };
  5788. const deserializeAws_restJson1CreateApiKeyCommandError = async (
  5789. output: __HttpResponse,
  5790. context: __SerdeContext
  5791. ): Promise<CreateApiKeyCommandOutput> => {
  5792. const parsedOutput: any = {
  5793. ...output,
  5794. body: await parseBody(output.body, context),
  5795. };
  5796. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  5797. let errorCode: string = "UnknownError";
  5798. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  5799. switch (errorCode) {
  5800. case "BadRequestException":
  5801. case "com.amazonaws.apigateway#BadRequestException":
  5802. response = {
  5803. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  5804. name: errorCode,
  5805. $metadata: deserializeMetadata(output),
  5806. };
  5807. break;
  5808. case "ConflictException":
  5809. case "com.amazonaws.apigateway#ConflictException":
  5810. response = {
  5811. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  5812. name: errorCode,
  5813. $metadata: deserializeMetadata(output),
  5814. };
  5815. break;
  5816. case "LimitExceededException":
  5817. case "com.amazonaws.apigateway#LimitExceededException":
  5818. response = {
  5819. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  5820. name: errorCode,
  5821. $metadata: deserializeMetadata(output),
  5822. };
  5823. break;
  5824. case "NotFoundException":
  5825. case "com.amazonaws.apigateway#NotFoundException":
  5826. response = {
  5827. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  5828. name: errorCode,
  5829. $metadata: deserializeMetadata(output),
  5830. };
  5831. break;
  5832. case "TooManyRequestsException":
  5833. case "com.amazonaws.apigateway#TooManyRequestsException":
  5834. response = {
  5835. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  5836. name: errorCode,
  5837. $metadata: deserializeMetadata(output),
  5838. };
  5839. break;
  5840. case "UnauthorizedException":
  5841. case "com.amazonaws.apigateway#UnauthorizedException":
  5842. response = {
  5843. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  5844. name: errorCode,
  5845. $metadata: deserializeMetadata(output),
  5846. };
  5847. break;
  5848. default:
  5849. const parsedBody = parsedOutput.body;
  5850. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  5851. response = {
  5852. ...parsedBody,
  5853. name: `${errorCode}`,
  5854. message: parsedBody.message || parsedBody.Message || errorCode,
  5855. $fault: "client",
  5856. $metadata: deserializeMetadata(output),
  5857. } as any;
  5858. }
  5859. const message = response.message || response.Message || errorCode;
  5860. response.message = message;
  5861. delete response.Message;
  5862. return Promise.reject(Object.assign(new Error(message), response));
  5863. };
  5864. export const deserializeAws_restJson1CreateAuthorizerCommand = async (
  5865. output: __HttpResponse,
  5866. context: __SerdeContext
  5867. ): Promise<CreateAuthorizerCommandOutput> => {
  5868. if (output.statusCode !== 201 && output.statusCode >= 400) {
  5869. return deserializeAws_restJson1CreateAuthorizerCommandError(output, context);
  5870. }
  5871. const contents: CreateAuthorizerCommandOutput = {
  5872. $metadata: deserializeMetadata(output),
  5873. authType: undefined,
  5874. authorizerCredentials: undefined,
  5875. authorizerResultTtlInSeconds: undefined,
  5876. authorizerUri: undefined,
  5877. id: undefined,
  5878. identitySource: undefined,
  5879. identityValidationExpression: undefined,
  5880. name: undefined,
  5881. providerARNs: undefined,
  5882. type: undefined,
  5883. };
  5884. const data: any = await parseBody(output.body, context);
  5885. if (data.authType !== undefined && data.authType !== null) {
  5886. contents.authType = data.authType;
  5887. }
  5888. if (data.authorizerCredentials !== undefined && data.authorizerCredentials !== null) {
  5889. contents.authorizerCredentials = data.authorizerCredentials;
  5890. }
  5891. if (data.authorizerResultTtlInSeconds !== undefined && data.authorizerResultTtlInSeconds !== null) {
  5892. contents.authorizerResultTtlInSeconds = data.authorizerResultTtlInSeconds;
  5893. }
  5894. if (data.authorizerUri !== undefined && data.authorizerUri !== null) {
  5895. contents.authorizerUri = data.authorizerUri;
  5896. }
  5897. if (data.id !== undefined && data.id !== null) {
  5898. contents.id = data.id;
  5899. }
  5900. if (data.identitySource !== undefined && data.identitySource !== null) {
  5901. contents.identitySource = data.identitySource;
  5902. }
  5903. if (data.identityValidationExpression !== undefined && data.identityValidationExpression !== null) {
  5904. contents.identityValidationExpression = data.identityValidationExpression;
  5905. }
  5906. if (data.name !== undefined && data.name !== null) {
  5907. contents.name = data.name;
  5908. }
  5909. if (data.providerARNs !== undefined && data.providerARNs !== null) {
  5910. contents.providerARNs = deserializeAws_restJson1ListOfARNs(data.providerARNs, context);
  5911. }
  5912. if (data.type !== undefined && data.type !== null) {
  5913. contents.type = data.type;
  5914. }
  5915. return Promise.resolve(contents);
  5916. };
  5917. const deserializeAws_restJson1CreateAuthorizerCommandError = async (
  5918. output: __HttpResponse,
  5919. context: __SerdeContext
  5920. ): Promise<CreateAuthorizerCommandOutput> => {
  5921. const parsedOutput: any = {
  5922. ...output,
  5923. body: await parseBody(output.body, context),
  5924. };
  5925. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  5926. let errorCode: string = "UnknownError";
  5927. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  5928. switch (errorCode) {
  5929. case "BadRequestException":
  5930. case "com.amazonaws.apigateway#BadRequestException":
  5931. response = {
  5932. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  5933. name: errorCode,
  5934. $metadata: deserializeMetadata(output),
  5935. };
  5936. break;
  5937. case "LimitExceededException":
  5938. case "com.amazonaws.apigateway#LimitExceededException":
  5939. response = {
  5940. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  5941. name: errorCode,
  5942. $metadata: deserializeMetadata(output),
  5943. };
  5944. break;
  5945. case "NotFoundException":
  5946. case "com.amazonaws.apigateway#NotFoundException":
  5947. response = {
  5948. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  5949. name: errorCode,
  5950. $metadata: deserializeMetadata(output),
  5951. };
  5952. break;
  5953. case "TooManyRequestsException":
  5954. case "com.amazonaws.apigateway#TooManyRequestsException":
  5955. response = {
  5956. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  5957. name: errorCode,
  5958. $metadata: deserializeMetadata(output),
  5959. };
  5960. break;
  5961. case "UnauthorizedException":
  5962. case "com.amazonaws.apigateway#UnauthorizedException":
  5963. response = {
  5964. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  5965. name: errorCode,
  5966. $metadata: deserializeMetadata(output),
  5967. };
  5968. break;
  5969. default:
  5970. const parsedBody = parsedOutput.body;
  5971. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  5972. response = {
  5973. ...parsedBody,
  5974. name: `${errorCode}`,
  5975. message: parsedBody.message || parsedBody.Message || errorCode,
  5976. $fault: "client",
  5977. $metadata: deserializeMetadata(output),
  5978. } as any;
  5979. }
  5980. const message = response.message || response.Message || errorCode;
  5981. response.message = message;
  5982. delete response.Message;
  5983. return Promise.reject(Object.assign(new Error(message), response));
  5984. };
  5985. export const deserializeAws_restJson1CreateBasePathMappingCommand = async (
  5986. output: __HttpResponse,
  5987. context: __SerdeContext
  5988. ): Promise<CreateBasePathMappingCommandOutput> => {
  5989. if (output.statusCode !== 201 && output.statusCode >= 400) {
  5990. return deserializeAws_restJson1CreateBasePathMappingCommandError(output, context);
  5991. }
  5992. const contents: CreateBasePathMappingCommandOutput = {
  5993. $metadata: deserializeMetadata(output),
  5994. basePath: undefined,
  5995. restApiId: undefined,
  5996. stage: undefined,
  5997. };
  5998. const data: any = await parseBody(output.body, context);
  5999. if (data.basePath !== undefined && data.basePath !== null) {
  6000. contents.basePath = data.basePath;
  6001. }
  6002. if (data.restApiId !== undefined && data.restApiId !== null) {
  6003. contents.restApiId = data.restApiId;
  6004. }
  6005. if (data.stage !== undefined && data.stage !== null) {
  6006. contents.stage = data.stage;
  6007. }
  6008. return Promise.resolve(contents);
  6009. };
  6010. const deserializeAws_restJson1CreateBasePathMappingCommandError = async (
  6011. output: __HttpResponse,
  6012. context: __SerdeContext
  6013. ): Promise<CreateBasePathMappingCommandOutput> => {
  6014. const parsedOutput: any = {
  6015. ...output,
  6016. body: await parseBody(output.body, context),
  6017. };
  6018. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6019. let errorCode: string = "UnknownError";
  6020. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6021. switch (errorCode) {
  6022. case "BadRequestException":
  6023. case "com.amazonaws.apigateway#BadRequestException":
  6024. response = {
  6025. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6026. name: errorCode,
  6027. $metadata: deserializeMetadata(output),
  6028. };
  6029. break;
  6030. case "ConflictException":
  6031. case "com.amazonaws.apigateway#ConflictException":
  6032. response = {
  6033. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6034. name: errorCode,
  6035. $metadata: deserializeMetadata(output),
  6036. };
  6037. break;
  6038. case "NotFoundException":
  6039. case "com.amazonaws.apigateway#NotFoundException":
  6040. response = {
  6041. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6042. name: errorCode,
  6043. $metadata: deserializeMetadata(output),
  6044. };
  6045. break;
  6046. case "TooManyRequestsException":
  6047. case "com.amazonaws.apigateway#TooManyRequestsException":
  6048. response = {
  6049. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6050. name: errorCode,
  6051. $metadata: deserializeMetadata(output),
  6052. };
  6053. break;
  6054. case "UnauthorizedException":
  6055. case "com.amazonaws.apigateway#UnauthorizedException":
  6056. response = {
  6057. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6058. name: errorCode,
  6059. $metadata: deserializeMetadata(output),
  6060. };
  6061. break;
  6062. default:
  6063. const parsedBody = parsedOutput.body;
  6064. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6065. response = {
  6066. ...parsedBody,
  6067. name: `${errorCode}`,
  6068. message: parsedBody.message || parsedBody.Message || errorCode,
  6069. $fault: "client",
  6070. $metadata: deserializeMetadata(output),
  6071. } as any;
  6072. }
  6073. const message = response.message || response.Message || errorCode;
  6074. response.message = message;
  6075. delete response.Message;
  6076. return Promise.reject(Object.assign(new Error(message), response));
  6077. };
  6078. export const deserializeAws_restJson1CreateDeploymentCommand = async (
  6079. output: __HttpResponse,
  6080. context: __SerdeContext
  6081. ): Promise<CreateDeploymentCommandOutput> => {
  6082. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6083. return deserializeAws_restJson1CreateDeploymentCommandError(output, context);
  6084. }
  6085. const contents: CreateDeploymentCommandOutput = {
  6086. $metadata: deserializeMetadata(output),
  6087. apiSummary: undefined,
  6088. createdDate: undefined,
  6089. description: undefined,
  6090. id: undefined,
  6091. };
  6092. const data: any = await parseBody(output.body, context);
  6093. if (data.apiSummary !== undefined && data.apiSummary !== null) {
  6094. contents.apiSummary = deserializeAws_restJson1PathToMapOfMethodSnapshot(data.apiSummary, context);
  6095. }
  6096. if (data.createdDate !== undefined && data.createdDate !== null) {
  6097. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  6098. }
  6099. if (data.description !== undefined && data.description !== null) {
  6100. contents.description = data.description;
  6101. }
  6102. if (data.id !== undefined && data.id !== null) {
  6103. contents.id = data.id;
  6104. }
  6105. return Promise.resolve(contents);
  6106. };
  6107. const deserializeAws_restJson1CreateDeploymentCommandError = async (
  6108. output: __HttpResponse,
  6109. context: __SerdeContext
  6110. ): Promise<CreateDeploymentCommandOutput> => {
  6111. const parsedOutput: any = {
  6112. ...output,
  6113. body: await parseBody(output.body, context),
  6114. };
  6115. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6116. let errorCode: string = "UnknownError";
  6117. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6118. switch (errorCode) {
  6119. case "BadRequestException":
  6120. case "com.amazonaws.apigateway#BadRequestException":
  6121. response = {
  6122. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6123. name: errorCode,
  6124. $metadata: deserializeMetadata(output),
  6125. };
  6126. break;
  6127. case "ConflictException":
  6128. case "com.amazonaws.apigateway#ConflictException":
  6129. response = {
  6130. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6131. name: errorCode,
  6132. $metadata: deserializeMetadata(output),
  6133. };
  6134. break;
  6135. case "LimitExceededException":
  6136. case "com.amazonaws.apigateway#LimitExceededException":
  6137. response = {
  6138. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6139. name: errorCode,
  6140. $metadata: deserializeMetadata(output),
  6141. };
  6142. break;
  6143. case "NotFoundException":
  6144. case "com.amazonaws.apigateway#NotFoundException":
  6145. response = {
  6146. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6147. name: errorCode,
  6148. $metadata: deserializeMetadata(output),
  6149. };
  6150. break;
  6151. case "ServiceUnavailableException":
  6152. case "com.amazonaws.apigateway#ServiceUnavailableException":
  6153. response = {
  6154. ...(await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context)),
  6155. name: errorCode,
  6156. $metadata: deserializeMetadata(output),
  6157. };
  6158. break;
  6159. case "TooManyRequestsException":
  6160. case "com.amazonaws.apigateway#TooManyRequestsException":
  6161. response = {
  6162. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6163. name: errorCode,
  6164. $metadata: deserializeMetadata(output),
  6165. };
  6166. break;
  6167. case "UnauthorizedException":
  6168. case "com.amazonaws.apigateway#UnauthorizedException":
  6169. response = {
  6170. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6171. name: errorCode,
  6172. $metadata: deserializeMetadata(output),
  6173. };
  6174. break;
  6175. default:
  6176. const parsedBody = parsedOutput.body;
  6177. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6178. response = {
  6179. ...parsedBody,
  6180. name: `${errorCode}`,
  6181. message: parsedBody.message || parsedBody.Message || errorCode,
  6182. $fault: "client",
  6183. $metadata: deserializeMetadata(output),
  6184. } as any;
  6185. }
  6186. const message = response.message || response.Message || errorCode;
  6187. response.message = message;
  6188. delete response.Message;
  6189. return Promise.reject(Object.assign(new Error(message), response));
  6190. };
  6191. export const deserializeAws_restJson1CreateDocumentationPartCommand = async (
  6192. output: __HttpResponse,
  6193. context: __SerdeContext
  6194. ): Promise<CreateDocumentationPartCommandOutput> => {
  6195. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6196. return deserializeAws_restJson1CreateDocumentationPartCommandError(output, context);
  6197. }
  6198. const contents: CreateDocumentationPartCommandOutput = {
  6199. $metadata: deserializeMetadata(output),
  6200. id: undefined,
  6201. location: undefined,
  6202. properties: undefined,
  6203. };
  6204. const data: any = await parseBody(output.body, context);
  6205. if (data.id !== undefined && data.id !== null) {
  6206. contents.id = data.id;
  6207. }
  6208. if (data.location !== undefined && data.location !== null) {
  6209. contents.location = deserializeAws_restJson1DocumentationPartLocation(data.location, context);
  6210. }
  6211. if (data.properties !== undefined && data.properties !== null) {
  6212. contents.properties = data.properties;
  6213. }
  6214. return Promise.resolve(contents);
  6215. };
  6216. const deserializeAws_restJson1CreateDocumentationPartCommandError = async (
  6217. output: __HttpResponse,
  6218. context: __SerdeContext
  6219. ): Promise<CreateDocumentationPartCommandOutput> => {
  6220. const parsedOutput: any = {
  6221. ...output,
  6222. body: await parseBody(output.body, context),
  6223. };
  6224. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6225. let errorCode: string = "UnknownError";
  6226. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6227. switch (errorCode) {
  6228. case "BadRequestException":
  6229. case "com.amazonaws.apigateway#BadRequestException":
  6230. response = {
  6231. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6232. name: errorCode,
  6233. $metadata: deserializeMetadata(output),
  6234. };
  6235. break;
  6236. case "ConflictException":
  6237. case "com.amazonaws.apigateway#ConflictException":
  6238. response = {
  6239. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6240. name: errorCode,
  6241. $metadata: deserializeMetadata(output),
  6242. };
  6243. break;
  6244. case "LimitExceededException":
  6245. case "com.amazonaws.apigateway#LimitExceededException":
  6246. response = {
  6247. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6248. name: errorCode,
  6249. $metadata: deserializeMetadata(output),
  6250. };
  6251. break;
  6252. case "NotFoundException":
  6253. case "com.amazonaws.apigateway#NotFoundException":
  6254. response = {
  6255. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6256. name: errorCode,
  6257. $metadata: deserializeMetadata(output),
  6258. };
  6259. break;
  6260. case "TooManyRequestsException":
  6261. case "com.amazonaws.apigateway#TooManyRequestsException":
  6262. response = {
  6263. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6264. name: errorCode,
  6265. $metadata: deserializeMetadata(output),
  6266. };
  6267. break;
  6268. case "UnauthorizedException":
  6269. case "com.amazonaws.apigateway#UnauthorizedException":
  6270. response = {
  6271. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6272. name: errorCode,
  6273. $metadata: deserializeMetadata(output),
  6274. };
  6275. break;
  6276. default:
  6277. const parsedBody = parsedOutput.body;
  6278. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6279. response = {
  6280. ...parsedBody,
  6281. name: `${errorCode}`,
  6282. message: parsedBody.message || parsedBody.Message || errorCode,
  6283. $fault: "client",
  6284. $metadata: deserializeMetadata(output),
  6285. } as any;
  6286. }
  6287. const message = response.message || response.Message || errorCode;
  6288. response.message = message;
  6289. delete response.Message;
  6290. return Promise.reject(Object.assign(new Error(message), response));
  6291. };
  6292. export const deserializeAws_restJson1CreateDocumentationVersionCommand = async (
  6293. output: __HttpResponse,
  6294. context: __SerdeContext
  6295. ): Promise<CreateDocumentationVersionCommandOutput> => {
  6296. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6297. return deserializeAws_restJson1CreateDocumentationVersionCommandError(output, context);
  6298. }
  6299. const contents: CreateDocumentationVersionCommandOutput = {
  6300. $metadata: deserializeMetadata(output),
  6301. createdDate: undefined,
  6302. description: undefined,
  6303. version: undefined,
  6304. };
  6305. const data: any = await parseBody(output.body, context);
  6306. if (data.createdDate !== undefined && data.createdDate !== null) {
  6307. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  6308. }
  6309. if (data.description !== undefined && data.description !== null) {
  6310. contents.description = data.description;
  6311. }
  6312. if (data.version !== undefined && data.version !== null) {
  6313. contents.version = data.version;
  6314. }
  6315. return Promise.resolve(contents);
  6316. };
  6317. const deserializeAws_restJson1CreateDocumentationVersionCommandError = async (
  6318. output: __HttpResponse,
  6319. context: __SerdeContext
  6320. ): Promise<CreateDocumentationVersionCommandOutput> => {
  6321. const parsedOutput: any = {
  6322. ...output,
  6323. body: await parseBody(output.body, context),
  6324. };
  6325. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6326. let errorCode: string = "UnknownError";
  6327. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6328. switch (errorCode) {
  6329. case "BadRequestException":
  6330. case "com.amazonaws.apigateway#BadRequestException":
  6331. response = {
  6332. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6333. name: errorCode,
  6334. $metadata: deserializeMetadata(output),
  6335. };
  6336. break;
  6337. case "ConflictException":
  6338. case "com.amazonaws.apigateway#ConflictException":
  6339. response = {
  6340. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6341. name: errorCode,
  6342. $metadata: deserializeMetadata(output),
  6343. };
  6344. break;
  6345. case "LimitExceededException":
  6346. case "com.amazonaws.apigateway#LimitExceededException":
  6347. response = {
  6348. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6349. name: errorCode,
  6350. $metadata: deserializeMetadata(output),
  6351. };
  6352. break;
  6353. case "NotFoundException":
  6354. case "com.amazonaws.apigateway#NotFoundException":
  6355. response = {
  6356. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6357. name: errorCode,
  6358. $metadata: deserializeMetadata(output),
  6359. };
  6360. break;
  6361. case "TooManyRequestsException":
  6362. case "com.amazonaws.apigateway#TooManyRequestsException":
  6363. response = {
  6364. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6365. name: errorCode,
  6366. $metadata: deserializeMetadata(output),
  6367. };
  6368. break;
  6369. case "UnauthorizedException":
  6370. case "com.amazonaws.apigateway#UnauthorizedException":
  6371. response = {
  6372. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6373. name: errorCode,
  6374. $metadata: deserializeMetadata(output),
  6375. };
  6376. break;
  6377. default:
  6378. const parsedBody = parsedOutput.body;
  6379. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6380. response = {
  6381. ...parsedBody,
  6382. name: `${errorCode}`,
  6383. message: parsedBody.message || parsedBody.Message || errorCode,
  6384. $fault: "client",
  6385. $metadata: deserializeMetadata(output),
  6386. } as any;
  6387. }
  6388. const message = response.message || response.Message || errorCode;
  6389. response.message = message;
  6390. delete response.Message;
  6391. return Promise.reject(Object.assign(new Error(message), response));
  6392. };
  6393. export const deserializeAws_restJson1CreateDomainNameCommand = async (
  6394. output: __HttpResponse,
  6395. context: __SerdeContext
  6396. ): Promise<CreateDomainNameCommandOutput> => {
  6397. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6398. return deserializeAws_restJson1CreateDomainNameCommandError(output, context);
  6399. }
  6400. const contents: CreateDomainNameCommandOutput = {
  6401. $metadata: deserializeMetadata(output),
  6402. certificateArn: undefined,
  6403. certificateName: undefined,
  6404. certificateUploadDate: undefined,
  6405. distributionDomainName: undefined,
  6406. distributionHostedZoneId: undefined,
  6407. domainName: undefined,
  6408. domainNameStatus: undefined,
  6409. domainNameStatusMessage: undefined,
  6410. endpointConfiguration: undefined,
  6411. regionalCertificateArn: undefined,
  6412. regionalCertificateName: undefined,
  6413. regionalDomainName: undefined,
  6414. regionalHostedZoneId: undefined,
  6415. securityPolicy: undefined,
  6416. tags: undefined,
  6417. };
  6418. const data: any = await parseBody(output.body, context);
  6419. if (data.certificateArn !== undefined && data.certificateArn !== null) {
  6420. contents.certificateArn = data.certificateArn;
  6421. }
  6422. if (data.certificateName !== undefined && data.certificateName !== null) {
  6423. contents.certificateName = data.certificateName;
  6424. }
  6425. if (data.certificateUploadDate !== undefined && data.certificateUploadDate !== null) {
  6426. contents.certificateUploadDate = new Date(Math.round(data.certificateUploadDate * 1000));
  6427. }
  6428. if (data.distributionDomainName !== undefined && data.distributionDomainName !== null) {
  6429. contents.distributionDomainName = data.distributionDomainName;
  6430. }
  6431. if (data.distributionHostedZoneId !== undefined && data.distributionHostedZoneId !== null) {
  6432. contents.distributionHostedZoneId = data.distributionHostedZoneId;
  6433. }
  6434. if (data.domainName !== undefined && data.domainName !== null) {
  6435. contents.domainName = data.domainName;
  6436. }
  6437. if (data.domainNameStatus !== undefined && data.domainNameStatus !== null) {
  6438. contents.domainNameStatus = data.domainNameStatus;
  6439. }
  6440. if (data.domainNameStatusMessage !== undefined && data.domainNameStatusMessage !== null) {
  6441. contents.domainNameStatusMessage = data.domainNameStatusMessage;
  6442. }
  6443. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  6444. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  6445. }
  6446. if (data.regionalCertificateArn !== undefined && data.regionalCertificateArn !== null) {
  6447. contents.regionalCertificateArn = data.regionalCertificateArn;
  6448. }
  6449. if (data.regionalCertificateName !== undefined && data.regionalCertificateName !== null) {
  6450. contents.regionalCertificateName = data.regionalCertificateName;
  6451. }
  6452. if (data.regionalDomainName !== undefined && data.regionalDomainName !== null) {
  6453. contents.regionalDomainName = data.regionalDomainName;
  6454. }
  6455. if (data.regionalHostedZoneId !== undefined && data.regionalHostedZoneId !== null) {
  6456. contents.regionalHostedZoneId = data.regionalHostedZoneId;
  6457. }
  6458. if (data.securityPolicy !== undefined && data.securityPolicy !== null) {
  6459. contents.securityPolicy = data.securityPolicy;
  6460. }
  6461. if (data.tags !== undefined && data.tags !== null) {
  6462. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  6463. }
  6464. return Promise.resolve(contents);
  6465. };
  6466. const deserializeAws_restJson1CreateDomainNameCommandError = async (
  6467. output: __HttpResponse,
  6468. context: __SerdeContext
  6469. ): Promise<CreateDomainNameCommandOutput> => {
  6470. const parsedOutput: any = {
  6471. ...output,
  6472. body: await parseBody(output.body, context),
  6473. };
  6474. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6475. let errorCode: string = "UnknownError";
  6476. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6477. switch (errorCode) {
  6478. case "BadRequestException":
  6479. case "com.amazonaws.apigateway#BadRequestException":
  6480. response = {
  6481. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6482. name: errorCode,
  6483. $metadata: deserializeMetadata(output),
  6484. };
  6485. break;
  6486. case "ConflictException":
  6487. case "com.amazonaws.apigateway#ConflictException":
  6488. response = {
  6489. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6490. name: errorCode,
  6491. $metadata: deserializeMetadata(output),
  6492. };
  6493. break;
  6494. case "TooManyRequestsException":
  6495. case "com.amazonaws.apigateway#TooManyRequestsException":
  6496. response = {
  6497. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6498. name: errorCode,
  6499. $metadata: deserializeMetadata(output),
  6500. };
  6501. break;
  6502. case "UnauthorizedException":
  6503. case "com.amazonaws.apigateway#UnauthorizedException":
  6504. response = {
  6505. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6506. name: errorCode,
  6507. $metadata: deserializeMetadata(output),
  6508. };
  6509. break;
  6510. default:
  6511. const parsedBody = parsedOutput.body;
  6512. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6513. response = {
  6514. ...parsedBody,
  6515. name: `${errorCode}`,
  6516. message: parsedBody.message || parsedBody.Message || errorCode,
  6517. $fault: "client",
  6518. $metadata: deserializeMetadata(output),
  6519. } as any;
  6520. }
  6521. const message = response.message || response.Message || errorCode;
  6522. response.message = message;
  6523. delete response.Message;
  6524. return Promise.reject(Object.assign(new Error(message), response));
  6525. };
  6526. export const deserializeAws_restJson1CreateModelCommand = async (
  6527. output: __HttpResponse,
  6528. context: __SerdeContext
  6529. ): Promise<CreateModelCommandOutput> => {
  6530. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6531. return deserializeAws_restJson1CreateModelCommandError(output, context);
  6532. }
  6533. const contents: CreateModelCommandOutput = {
  6534. $metadata: deserializeMetadata(output),
  6535. contentType: undefined,
  6536. description: undefined,
  6537. id: undefined,
  6538. name: undefined,
  6539. schema: undefined,
  6540. };
  6541. const data: any = await parseBody(output.body, context);
  6542. if (data.contentType !== undefined && data.contentType !== null) {
  6543. contents.contentType = data.contentType;
  6544. }
  6545. if (data.description !== undefined && data.description !== null) {
  6546. contents.description = data.description;
  6547. }
  6548. if (data.id !== undefined && data.id !== null) {
  6549. contents.id = data.id;
  6550. }
  6551. if (data.name !== undefined && data.name !== null) {
  6552. contents.name = data.name;
  6553. }
  6554. if (data.schema !== undefined && data.schema !== null) {
  6555. contents.schema = data.schema;
  6556. }
  6557. return Promise.resolve(contents);
  6558. };
  6559. const deserializeAws_restJson1CreateModelCommandError = async (
  6560. output: __HttpResponse,
  6561. context: __SerdeContext
  6562. ): Promise<CreateModelCommandOutput> => {
  6563. const parsedOutput: any = {
  6564. ...output,
  6565. body: await parseBody(output.body, context),
  6566. };
  6567. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6568. let errorCode: string = "UnknownError";
  6569. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6570. switch (errorCode) {
  6571. case "BadRequestException":
  6572. case "com.amazonaws.apigateway#BadRequestException":
  6573. response = {
  6574. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6575. name: errorCode,
  6576. $metadata: deserializeMetadata(output),
  6577. };
  6578. break;
  6579. case "ConflictException":
  6580. case "com.amazonaws.apigateway#ConflictException":
  6581. response = {
  6582. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6583. name: errorCode,
  6584. $metadata: deserializeMetadata(output),
  6585. };
  6586. break;
  6587. case "LimitExceededException":
  6588. case "com.amazonaws.apigateway#LimitExceededException":
  6589. response = {
  6590. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6591. name: errorCode,
  6592. $metadata: deserializeMetadata(output),
  6593. };
  6594. break;
  6595. case "NotFoundException":
  6596. case "com.amazonaws.apigateway#NotFoundException":
  6597. response = {
  6598. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6599. name: errorCode,
  6600. $metadata: deserializeMetadata(output),
  6601. };
  6602. break;
  6603. case "TooManyRequestsException":
  6604. case "com.amazonaws.apigateway#TooManyRequestsException":
  6605. response = {
  6606. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6607. name: errorCode,
  6608. $metadata: deserializeMetadata(output),
  6609. };
  6610. break;
  6611. case "UnauthorizedException":
  6612. case "com.amazonaws.apigateway#UnauthorizedException":
  6613. response = {
  6614. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6615. name: errorCode,
  6616. $metadata: deserializeMetadata(output),
  6617. };
  6618. break;
  6619. default:
  6620. const parsedBody = parsedOutput.body;
  6621. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6622. response = {
  6623. ...parsedBody,
  6624. name: `${errorCode}`,
  6625. message: parsedBody.message || parsedBody.Message || errorCode,
  6626. $fault: "client",
  6627. $metadata: deserializeMetadata(output),
  6628. } as any;
  6629. }
  6630. const message = response.message || response.Message || errorCode;
  6631. response.message = message;
  6632. delete response.Message;
  6633. return Promise.reject(Object.assign(new Error(message), response));
  6634. };
  6635. export const deserializeAws_restJson1CreateRequestValidatorCommand = async (
  6636. output: __HttpResponse,
  6637. context: __SerdeContext
  6638. ): Promise<CreateRequestValidatorCommandOutput> => {
  6639. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6640. return deserializeAws_restJson1CreateRequestValidatorCommandError(output, context);
  6641. }
  6642. const contents: CreateRequestValidatorCommandOutput = {
  6643. $metadata: deserializeMetadata(output),
  6644. id: undefined,
  6645. name: undefined,
  6646. validateRequestBody: undefined,
  6647. validateRequestParameters: undefined,
  6648. };
  6649. const data: any = await parseBody(output.body, context);
  6650. if (data.id !== undefined && data.id !== null) {
  6651. contents.id = data.id;
  6652. }
  6653. if (data.name !== undefined && data.name !== null) {
  6654. contents.name = data.name;
  6655. }
  6656. if (data.validateRequestBody !== undefined && data.validateRequestBody !== null) {
  6657. contents.validateRequestBody = data.validateRequestBody;
  6658. }
  6659. if (data.validateRequestParameters !== undefined && data.validateRequestParameters !== null) {
  6660. contents.validateRequestParameters = data.validateRequestParameters;
  6661. }
  6662. return Promise.resolve(contents);
  6663. };
  6664. const deserializeAws_restJson1CreateRequestValidatorCommandError = async (
  6665. output: __HttpResponse,
  6666. context: __SerdeContext
  6667. ): Promise<CreateRequestValidatorCommandOutput> => {
  6668. const parsedOutput: any = {
  6669. ...output,
  6670. body: await parseBody(output.body, context),
  6671. };
  6672. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6673. let errorCode: string = "UnknownError";
  6674. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6675. switch (errorCode) {
  6676. case "BadRequestException":
  6677. case "com.amazonaws.apigateway#BadRequestException":
  6678. response = {
  6679. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6680. name: errorCode,
  6681. $metadata: deserializeMetadata(output),
  6682. };
  6683. break;
  6684. case "LimitExceededException":
  6685. case "com.amazonaws.apigateway#LimitExceededException":
  6686. response = {
  6687. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6688. name: errorCode,
  6689. $metadata: deserializeMetadata(output),
  6690. };
  6691. break;
  6692. case "NotFoundException":
  6693. case "com.amazonaws.apigateway#NotFoundException":
  6694. response = {
  6695. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6696. name: errorCode,
  6697. $metadata: deserializeMetadata(output),
  6698. };
  6699. break;
  6700. case "TooManyRequestsException":
  6701. case "com.amazonaws.apigateway#TooManyRequestsException":
  6702. response = {
  6703. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6704. name: errorCode,
  6705. $metadata: deserializeMetadata(output),
  6706. };
  6707. break;
  6708. case "UnauthorizedException":
  6709. case "com.amazonaws.apigateway#UnauthorizedException":
  6710. response = {
  6711. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6712. name: errorCode,
  6713. $metadata: deserializeMetadata(output),
  6714. };
  6715. break;
  6716. default:
  6717. const parsedBody = parsedOutput.body;
  6718. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6719. response = {
  6720. ...parsedBody,
  6721. name: `${errorCode}`,
  6722. message: parsedBody.message || parsedBody.Message || errorCode,
  6723. $fault: "client",
  6724. $metadata: deserializeMetadata(output),
  6725. } as any;
  6726. }
  6727. const message = response.message || response.Message || errorCode;
  6728. response.message = message;
  6729. delete response.Message;
  6730. return Promise.reject(Object.assign(new Error(message), response));
  6731. };
  6732. export const deserializeAws_restJson1CreateResourceCommand = async (
  6733. output: __HttpResponse,
  6734. context: __SerdeContext
  6735. ): Promise<CreateResourceCommandOutput> => {
  6736. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6737. return deserializeAws_restJson1CreateResourceCommandError(output, context);
  6738. }
  6739. const contents: CreateResourceCommandOutput = {
  6740. $metadata: deserializeMetadata(output),
  6741. id: undefined,
  6742. parentId: undefined,
  6743. path: undefined,
  6744. pathPart: undefined,
  6745. resourceMethods: undefined,
  6746. };
  6747. const data: any = await parseBody(output.body, context);
  6748. if (data.id !== undefined && data.id !== null) {
  6749. contents.id = data.id;
  6750. }
  6751. if (data.parentId !== undefined && data.parentId !== null) {
  6752. contents.parentId = data.parentId;
  6753. }
  6754. if (data.path !== undefined && data.path !== null) {
  6755. contents.path = data.path;
  6756. }
  6757. if (data.pathPart !== undefined && data.pathPart !== null) {
  6758. contents.pathPart = data.pathPart;
  6759. }
  6760. if (data.resourceMethods !== undefined && data.resourceMethods !== null) {
  6761. contents.resourceMethods = deserializeAws_restJson1MapOfMethod(data.resourceMethods, context);
  6762. }
  6763. return Promise.resolve(contents);
  6764. };
  6765. const deserializeAws_restJson1CreateResourceCommandError = async (
  6766. output: __HttpResponse,
  6767. context: __SerdeContext
  6768. ): Promise<CreateResourceCommandOutput> => {
  6769. const parsedOutput: any = {
  6770. ...output,
  6771. body: await parseBody(output.body, context),
  6772. };
  6773. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6774. let errorCode: string = "UnknownError";
  6775. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6776. switch (errorCode) {
  6777. case "BadRequestException":
  6778. case "com.amazonaws.apigateway#BadRequestException":
  6779. response = {
  6780. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6781. name: errorCode,
  6782. $metadata: deserializeMetadata(output),
  6783. };
  6784. break;
  6785. case "ConflictException":
  6786. case "com.amazonaws.apigateway#ConflictException":
  6787. response = {
  6788. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  6789. name: errorCode,
  6790. $metadata: deserializeMetadata(output),
  6791. };
  6792. break;
  6793. case "LimitExceededException":
  6794. case "com.amazonaws.apigateway#LimitExceededException":
  6795. response = {
  6796. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6797. name: errorCode,
  6798. $metadata: deserializeMetadata(output),
  6799. };
  6800. break;
  6801. case "NotFoundException":
  6802. case "com.amazonaws.apigateway#NotFoundException":
  6803. response = {
  6804. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  6805. name: errorCode,
  6806. $metadata: deserializeMetadata(output),
  6807. };
  6808. break;
  6809. case "TooManyRequestsException":
  6810. case "com.amazonaws.apigateway#TooManyRequestsException":
  6811. response = {
  6812. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6813. name: errorCode,
  6814. $metadata: deserializeMetadata(output),
  6815. };
  6816. break;
  6817. case "UnauthorizedException":
  6818. case "com.amazonaws.apigateway#UnauthorizedException":
  6819. response = {
  6820. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6821. name: errorCode,
  6822. $metadata: deserializeMetadata(output),
  6823. };
  6824. break;
  6825. default:
  6826. const parsedBody = parsedOutput.body;
  6827. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6828. response = {
  6829. ...parsedBody,
  6830. name: `${errorCode}`,
  6831. message: parsedBody.message || parsedBody.Message || errorCode,
  6832. $fault: "client",
  6833. $metadata: deserializeMetadata(output),
  6834. } as any;
  6835. }
  6836. const message = response.message || response.Message || errorCode;
  6837. response.message = message;
  6838. delete response.Message;
  6839. return Promise.reject(Object.assign(new Error(message), response));
  6840. };
  6841. export const deserializeAws_restJson1CreateRestApiCommand = async (
  6842. output: __HttpResponse,
  6843. context: __SerdeContext
  6844. ): Promise<CreateRestApiCommandOutput> => {
  6845. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6846. return deserializeAws_restJson1CreateRestApiCommandError(output, context);
  6847. }
  6848. const contents: CreateRestApiCommandOutput = {
  6849. $metadata: deserializeMetadata(output),
  6850. apiKeySource: undefined,
  6851. binaryMediaTypes: undefined,
  6852. createdDate: undefined,
  6853. description: undefined,
  6854. endpointConfiguration: undefined,
  6855. id: undefined,
  6856. minimumCompressionSize: undefined,
  6857. name: undefined,
  6858. policy: undefined,
  6859. tags: undefined,
  6860. version: undefined,
  6861. warnings: undefined,
  6862. };
  6863. const data: any = await parseBody(output.body, context);
  6864. if (data.apiKeySource !== undefined && data.apiKeySource !== null) {
  6865. contents.apiKeySource = data.apiKeySource;
  6866. }
  6867. if (data.binaryMediaTypes !== undefined && data.binaryMediaTypes !== null) {
  6868. contents.binaryMediaTypes = deserializeAws_restJson1ListOfString(data.binaryMediaTypes, context);
  6869. }
  6870. if (data.createdDate !== undefined && data.createdDate !== null) {
  6871. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  6872. }
  6873. if (data.description !== undefined && data.description !== null) {
  6874. contents.description = data.description;
  6875. }
  6876. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  6877. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  6878. }
  6879. if (data.id !== undefined && data.id !== null) {
  6880. contents.id = data.id;
  6881. }
  6882. if (data.minimumCompressionSize !== undefined && data.minimumCompressionSize !== null) {
  6883. contents.minimumCompressionSize = data.minimumCompressionSize;
  6884. }
  6885. if (data.name !== undefined && data.name !== null) {
  6886. contents.name = data.name;
  6887. }
  6888. if (data.policy !== undefined && data.policy !== null) {
  6889. contents.policy = data.policy;
  6890. }
  6891. if (data.tags !== undefined && data.tags !== null) {
  6892. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  6893. }
  6894. if (data.version !== undefined && data.version !== null) {
  6895. contents.version = data.version;
  6896. }
  6897. if (data.warnings !== undefined && data.warnings !== null) {
  6898. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  6899. }
  6900. return Promise.resolve(contents);
  6901. };
  6902. const deserializeAws_restJson1CreateRestApiCommandError = async (
  6903. output: __HttpResponse,
  6904. context: __SerdeContext
  6905. ): Promise<CreateRestApiCommandOutput> => {
  6906. const parsedOutput: any = {
  6907. ...output,
  6908. body: await parseBody(output.body, context),
  6909. };
  6910. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  6911. let errorCode: string = "UnknownError";
  6912. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  6913. switch (errorCode) {
  6914. case "BadRequestException":
  6915. case "com.amazonaws.apigateway#BadRequestException":
  6916. response = {
  6917. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  6918. name: errorCode,
  6919. $metadata: deserializeMetadata(output),
  6920. };
  6921. break;
  6922. case "LimitExceededException":
  6923. case "com.amazonaws.apigateway#LimitExceededException":
  6924. response = {
  6925. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  6926. name: errorCode,
  6927. $metadata: deserializeMetadata(output),
  6928. };
  6929. break;
  6930. case "TooManyRequestsException":
  6931. case "com.amazonaws.apigateway#TooManyRequestsException":
  6932. response = {
  6933. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  6934. name: errorCode,
  6935. $metadata: deserializeMetadata(output),
  6936. };
  6937. break;
  6938. case "UnauthorizedException":
  6939. case "com.amazonaws.apigateway#UnauthorizedException":
  6940. response = {
  6941. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  6942. name: errorCode,
  6943. $metadata: deserializeMetadata(output),
  6944. };
  6945. break;
  6946. default:
  6947. const parsedBody = parsedOutput.body;
  6948. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  6949. response = {
  6950. ...parsedBody,
  6951. name: `${errorCode}`,
  6952. message: parsedBody.message || parsedBody.Message || errorCode,
  6953. $fault: "client",
  6954. $metadata: deserializeMetadata(output),
  6955. } as any;
  6956. }
  6957. const message = response.message || response.Message || errorCode;
  6958. response.message = message;
  6959. delete response.Message;
  6960. return Promise.reject(Object.assign(new Error(message), response));
  6961. };
  6962. export const deserializeAws_restJson1CreateStageCommand = async (
  6963. output: __HttpResponse,
  6964. context: __SerdeContext
  6965. ): Promise<CreateStageCommandOutput> => {
  6966. if (output.statusCode !== 201 && output.statusCode >= 400) {
  6967. return deserializeAws_restJson1CreateStageCommandError(output, context);
  6968. }
  6969. const contents: CreateStageCommandOutput = {
  6970. $metadata: deserializeMetadata(output),
  6971. accessLogSettings: undefined,
  6972. cacheClusterEnabled: undefined,
  6973. cacheClusterSize: undefined,
  6974. cacheClusterStatus: undefined,
  6975. canarySettings: undefined,
  6976. clientCertificateId: undefined,
  6977. createdDate: undefined,
  6978. deploymentId: undefined,
  6979. description: undefined,
  6980. documentationVersion: undefined,
  6981. lastUpdatedDate: undefined,
  6982. methodSettings: undefined,
  6983. stageName: undefined,
  6984. tags: undefined,
  6985. tracingEnabled: undefined,
  6986. variables: undefined,
  6987. webAclArn: undefined,
  6988. };
  6989. const data: any = await parseBody(output.body, context);
  6990. if (data.accessLogSettings !== undefined && data.accessLogSettings !== null) {
  6991. contents.accessLogSettings = deserializeAws_restJson1AccessLogSettings(data.accessLogSettings, context);
  6992. }
  6993. if (data.cacheClusterEnabled !== undefined && data.cacheClusterEnabled !== null) {
  6994. contents.cacheClusterEnabled = data.cacheClusterEnabled;
  6995. }
  6996. if (data.cacheClusterSize !== undefined && data.cacheClusterSize !== null) {
  6997. contents.cacheClusterSize = data.cacheClusterSize;
  6998. }
  6999. if (data.cacheClusterStatus !== undefined && data.cacheClusterStatus !== null) {
  7000. contents.cacheClusterStatus = data.cacheClusterStatus;
  7001. }
  7002. if (data.canarySettings !== undefined && data.canarySettings !== null) {
  7003. contents.canarySettings = deserializeAws_restJson1CanarySettings(data.canarySettings, context);
  7004. }
  7005. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  7006. contents.clientCertificateId = data.clientCertificateId;
  7007. }
  7008. if (data.createdDate !== undefined && data.createdDate !== null) {
  7009. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  7010. }
  7011. if (data.deploymentId !== undefined && data.deploymentId !== null) {
  7012. contents.deploymentId = data.deploymentId;
  7013. }
  7014. if (data.description !== undefined && data.description !== null) {
  7015. contents.description = data.description;
  7016. }
  7017. if (data.documentationVersion !== undefined && data.documentationVersion !== null) {
  7018. contents.documentationVersion = data.documentationVersion;
  7019. }
  7020. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  7021. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  7022. }
  7023. if (data.methodSettings !== undefined && data.methodSettings !== null) {
  7024. contents.methodSettings = deserializeAws_restJson1MapOfMethodSettings(data.methodSettings, context);
  7025. }
  7026. if (data.stageName !== undefined && data.stageName !== null) {
  7027. contents.stageName = data.stageName;
  7028. }
  7029. if (data.tags !== undefined && data.tags !== null) {
  7030. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  7031. }
  7032. if (data.tracingEnabled !== undefined && data.tracingEnabled !== null) {
  7033. contents.tracingEnabled = data.tracingEnabled;
  7034. }
  7035. if (data.variables !== undefined && data.variables !== null) {
  7036. contents.variables = deserializeAws_restJson1MapOfStringToString(data.variables, context);
  7037. }
  7038. if (data.webAclArn !== undefined && data.webAclArn !== null) {
  7039. contents.webAclArn = data.webAclArn;
  7040. }
  7041. return Promise.resolve(contents);
  7042. };
  7043. const deserializeAws_restJson1CreateStageCommandError = async (
  7044. output: __HttpResponse,
  7045. context: __SerdeContext
  7046. ): Promise<CreateStageCommandOutput> => {
  7047. const parsedOutput: any = {
  7048. ...output,
  7049. body: await parseBody(output.body, context),
  7050. };
  7051. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7052. let errorCode: string = "UnknownError";
  7053. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7054. switch (errorCode) {
  7055. case "BadRequestException":
  7056. case "com.amazonaws.apigateway#BadRequestException":
  7057. response = {
  7058. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7059. name: errorCode,
  7060. $metadata: deserializeMetadata(output),
  7061. };
  7062. break;
  7063. case "ConflictException":
  7064. case "com.amazonaws.apigateway#ConflictException":
  7065. response = {
  7066. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7067. name: errorCode,
  7068. $metadata: deserializeMetadata(output),
  7069. };
  7070. break;
  7071. case "LimitExceededException":
  7072. case "com.amazonaws.apigateway#LimitExceededException":
  7073. response = {
  7074. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  7075. name: errorCode,
  7076. $metadata: deserializeMetadata(output),
  7077. };
  7078. break;
  7079. case "NotFoundException":
  7080. case "com.amazonaws.apigateway#NotFoundException":
  7081. response = {
  7082. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7083. name: errorCode,
  7084. $metadata: deserializeMetadata(output),
  7085. };
  7086. break;
  7087. case "TooManyRequestsException":
  7088. case "com.amazonaws.apigateway#TooManyRequestsException":
  7089. response = {
  7090. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7091. name: errorCode,
  7092. $metadata: deserializeMetadata(output),
  7093. };
  7094. break;
  7095. case "UnauthorizedException":
  7096. case "com.amazonaws.apigateway#UnauthorizedException":
  7097. response = {
  7098. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7099. name: errorCode,
  7100. $metadata: deserializeMetadata(output),
  7101. };
  7102. break;
  7103. default:
  7104. const parsedBody = parsedOutput.body;
  7105. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7106. response = {
  7107. ...parsedBody,
  7108. name: `${errorCode}`,
  7109. message: parsedBody.message || parsedBody.Message || errorCode,
  7110. $fault: "client",
  7111. $metadata: deserializeMetadata(output),
  7112. } as any;
  7113. }
  7114. const message = response.message || response.Message || errorCode;
  7115. response.message = message;
  7116. delete response.Message;
  7117. return Promise.reject(Object.assign(new Error(message), response));
  7118. };
  7119. export const deserializeAws_restJson1CreateUsagePlanCommand = async (
  7120. output: __HttpResponse,
  7121. context: __SerdeContext
  7122. ): Promise<CreateUsagePlanCommandOutput> => {
  7123. if (output.statusCode !== 201 && output.statusCode >= 400) {
  7124. return deserializeAws_restJson1CreateUsagePlanCommandError(output, context);
  7125. }
  7126. const contents: CreateUsagePlanCommandOutput = {
  7127. $metadata: deserializeMetadata(output),
  7128. apiStages: undefined,
  7129. description: undefined,
  7130. id: undefined,
  7131. name: undefined,
  7132. productCode: undefined,
  7133. quota: undefined,
  7134. tags: undefined,
  7135. throttle: undefined,
  7136. };
  7137. const data: any = await parseBody(output.body, context);
  7138. if (data.apiStages !== undefined && data.apiStages !== null) {
  7139. contents.apiStages = deserializeAws_restJson1ListOfApiStage(data.apiStages, context);
  7140. }
  7141. if (data.description !== undefined && data.description !== null) {
  7142. contents.description = data.description;
  7143. }
  7144. if (data.id !== undefined && data.id !== null) {
  7145. contents.id = data.id;
  7146. }
  7147. if (data.name !== undefined && data.name !== null) {
  7148. contents.name = data.name;
  7149. }
  7150. if (data.productCode !== undefined && data.productCode !== null) {
  7151. contents.productCode = data.productCode;
  7152. }
  7153. if (data.quota !== undefined && data.quota !== null) {
  7154. contents.quota = deserializeAws_restJson1QuotaSettings(data.quota, context);
  7155. }
  7156. if (data.tags !== undefined && data.tags !== null) {
  7157. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  7158. }
  7159. if (data.throttle !== undefined && data.throttle !== null) {
  7160. contents.throttle = deserializeAws_restJson1ThrottleSettings(data.throttle, context);
  7161. }
  7162. return Promise.resolve(contents);
  7163. };
  7164. const deserializeAws_restJson1CreateUsagePlanCommandError = async (
  7165. output: __HttpResponse,
  7166. context: __SerdeContext
  7167. ): Promise<CreateUsagePlanCommandOutput> => {
  7168. const parsedOutput: any = {
  7169. ...output,
  7170. body: await parseBody(output.body, context),
  7171. };
  7172. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7173. let errorCode: string = "UnknownError";
  7174. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7175. switch (errorCode) {
  7176. case "BadRequestException":
  7177. case "com.amazonaws.apigateway#BadRequestException":
  7178. response = {
  7179. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7180. name: errorCode,
  7181. $metadata: deserializeMetadata(output),
  7182. };
  7183. break;
  7184. case "ConflictException":
  7185. case "com.amazonaws.apigateway#ConflictException":
  7186. response = {
  7187. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7188. name: errorCode,
  7189. $metadata: deserializeMetadata(output),
  7190. };
  7191. break;
  7192. case "LimitExceededException":
  7193. case "com.amazonaws.apigateway#LimitExceededException":
  7194. response = {
  7195. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  7196. name: errorCode,
  7197. $metadata: deserializeMetadata(output),
  7198. };
  7199. break;
  7200. case "NotFoundException":
  7201. case "com.amazonaws.apigateway#NotFoundException":
  7202. response = {
  7203. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7204. name: errorCode,
  7205. $metadata: deserializeMetadata(output),
  7206. };
  7207. break;
  7208. case "TooManyRequestsException":
  7209. case "com.amazonaws.apigateway#TooManyRequestsException":
  7210. response = {
  7211. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7212. name: errorCode,
  7213. $metadata: deserializeMetadata(output),
  7214. };
  7215. break;
  7216. case "UnauthorizedException":
  7217. case "com.amazonaws.apigateway#UnauthorizedException":
  7218. response = {
  7219. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7220. name: errorCode,
  7221. $metadata: deserializeMetadata(output),
  7222. };
  7223. break;
  7224. default:
  7225. const parsedBody = parsedOutput.body;
  7226. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7227. response = {
  7228. ...parsedBody,
  7229. name: `${errorCode}`,
  7230. message: parsedBody.message || parsedBody.Message || errorCode,
  7231. $fault: "client",
  7232. $metadata: deserializeMetadata(output),
  7233. } as any;
  7234. }
  7235. const message = response.message || response.Message || errorCode;
  7236. response.message = message;
  7237. delete response.Message;
  7238. return Promise.reject(Object.assign(new Error(message), response));
  7239. };
  7240. export const deserializeAws_restJson1CreateUsagePlanKeyCommand = async (
  7241. output: __HttpResponse,
  7242. context: __SerdeContext
  7243. ): Promise<CreateUsagePlanKeyCommandOutput> => {
  7244. if (output.statusCode !== 201 && output.statusCode >= 400) {
  7245. return deserializeAws_restJson1CreateUsagePlanKeyCommandError(output, context);
  7246. }
  7247. const contents: CreateUsagePlanKeyCommandOutput = {
  7248. $metadata: deserializeMetadata(output),
  7249. id: undefined,
  7250. name: undefined,
  7251. type: undefined,
  7252. value: undefined,
  7253. };
  7254. const data: any = await parseBody(output.body, context);
  7255. if (data.id !== undefined && data.id !== null) {
  7256. contents.id = data.id;
  7257. }
  7258. if (data.name !== undefined && data.name !== null) {
  7259. contents.name = data.name;
  7260. }
  7261. if (data.type !== undefined && data.type !== null) {
  7262. contents.type = data.type;
  7263. }
  7264. if (data.value !== undefined && data.value !== null) {
  7265. contents.value = data.value;
  7266. }
  7267. return Promise.resolve(contents);
  7268. };
  7269. const deserializeAws_restJson1CreateUsagePlanKeyCommandError = async (
  7270. output: __HttpResponse,
  7271. context: __SerdeContext
  7272. ): Promise<CreateUsagePlanKeyCommandOutput> => {
  7273. const parsedOutput: any = {
  7274. ...output,
  7275. body: await parseBody(output.body, context),
  7276. };
  7277. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7278. let errorCode: string = "UnknownError";
  7279. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7280. switch (errorCode) {
  7281. case "BadRequestException":
  7282. case "com.amazonaws.apigateway#BadRequestException":
  7283. response = {
  7284. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7285. name: errorCode,
  7286. $metadata: deserializeMetadata(output),
  7287. };
  7288. break;
  7289. case "ConflictException":
  7290. case "com.amazonaws.apigateway#ConflictException":
  7291. response = {
  7292. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7293. name: errorCode,
  7294. $metadata: deserializeMetadata(output),
  7295. };
  7296. break;
  7297. case "NotFoundException":
  7298. case "com.amazonaws.apigateway#NotFoundException":
  7299. response = {
  7300. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7301. name: errorCode,
  7302. $metadata: deserializeMetadata(output),
  7303. };
  7304. break;
  7305. case "TooManyRequestsException":
  7306. case "com.amazonaws.apigateway#TooManyRequestsException":
  7307. response = {
  7308. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7309. name: errorCode,
  7310. $metadata: deserializeMetadata(output),
  7311. };
  7312. break;
  7313. case "UnauthorizedException":
  7314. case "com.amazonaws.apigateway#UnauthorizedException":
  7315. response = {
  7316. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7317. name: errorCode,
  7318. $metadata: deserializeMetadata(output),
  7319. };
  7320. break;
  7321. default:
  7322. const parsedBody = parsedOutput.body;
  7323. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7324. response = {
  7325. ...parsedBody,
  7326. name: `${errorCode}`,
  7327. message: parsedBody.message || parsedBody.Message || errorCode,
  7328. $fault: "client",
  7329. $metadata: deserializeMetadata(output),
  7330. } as any;
  7331. }
  7332. const message = response.message || response.Message || errorCode;
  7333. response.message = message;
  7334. delete response.Message;
  7335. return Promise.reject(Object.assign(new Error(message), response));
  7336. };
  7337. export const deserializeAws_restJson1CreateVpcLinkCommand = async (
  7338. output: __HttpResponse,
  7339. context: __SerdeContext
  7340. ): Promise<CreateVpcLinkCommandOutput> => {
  7341. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7342. return deserializeAws_restJson1CreateVpcLinkCommandError(output, context);
  7343. }
  7344. const contents: CreateVpcLinkCommandOutput = {
  7345. $metadata: deserializeMetadata(output),
  7346. description: undefined,
  7347. id: undefined,
  7348. name: undefined,
  7349. status: undefined,
  7350. statusMessage: undefined,
  7351. tags: undefined,
  7352. targetArns: undefined,
  7353. };
  7354. const data: any = await parseBody(output.body, context);
  7355. if (data.description !== undefined && data.description !== null) {
  7356. contents.description = data.description;
  7357. }
  7358. if (data.id !== undefined && data.id !== null) {
  7359. contents.id = data.id;
  7360. }
  7361. if (data.name !== undefined && data.name !== null) {
  7362. contents.name = data.name;
  7363. }
  7364. if (data.status !== undefined && data.status !== null) {
  7365. contents.status = data.status;
  7366. }
  7367. if (data.statusMessage !== undefined && data.statusMessage !== null) {
  7368. contents.statusMessage = data.statusMessage;
  7369. }
  7370. if (data.tags !== undefined && data.tags !== null) {
  7371. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  7372. }
  7373. if (data.targetArns !== undefined && data.targetArns !== null) {
  7374. contents.targetArns = deserializeAws_restJson1ListOfString(data.targetArns, context);
  7375. }
  7376. return Promise.resolve(contents);
  7377. };
  7378. const deserializeAws_restJson1CreateVpcLinkCommandError = async (
  7379. output: __HttpResponse,
  7380. context: __SerdeContext
  7381. ): Promise<CreateVpcLinkCommandOutput> => {
  7382. const parsedOutput: any = {
  7383. ...output,
  7384. body: await parseBody(output.body, context),
  7385. };
  7386. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7387. let errorCode: string = "UnknownError";
  7388. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7389. switch (errorCode) {
  7390. case "BadRequestException":
  7391. case "com.amazonaws.apigateway#BadRequestException":
  7392. response = {
  7393. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7394. name: errorCode,
  7395. $metadata: deserializeMetadata(output),
  7396. };
  7397. break;
  7398. case "TooManyRequestsException":
  7399. case "com.amazonaws.apigateway#TooManyRequestsException":
  7400. response = {
  7401. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7402. name: errorCode,
  7403. $metadata: deserializeMetadata(output),
  7404. };
  7405. break;
  7406. case "UnauthorizedException":
  7407. case "com.amazonaws.apigateway#UnauthorizedException":
  7408. response = {
  7409. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7410. name: errorCode,
  7411. $metadata: deserializeMetadata(output),
  7412. };
  7413. break;
  7414. default:
  7415. const parsedBody = parsedOutput.body;
  7416. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7417. response = {
  7418. ...parsedBody,
  7419. name: `${errorCode}`,
  7420. message: parsedBody.message || parsedBody.Message || errorCode,
  7421. $fault: "client",
  7422. $metadata: deserializeMetadata(output),
  7423. } as any;
  7424. }
  7425. const message = response.message || response.Message || errorCode;
  7426. response.message = message;
  7427. delete response.Message;
  7428. return Promise.reject(Object.assign(new Error(message), response));
  7429. };
  7430. export const deserializeAws_restJson1DeleteApiKeyCommand = async (
  7431. output: __HttpResponse,
  7432. context: __SerdeContext
  7433. ): Promise<DeleteApiKeyCommandOutput> => {
  7434. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7435. return deserializeAws_restJson1DeleteApiKeyCommandError(output, context);
  7436. }
  7437. const contents: DeleteApiKeyCommandOutput = {
  7438. $metadata: deserializeMetadata(output),
  7439. };
  7440. await collectBody(output.body, context);
  7441. return Promise.resolve(contents);
  7442. };
  7443. const deserializeAws_restJson1DeleteApiKeyCommandError = async (
  7444. output: __HttpResponse,
  7445. context: __SerdeContext
  7446. ): Promise<DeleteApiKeyCommandOutput> => {
  7447. const parsedOutput: any = {
  7448. ...output,
  7449. body: await parseBody(output.body, context),
  7450. };
  7451. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7452. let errorCode: string = "UnknownError";
  7453. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7454. switch (errorCode) {
  7455. case "NotFoundException":
  7456. case "com.amazonaws.apigateway#NotFoundException":
  7457. response = {
  7458. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7459. name: errorCode,
  7460. $metadata: deserializeMetadata(output),
  7461. };
  7462. break;
  7463. case "TooManyRequestsException":
  7464. case "com.amazonaws.apigateway#TooManyRequestsException":
  7465. response = {
  7466. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7467. name: errorCode,
  7468. $metadata: deserializeMetadata(output),
  7469. };
  7470. break;
  7471. case "UnauthorizedException":
  7472. case "com.amazonaws.apigateway#UnauthorizedException":
  7473. response = {
  7474. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7475. name: errorCode,
  7476. $metadata: deserializeMetadata(output),
  7477. };
  7478. break;
  7479. default:
  7480. const parsedBody = parsedOutput.body;
  7481. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7482. response = {
  7483. ...parsedBody,
  7484. name: `${errorCode}`,
  7485. message: parsedBody.message || parsedBody.Message || errorCode,
  7486. $fault: "client",
  7487. $metadata: deserializeMetadata(output),
  7488. } as any;
  7489. }
  7490. const message = response.message || response.Message || errorCode;
  7491. response.message = message;
  7492. delete response.Message;
  7493. return Promise.reject(Object.assign(new Error(message), response));
  7494. };
  7495. export const deserializeAws_restJson1DeleteAuthorizerCommand = async (
  7496. output: __HttpResponse,
  7497. context: __SerdeContext
  7498. ): Promise<DeleteAuthorizerCommandOutput> => {
  7499. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7500. return deserializeAws_restJson1DeleteAuthorizerCommandError(output, context);
  7501. }
  7502. const contents: DeleteAuthorizerCommandOutput = {
  7503. $metadata: deserializeMetadata(output),
  7504. };
  7505. await collectBody(output.body, context);
  7506. return Promise.resolve(contents);
  7507. };
  7508. const deserializeAws_restJson1DeleteAuthorizerCommandError = async (
  7509. output: __HttpResponse,
  7510. context: __SerdeContext
  7511. ): Promise<DeleteAuthorizerCommandOutput> => {
  7512. const parsedOutput: any = {
  7513. ...output,
  7514. body: await parseBody(output.body, context),
  7515. };
  7516. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7517. let errorCode: string = "UnknownError";
  7518. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7519. switch (errorCode) {
  7520. case "BadRequestException":
  7521. case "com.amazonaws.apigateway#BadRequestException":
  7522. response = {
  7523. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7524. name: errorCode,
  7525. $metadata: deserializeMetadata(output),
  7526. };
  7527. break;
  7528. case "ConflictException":
  7529. case "com.amazonaws.apigateway#ConflictException":
  7530. response = {
  7531. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7532. name: errorCode,
  7533. $metadata: deserializeMetadata(output),
  7534. };
  7535. break;
  7536. case "NotFoundException":
  7537. case "com.amazonaws.apigateway#NotFoundException":
  7538. response = {
  7539. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7540. name: errorCode,
  7541. $metadata: deserializeMetadata(output),
  7542. };
  7543. break;
  7544. case "TooManyRequestsException":
  7545. case "com.amazonaws.apigateway#TooManyRequestsException":
  7546. response = {
  7547. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7548. name: errorCode,
  7549. $metadata: deserializeMetadata(output),
  7550. };
  7551. break;
  7552. case "UnauthorizedException":
  7553. case "com.amazonaws.apigateway#UnauthorizedException":
  7554. response = {
  7555. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7556. name: errorCode,
  7557. $metadata: deserializeMetadata(output),
  7558. };
  7559. break;
  7560. default:
  7561. const parsedBody = parsedOutput.body;
  7562. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7563. response = {
  7564. ...parsedBody,
  7565. name: `${errorCode}`,
  7566. message: parsedBody.message || parsedBody.Message || errorCode,
  7567. $fault: "client",
  7568. $metadata: deserializeMetadata(output),
  7569. } as any;
  7570. }
  7571. const message = response.message || response.Message || errorCode;
  7572. response.message = message;
  7573. delete response.Message;
  7574. return Promise.reject(Object.assign(new Error(message), response));
  7575. };
  7576. export const deserializeAws_restJson1DeleteBasePathMappingCommand = async (
  7577. output: __HttpResponse,
  7578. context: __SerdeContext
  7579. ): Promise<DeleteBasePathMappingCommandOutput> => {
  7580. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7581. return deserializeAws_restJson1DeleteBasePathMappingCommandError(output, context);
  7582. }
  7583. const contents: DeleteBasePathMappingCommandOutput = {
  7584. $metadata: deserializeMetadata(output),
  7585. };
  7586. await collectBody(output.body, context);
  7587. return Promise.resolve(contents);
  7588. };
  7589. const deserializeAws_restJson1DeleteBasePathMappingCommandError = async (
  7590. output: __HttpResponse,
  7591. context: __SerdeContext
  7592. ): Promise<DeleteBasePathMappingCommandOutput> => {
  7593. const parsedOutput: any = {
  7594. ...output,
  7595. body: await parseBody(output.body, context),
  7596. };
  7597. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7598. let errorCode: string = "UnknownError";
  7599. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7600. switch (errorCode) {
  7601. case "BadRequestException":
  7602. case "com.amazonaws.apigateway#BadRequestException":
  7603. response = {
  7604. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7605. name: errorCode,
  7606. $metadata: deserializeMetadata(output),
  7607. };
  7608. break;
  7609. case "ConflictException":
  7610. case "com.amazonaws.apigateway#ConflictException":
  7611. response = {
  7612. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7613. name: errorCode,
  7614. $metadata: deserializeMetadata(output),
  7615. };
  7616. break;
  7617. case "NotFoundException":
  7618. case "com.amazonaws.apigateway#NotFoundException":
  7619. response = {
  7620. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7621. name: errorCode,
  7622. $metadata: deserializeMetadata(output),
  7623. };
  7624. break;
  7625. case "TooManyRequestsException":
  7626. case "com.amazonaws.apigateway#TooManyRequestsException":
  7627. response = {
  7628. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7629. name: errorCode,
  7630. $metadata: deserializeMetadata(output),
  7631. };
  7632. break;
  7633. case "UnauthorizedException":
  7634. case "com.amazonaws.apigateway#UnauthorizedException":
  7635. response = {
  7636. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7637. name: errorCode,
  7638. $metadata: deserializeMetadata(output),
  7639. };
  7640. break;
  7641. default:
  7642. const parsedBody = parsedOutput.body;
  7643. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7644. response = {
  7645. ...parsedBody,
  7646. name: `${errorCode}`,
  7647. message: parsedBody.message || parsedBody.Message || errorCode,
  7648. $fault: "client",
  7649. $metadata: deserializeMetadata(output),
  7650. } as any;
  7651. }
  7652. const message = response.message || response.Message || errorCode;
  7653. response.message = message;
  7654. delete response.Message;
  7655. return Promise.reject(Object.assign(new Error(message), response));
  7656. };
  7657. export const deserializeAws_restJson1DeleteClientCertificateCommand = async (
  7658. output: __HttpResponse,
  7659. context: __SerdeContext
  7660. ): Promise<DeleteClientCertificateCommandOutput> => {
  7661. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7662. return deserializeAws_restJson1DeleteClientCertificateCommandError(output, context);
  7663. }
  7664. const contents: DeleteClientCertificateCommandOutput = {
  7665. $metadata: deserializeMetadata(output),
  7666. };
  7667. await collectBody(output.body, context);
  7668. return Promise.resolve(contents);
  7669. };
  7670. const deserializeAws_restJson1DeleteClientCertificateCommandError = async (
  7671. output: __HttpResponse,
  7672. context: __SerdeContext
  7673. ): Promise<DeleteClientCertificateCommandOutput> => {
  7674. const parsedOutput: any = {
  7675. ...output,
  7676. body: await parseBody(output.body, context),
  7677. };
  7678. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7679. let errorCode: string = "UnknownError";
  7680. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7681. switch (errorCode) {
  7682. case "BadRequestException":
  7683. case "com.amazonaws.apigateway#BadRequestException":
  7684. response = {
  7685. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7686. name: errorCode,
  7687. $metadata: deserializeMetadata(output),
  7688. };
  7689. break;
  7690. case "NotFoundException":
  7691. case "com.amazonaws.apigateway#NotFoundException":
  7692. response = {
  7693. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7694. name: errorCode,
  7695. $metadata: deserializeMetadata(output),
  7696. };
  7697. break;
  7698. case "TooManyRequestsException":
  7699. case "com.amazonaws.apigateway#TooManyRequestsException":
  7700. response = {
  7701. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7702. name: errorCode,
  7703. $metadata: deserializeMetadata(output),
  7704. };
  7705. break;
  7706. case "UnauthorizedException":
  7707. case "com.amazonaws.apigateway#UnauthorizedException":
  7708. response = {
  7709. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7710. name: errorCode,
  7711. $metadata: deserializeMetadata(output),
  7712. };
  7713. break;
  7714. default:
  7715. const parsedBody = parsedOutput.body;
  7716. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7717. response = {
  7718. ...parsedBody,
  7719. name: `${errorCode}`,
  7720. message: parsedBody.message || parsedBody.Message || errorCode,
  7721. $fault: "client",
  7722. $metadata: deserializeMetadata(output),
  7723. } as any;
  7724. }
  7725. const message = response.message || response.Message || errorCode;
  7726. response.message = message;
  7727. delete response.Message;
  7728. return Promise.reject(Object.assign(new Error(message), response));
  7729. };
  7730. export const deserializeAws_restJson1DeleteDeploymentCommand = async (
  7731. output: __HttpResponse,
  7732. context: __SerdeContext
  7733. ): Promise<DeleteDeploymentCommandOutput> => {
  7734. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7735. return deserializeAws_restJson1DeleteDeploymentCommandError(output, context);
  7736. }
  7737. const contents: DeleteDeploymentCommandOutput = {
  7738. $metadata: deserializeMetadata(output),
  7739. };
  7740. await collectBody(output.body, context);
  7741. return Promise.resolve(contents);
  7742. };
  7743. const deserializeAws_restJson1DeleteDeploymentCommandError = async (
  7744. output: __HttpResponse,
  7745. context: __SerdeContext
  7746. ): Promise<DeleteDeploymentCommandOutput> => {
  7747. const parsedOutput: any = {
  7748. ...output,
  7749. body: await parseBody(output.body, context),
  7750. };
  7751. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7752. let errorCode: string = "UnknownError";
  7753. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7754. switch (errorCode) {
  7755. case "BadRequestException":
  7756. case "com.amazonaws.apigateway#BadRequestException":
  7757. response = {
  7758. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7759. name: errorCode,
  7760. $metadata: deserializeMetadata(output),
  7761. };
  7762. break;
  7763. case "NotFoundException":
  7764. case "com.amazonaws.apigateway#NotFoundException":
  7765. response = {
  7766. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7767. name: errorCode,
  7768. $metadata: deserializeMetadata(output),
  7769. };
  7770. break;
  7771. case "TooManyRequestsException":
  7772. case "com.amazonaws.apigateway#TooManyRequestsException":
  7773. response = {
  7774. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7775. name: errorCode,
  7776. $metadata: deserializeMetadata(output),
  7777. };
  7778. break;
  7779. case "UnauthorizedException":
  7780. case "com.amazonaws.apigateway#UnauthorizedException":
  7781. response = {
  7782. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7783. name: errorCode,
  7784. $metadata: deserializeMetadata(output),
  7785. };
  7786. break;
  7787. default:
  7788. const parsedBody = parsedOutput.body;
  7789. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7790. response = {
  7791. ...parsedBody,
  7792. name: `${errorCode}`,
  7793. message: parsedBody.message || parsedBody.Message || errorCode,
  7794. $fault: "client",
  7795. $metadata: deserializeMetadata(output),
  7796. } as any;
  7797. }
  7798. const message = response.message || response.Message || errorCode;
  7799. response.message = message;
  7800. delete response.Message;
  7801. return Promise.reject(Object.assign(new Error(message), response));
  7802. };
  7803. export const deserializeAws_restJson1DeleteDocumentationPartCommand = async (
  7804. output: __HttpResponse,
  7805. context: __SerdeContext
  7806. ): Promise<DeleteDocumentationPartCommandOutput> => {
  7807. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7808. return deserializeAws_restJson1DeleteDocumentationPartCommandError(output, context);
  7809. }
  7810. const contents: DeleteDocumentationPartCommandOutput = {
  7811. $metadata: deserializeMetadata(output),
  7812. };
  7813. await collectBody(output.body, context);
  7814. return Promise.resolve(contents);
  7815. };
  7816. const deserializeAws_restJson1DeleteDocumentationPartCommandError = async (
  7817. output: __HttpResponse,
  7818. context: __SerdeContext
  7819. ): Promise<DeleteDocumentationPartCommandOutput> => {
  7820. const parsedOutput: any = {
  7821. ...output,
  7822. body: await parseBody(output.body, context),
  7823. };
  7824. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7825. let errorCode: string = "UnknownError";
  7826. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7827. switch (errorCode) {
  7828. case "BadRequestException":
  7829. case "com.amazonaws.apigateway#BadRequestException":
  7830. response = {
  7831. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7832. name: errorCode,
  7833. $metadata: deserializeMetadata(output),
  7834. };
  7835. break;
  7836. case "ConflictException":
  7837. case "com.amazonaws.apigateway#ConflictException":
  7838. response = {
  7839. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7840. name: errorCode,
  7841. $metadata: deserializeMetadata(output),
  7842. };
  7843. break;
  7844. case "NotFoundException":
  7845. case "com.amazonaws.apigateway#NotFoundException":
  7846. response = {
  7847. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7848. name: errorCode,
  7849. $metadata: deserializeMetadata(output),
  7850. };
  7851. break;
  7852. case "TooManyRequestsException":
  7853. case "com.amazonaws.apigateway#TooManyRequestsException":
  7854. response = {
  7855. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7856. name: errorCode,
  7857. $metadata: deserializeMetadata(output),
  7858. };
  7859. break;
  7860. case "UnauthorizedException":
  7861. case "com.amazonaws.apigateway#UnauthorizedException":
  7862. response = {
  7863. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7864. name: errorCode,
  7865. $metadata: deserializeMetadata(output),
  7866. };
  7867. break;
  7868. default:
  7869. const parsedBody = parsedOutput.body;
  7870. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7871. response = {
  7872. ...parsedBody,
  7873. name: `${errorCode}`,
  7874. message: parsedBody.message || parsedBody.Message || errorCode,
  7875. $fault: "client",
  7876. $metadata: deserializeMetadata(output),
  7877. } as any;
  7878. }
  7879. const message = response.message || response.Message || errorCode;
  7880. response.message = message;
  7881. delete response.Message;
  7882. return Promise.reject(Object.assign(new Error(message), response));
  7883. };
  7884. export const deserializeAws_restJson1DeleteDocumentationVersionCommand = async (
  7885. output: __HttpResponse,
  7886. context: __SerdeContext
  7887. ): Promise<DeleteDocumentationVersionCommandOutput> => {
  7888. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7889. return deserializeAws_restJson1DeleteDocumentationVersionCommandError(output, context);
  7890. }
  7891. const contents: DeleteDocumentationVersionCommandOutput = {
  7892. $metadata: deserializeMetadata(output),
  7893. };
  7894. await collectBody(output.body, context);
  7895. return Promise.resolve(contents);
  7896. };
  7897. const deserializeAws_restJson1DeleteDocumentationVersionCommandError = async (
  7898. output: __HttpResponse,
  7899. context: __SerdeContext
  7900. ): Promise<DeleteDocumentationVersionCommandOutput> => {
  7901. const parsedOutput: any = {
  7902. ...output,
  7903. body: await parseBody(output.body, context),
  7904. };
  7905. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7906. let errorCode: string = "UnknownError";
  7907. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7908. switch (errorCode) {
  7909. case "BadRequestException":
  7910. case "com.amazonaws.apigateway#BadRequestException":
  7911. response = {
  7912. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7913. name: errorCode,
  7914. $metadata: deserializeMetadata(output),
  7915. };
  7916. break;
  7917. case "ConflictException":
  7918. case "com.amazonaws.apigateway#ConflictException":
  7919. response = {
  7920. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  7921. name: errorCode,
  7922. $metadata: deserializeMetadata(output),
  7923. };
  7924. break;
  7925. case "NotFoundException":
  7926. case "com.amazonaws.apigateway#NotFoundException":
  7927. response = {
  7928. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  7929. name: errorCode,
  7930. $metadata: deserializeMetadata(output),
  7931. };
  7932. break;
  7933. case "TooManyRequestsException":
  7934. case "com.amazonaws.apigateway#TooManyRequestsException":
  7935. response = {
  7936. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  7937. name: errorCode,
  7938. $metadata: deserializeMetadata(output),
  7939. };
  7940. break;
  7941. case "UnauthorizedException":
  7942. case "com.amazonaws.apigateway#UnauthorizedException":
  7943. response = {
  7944. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  7945. name: errorCode,
  7946. $metadata: deserializeMetadata(output),
  7947. };
  7948. break;
  7949. default:
  7950. const parsedBody = parsedOutput.body;
  7951. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  7952. response = {
  7953. ...parsedBody,
  7954. name: `${errorCode}`,
  7955. message: parsedBody.message || parsedBody.Message || errorCode,
  7956. $fault: "client",
  7957. $metadata: deserializeMetadata(output),
  7958. } as any;
  7959. }
  7960. const message = response.message || response.Message || errorCode;
  7961. response.message = message;
  7962. delete response.Message;
  7963. return Promise.reject(Object.assign(new Error(message), response));
  7964. };
  7965. export const deserializeAws_restJson1DeleteDomainNameCommand = async (
  7966. output: __HttpResponse,
  7967. context: __SerdeContext
  7968. ): Promise<DeleteDomainNameCommandOutput> => {
  7969. if (output.statusCode !== 202 && output.statusCode >= 400) {
  7970. return deserializeAws_restJson1DeleteDomainNameCommandError(output, context);
  7971. }
  7972. const contents: DeleteDomainNameCommandOutput = {
  7973. $metadata: deserializeMetadata(output),
  7974. };
  7975. await collectBody(output.body, context);
  7976. return Promise.resolve(contents);
  7977. };
  7978. const deserializeAws_restJson1DeleteDomainNameCommandError = async (
  7979. output: __HttpResponse,
  7980. context: __SerdeContext
  7981. ): Promise<DeleteDomainNameCommandOutput> => {
  7982. const parsedOutput: any = {
  7983. ...output,
  7984. body: await parseBody(output.body, context),
  7985. };
  7986. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  7987. let errorCode: string = "UnknownError";
  7988. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  7989. switch (errorCode) {
  7990. case "BadRequestException":
  7991. case "com.amazonaws.apigateway#BadRequestException":
  7992. response = {
  7993. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  7994. name: errorCode,
  7995. $metadata: deserializeMetadata(output),
  7996. };
  7997. break;
  7998. case "NotFoundException":
  7999. case "com.amazonaws.apigateway#NotFoundException":
  8000. response = {
  8001. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8002. name: errorCode,
  8003. $metadata: deserializeMetadata(output),
  8004. };
  8005. break;
  8006. case "TooManyRequestsException":
  8007. case "com.amazonaws.apigateway#TooManyRequestsException":
  8008. response = {
  8009. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8010. name: errorCode,
  8011. $metadata: deserializeMetadata(output),
  8012. };
  8013. break;
  8014. case "UnauthorizedException":
  8015. case "com.amazonaws.apigateway#UnauthorizedException":
  8016. response = {
  8017. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8018. name: errorCode,
  8019. $metadata: deserializeMetadata(output),
  8020. };
  8021. break;
  8022. default:
  8023. const parsedBody = parsedOutput.body;
  8024. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8025. response = {
  8026. ...parsedBody,
  8027. name: `${errorCode}`,
  8028. message: parsedBody.message || parsedBody.Message || errorCode,
  8029. $fault: "client",
  8030. $metadata: deserializeMetadata(output),
  8031. } as any;
  8032. }
  8033. const message = response.message || response.Message || errorCode;
  8034. response.message = message;
  8035. delete response.Message;
  8036. return Promise.reject(Object.assign(new Error(message), response));
  8037. };
  8038. export const deserializeAws_restJson1DeleteGatewayResponseCommand = async (
  8039. output: __HttpResponse,
  8040. context: __SerdeContext
  8041. ): Promise<DeleteGatewayResponseCommandOutput> => {
  8042. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8043. return deserializeAws_restJson1DeleteGatewayResponseCommandError(output, context);
  8044. }
  8045. const contents: DeleteGatewayResponseCommandOutput = {
  8046. $metadata: deserializeMetadata(output),
  8047. };
  8048. await collectBody(output.body, context);
  8049. return Promise.resolve(contents);
  8050. };
  8051. const deserializeAws_restJson1DeleteGatewayResponseCommandError = async (
  8052. output: __HttpResponse,
  8053. context: __SerdeContext
  8054. ): Promise<DeleteGatewayResponseCommandOutput> => {
  8055. const parsedOutput: any = {
  8056. ...output,
  8057. body: await parseBody(output.body, context),
  8058. };
  8059. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8060. let errorCode: string = "UnknownError";
  8061. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8062. switch (errorCode) {
  8063. case "BadRequestException":
  8064. case "com.amazonaws.apigateway#BadRequestException":
  8065. response = {
  8066. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8067. name: errorCode,
  8068. $metadata: deserializeMetadata(output),
  8069. };
  8070. break;
  8071. case "ConflictException":
  8072. case "com.amazonaws.apigateway#ConflictException":
  8073. response = {
  8074. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8075. name: errorCode,
  8076. $metadata: deserializeMetadata(output),
  8077. };
  8078. break;
  8079. case "NotFoundException":
  8080. case "com.amazonaws.apigateway#NotFoundException":
  8081. response = {
  8082. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8083. name: errorCode,
  8084. $metadata: deserializeMetadata(output),
  8085. };
  8086. break;
  8087. case "TooManyRequestsException":
  8088. case "com.amazonaws.apigateway#TooManyRequestsException":
  8089. response = {
  8090. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8091. name: errorCode,
  8092. $metadata: deserializeMetadata(output),
  8093. };
  8094. break;
  8095. case "UnauthorizedException":
  8096. case "com.amazonaws.apigateway#UnauthorizedException":
  8097. response = {
  8098. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8099. name: errorCode,
  8100. $metadata: deserializeMetadata(output),
  8101. };
  8102. break;
  8103. default:
  8104. const parsedBody = parsedOutput.body;
  8105. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8106. response = {
  8107. ...parsedBody,
  8108. name: `${errorCode}`,
  8109. message: parsedBody.message || parsedBody.Message || errorCode,
  8110. $fault: "client",
  8111. $metadata: deserializeMetadata(output),
  8112. } as any;
  8113. }
  8114. const message = response.message || response.Message || errorCode;
  8115. response.message = message;
  8116. delete response.Message;
  8117. return Promise.reject(Object.assign(new Error(message), response));
  8118. };
  8119. export const deserializeAws_restJson1DeleteIntegrationCommand = async (
  8120. output: __HttpResponse,
  8121. context: __SerdeContext
  8122. ): Promise<DeleteIntegrationCommandOutput> => {
  8123. if (output.statusCode !== 204 && output.statusCode >= 400) {
  8124. return deserializeAws_restJson1DeleteIntegrationCommandError(output, context);
  8125. }
  8126. const contents: DeleteIntegrationCommandOutput = {
  8127. $metadata: deserializeMetadata(output),
  8128. };
  8129. await collectBody(output.body, context);
  8130. return Promise.resolve(contents);
  8131. };
  8132. const deserializeAws_restJson1DeleteIntegrationCommandError = async (
  8133. output: __HttpResponse,
  8134. context: __SerdeContext
  8135. ): Promise<DeleteIntegrationCommandOutput> => {
  8136. const parsedOutput: any = {
  8137. ...output,
  8138. body: await parseBody(output.body, context),
  8139. };
  8140. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8141. let errorCode: string = "UnknownError";
  8142. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8143. switch (errorCode) {
  8144. case "ConflictException":
  8145. case "com.amazonaws.apigateway#ConflictException":
  8146. response = {
  8147. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8148. name: errorCode,
  8149. $metadata: deserializeMetadata(output),
  8150. };
  8151. break;
  8152. case "NotFoundException":
  8153. case "com.amazonaws.apigateway#NotFoundException":
  8154. response = {
  8155. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8156. name: errorCode,
  8157. $metadata: deserializeMetadata(output),
  8158. };
  8159. break;
  8160. case "TooManyRequestsException":
  8161. case "com.amazonaws.apigateway#TooManyRequestsException":
  8162. response = {
  8163. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8164. name: errorCode,
  8165. $metadata: deserializeMetadata(output),
  8166. };
  8167. break;
  8168. case "UnauthorizedException":
  8169. case "com.amazonaws.apigateway#UnauthorizedException":
  8170. response = {
  8171. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8172. name: errorCode,
  8173. $metadata: deserializeMetadata(output),
  8174. };
  8175. break;
  8176. default:
  8177. const parsedBody = parsedOutput.body;
  8178. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8179. response = {
  8180. ...parsedBody,
  8181. name: `${errorCode}`,
  8182. message: parsedBody.message || parsedBody.Message || errorCode,
  8183. $fault: "client",
  8184. $metadata: deserializeMetadata(output),
  8185. } as any;
  8186. }
  8187. const message = response.message || response.Message || errorCode;
  8188. response.message = message;
  8189. delete response.Message;
  8190. return Promise.reject(Object.assign(new Error(message), response));
  8191. };
  8192. export const deserializeAws_restJson1DeleteIntegrationResponseCommand = async (
  8193. output: __HttpResponse,
  8194. context: __SerdeContext
  8195. ): Promise<DeleteIntegrationResponseCommandOutput> => {
  8196. if (output.statusCode !== 204 && output.statusCode >= 400) {
  8197. return deserializeAws_restJson1DeleteIntegrationResponseCommandError(output, context);
  8198. }
  8199. const contents: DeleteIntegrationResponseCommandOutput = {
  8200. $metadata: deserializeMetadata(output),
  8201. };
  8202. await collectBody(output.body, context);
  8203. return Promise.resolve(contents);
  8204. };
  8205. const deserializeAws_restJson1DeleteIntegrationResponseCommandError = async (
  8206. output: __HttpResponse,
  8207. context: __SerdeContext
  8208. ): Promise<DeleteIntegrationResponseCommandOutput> => {
  8209. const parsedOutput: any = {
  8210. ...output,
  8211. body: await parseBody(output.body, context),
  8212. };
  8213. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8214. let errorCode: string = "UnknownError";
  8215. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8216. switch (errorCode) {
  8217. case "BadRequestException":
  8218. case "com.amazonaws.apigateway#BadRequestException":
  8219. response = {
  8220. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8221. name: errorCode,
  8222. $metadata: deserializeMetadata(output),
  8223. };
  8224. break;
  8225. case "ConflictException":
  8226. case "com.amazonaws.apigateway#ConflictException":
  8227. response = {
  8228. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8229. name: errorCode,
  8230. $metadata: deserializeMetadata(output),
  8231. };
  8232. break;
  8233. case "NotFoundException":
  8234. case "com.amazonaws.apigateway#NotFoundException":
  8235. response = {
  8236. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8237. name: errorCode,
  8238. $metadata: deserializeMetadata(output),
  8239. };
  8240. break;
  8241. case "TooManyRequestsException":
  8242. case "com.amazonaws.apigateway#TooManyRequestsException":
  8243. response = {
  8244. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8245. name: errorCode,
  8246. $metadata: deserializeMetadata(output),
  8247. };
  8248. break;
  8249. case "UnauthorizedException":
  8250. case "com.amazonaws.apigateway#UnauthorizedException":
  8251. response = {
  8252. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8253. name: errorCode,
  8254. $metadata: deserializeMetadata(output),
  8255. };
  8256. break;
  8257. default:
  8258. const parsedBody = parsedOutput.body;
  8259. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8260. response = {
  8261. ...parsedBody,
  8262. name: `${errorCode}`,
  8263. message: parsedBody.message || parsedBody.Message || errorCode,
  8264. $fault: "client",
  8265. $metadata: deserializeMetadata(output),
  8266. } as any;
  8267. }
  8268. const message = response.message || response.Message || errorCode;
  8269. response.message = message;
  8270. delete response.Message;
  8271. return Promise.reject(Object.assign(new Error(message), response));
  8272. };
  8273. export const deserializeAws_restJson1DeleteMethodCommand = async (
  8274. output: __HttpResponse,
  8275. context: __SerdeContext
  8276. ): Promise<DeleteMethodCommandOutput> => {
  8277. if (output.statusCode !== 204 && output.statusCode >= 400) {
  8278. return deserializeAws_restJson1DeleteMethodCommandError(output, context);
  8279. }
  8280. const contents: DeleteMethodCommandOutput = {
  8281. $metadata: deserializeMetadata(output),
  8282. };
  8283. await collectBody(output.body, context);
  8284. return Promise.resolve(contents);
  8285. };
  8286. const deserializeAws_restJson1DeleteMethodCommandError = async (
  8287. output: __HttpResponse,
  8288. context: __SerdeContext
  8289. ): Promise<DeleteMethodCommandOutput> => {
  8290. const parsedOutput: any = {
  8291. ...output,
  8292. body: await parseBody(output.body, context),
  8293. };
  8294. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8295. let errorCode: string = "UnknownError";
  8296. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8297. switch (errorCode) {
  8298. case "ConflictException":
  8299. case "com.amazonaws.apigateway#ConflictException":
  8300. response = {
  8301. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8302. name: errorCode,
  8303. $metadata: deserializeMetadata(output),
  8304. };
  8305. break;
  8306. case "NotFoundException":
  8307. case "com.amazonaws.apigateway#NotFoundException":
  8308. response = {
  8309. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8310. name: errorCode,
  8311. $metadata: deserializeMetadata(output),
  8312. };
  8313. break;
  8314. case "TooManyRequestsException":
  8315. case "com.amazonaws.apigateway#TooManyRequestsException":
  8316. response = {
  8317. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8318. name: errorCode,
  8319. $metadata: deserializeMetadata(output),
  8320. };
  8321. break;
  8322. case "UnauthorizedException":
  8323. case "com.amazonaws.apigateway#UnauthorizedException":
  8324. response = {
  8325. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8326. name: errorCode,
  8327. $metadata: deserializeMetadata(output),
  8328. };
  8329. break;
  8330. default:
  8331. const parsedBody = parsedOutput.body;
  8332. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8333. response = {
  8334. ...parsedBody,
  8335. name: `${errorCode}`,
  8336. message: parsedBody.message || parsedBody.Message || errorCode,
  8337. $fault: "client",
  8338. $metadata: deserializeMetadata(output),
  8339. } as any;
  8340. }
  8341. const message = response.message || response.Message || errorCode;
  8342. response.message = message;
  8343. delete response.Message;
  8344. return Promise.reject(Object.assign(new Error(message), response));
  8345. };
  8346. export const deserializeAws_restJson1DeleteMethodResponseCommand = async (
  8347. output: __HttpResponse,
  8348. context: __SerdeContext
  8349. ): Promise<DeleteMethodResponseCommandOutput> => {
  8350. if (output.statusCode !== 204 && output.statusCode >= 400) {
  8351. return deserializeAws_restJson1DeleteMethodResponseCommandError(output, context);
  8352. }
  8353. const contents: DeleteMethodResponseCommandOutput = {
  8354. $metadata: deserializeMetadata(output),
  8355. };
  8356. await collectBody(output.body, context);
  8357. return Promise.resolve(contents);
  8358. };
  8359. const deserializeAws_restJson1DeleteMethodResponseCommandError = async (
  8360. output: __HttpResponse,
  8361. context: __SerdeContext
  8362. ): Promise<DeleteMethodResponseCommandOutput> => {
  8363. const parsedOutput: any = {
  8364. ...output,
  8365. body: await parseBody(output.body, context),
  8366. };
  8367. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8368. let errorCode: string = "UnknownError";
  8369. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8370. switch (errorCode) {
  8371. case "BadRequestException":
  8372. case "com.amazonaws.apigateway#BadRequestException":
  8373. response = {
  8374. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8375. name: errorCode,
  8376. $metadata: deserializeMetadata(output),
  8377. };
  8378. break;
  8379. case "ConflictException":
  8380. case "com.amazonaws.apigateway#ConflictException":
  8381. response = {
  8382. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8383. name: errorCode,
  8384. $metadata: deserializeMetadata(output),
  8385. };
  8386. break;
  8387. case "NotFoundException":
  8388. case "com.amazonaws.apigateway#NotFoundException":
  8389. response = {
  8390. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8391. name: errorCode,
  8392. $metadata: deserializeMetadata(output),
  8393. };
  8394. break;
  8395. case "TooManyRequestsException":
  8396. case "com.amazonaws.apigateway#TooManyRequestsException":
  8397. response = {
  8398. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8399. name: errorCode,
  8400. $metadata: deserializeMetadata(output),
  8401. };
  8402. break;
  8403. case "UnauthorizedException":
  8404. case "com.amazonaws.apigateway#UnauthorizedException":
  8405. response = {
  8406. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8407. name: errorCode,
  8408. $metadata: deserializeMetadata(output),
  8409. };
  8410. break;
  8411. default:
  8412. const parsedBody = parsedOutput.body;
  8413. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8414. response = {
  8415. ...parsedBody,
  8416. name: `${errorCode}`,
  8417. message: parsedBody.message || parsedBody.Message || errorCode,
  8418. $fault: "client",
  8419. $metadata: deserializeMetadata(output),
  8420. } as any;
  8421. }
  8422. const message = response.message || response.Message || errorCode;
  8423. response.message = message;
  8424. delete response.Message;
  8425. return Promise.reject(Object.assign(new Error(message), response));
  8426. };
  8427. export const deserializeAws_restJson1DeleteModelCommand = async (
  8428. output: __HttpResponse,
  8429. context: __SerdeContext
  8430. ): Promise<DeleteModelCommandOutput> => {
  8431. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8432. return deserializeAws_restJson1DeleteModelCommandError(output, context);
  8433. }
  8434. const contents: DeleteModelCommandOutput = {
  8435. $metadata: deserializeMetadata(output),
  8436. };
  8437. await collectBody(output.body, context);
  8438. return Promise.resolve(contents);
  8439. };
  8440. const deserializeAws_restJson1DeleteModelCommandError = async (
  8441. output: __HttpResponse,
  8442. context: __SerdeContext
  8443. ): Promise<DeleteModelCommandOutput> => {
  8444. const parsedOutput: any = {
  8445. ...output,
  8446. body: await parseBody(output.body, context),
  8447. };
  8448. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8449. let errorCode: string = "UnknownError";
  8450. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8451. switch (errorCode) {
  8452. case "BadRequestException":
  8453. case "com.amazonaws.apigateway#BadRequestException":
  8454. response = {
  8455. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8456. name: errorCode,
  8457. $metadata: deserializeMetadata(output),
  8458. };
  8459. break;
  8460. case "ConflictException":
  8461. case "com.amazonaws.apigateway#ConflictException":
  8462. response = {
  8463. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8464. name: errorCode,
  8465. $metadata: deserializeMetadata(output),
  8466. };
  8467. break;
  8468. case "NotFoundException":
  8469. case "com.amazonaws.apigateway#NotFoundException":
  8470. response = {
  8471. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8472. name: errorCode,
  8473. $metadata: deserializeMetadata(output),
  8474. };
  8475. break;
  8476. case "TooManyRequestsException":
  8477. case "com.amazonaws.apigateway#TooManyRequestsException":
  8478. response = {
  8479. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8480. name: errorCode,
  8481. $metadata: deserializeMetadata(output),
  8482. };
  8483. break;
  8484. case "UnauthorizedException":
  8485. case "com.amazonaws.apigateway#UnauthorizedException":
  8486. response = {
  8487. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8488. name: errorCode,
  8489. $metadata: deserializeMetadata(output),
  8490. };
  8491. break;
  8492. default:
  8493. const parsedBody = parsedOutput.body;
  8494. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8495. response = {
  8496. ...parsedBody,
  8497. name: `${errorCode}`,
  8498. message: parsedBody.message || parsedBody.Message || errorCode,
  8499. $fault: "client",
  8500. $metadata: deserializeMetadata(output),
  8501. } as any;
  8502. }
  8503. const message = response.message || response.Message || errorCode;
  8504. response.message = message;
  8505. delete response.Message;
  8506. return Promise.reject(Object.assign(new Error(message), response));
  8507. };
  8508. export const deserializeAws_restJson1DeleteRequestValidatorCommand = async (
  8509. output: __HttpResponse,
  8510. context: __SerdeContext
  8511. ): Promise<DeleteRequestValidatorCommandOutput> => {
  8512. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8513. return deserializeAws_restJson1DeleteRequestValidatorCommandError(output, context);
  8514. }
  8515. const contents: DeleteRequestValidatorCommandOutput = {
  8516. $metadata: deserializeMetadata(output),
  8517. };
  8518. await collectBody(output.body, context);
  8519. return Promise.resolve(contents);
  8520. };
  8521. const deserializeAws_restJson1DeleteRequestValidatorCommandError = async (
  8522. output: __HttpResponse,
  8523. context: __SerdeContext
  8524. ): Promise<DeleteRequestValidatorCommandOutput> => {
  8525. const parsedOutput: any = {
  8526. ...output,
  8527. body: await parseBody(output.body, context),
  8528. };
  8529. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8530. let errorCode: string = "UnknownError";
  8531. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8532. switch (errorCode) {
  8533. case "BadRequestException":
  8534. case "com.amazonaws.apigateway#BadRequestException":
  8535. response = {
  8536. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8537. name: errorCode,
  8538. $metadata: deserializeMetadata(output),
  8539. };
  8540. break;
  8541. case "ConflictException":
  8542. case "com.amazonaws.apigateway#ConflictException":
  8543. response = {
  8544. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8545. name: errorCode,
  8546. $metadata: deserializeMetadata(output),
  8547. };
  8548. break;
  8549. case "NotFoundException":
  8550. case "com.amazonaws.apigateway#NotFoundException":
  8551. response = {
  8552. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8553. name: errorCode,
  8554. $metadata: deserializeMetadata(output),
  8555. };
  8556. break;
  8557. case "TooManyRequestsException":
  8558. case "com.amazonaws.apigateway#TooManyRequestsException":
  8559. response = {
  8560. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8561. name: errorCode,
  8562. $metadata: deserializeMetadata(output),
  8563. };
  8564. break;
  8565. case "UnauthorizedException":
  8566. case "com.amazonaws.apigateway#UnauthorizedException":
  8567. response = {
  8568. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8569. name: errorCode,
  8570. $metadata: deserializeMetadata(output),
  8571. };
  8572. break;
  8573. default:
  8574. const parsedBody = parsedOutput.body;
  8575. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8576. response = {
  8577. ...parsedBody,
  8578. name: `${errorCode}`,
  8579. message: parsedBody.message || parsedBody.Message || errorCode,
  8580. $fault: "client",
  8581. $metadata: deserializeMetadata(output),
  8582. } as any;
  8583. }
  8584. const message = response.message || response.Message || errorCode;
  8585. response.message = message;
  8586. delete response.Message;
  8587. return Promise.reject(Object.assign(new Error(message), response));
  8588. };
  8589. export const deserializeAws_restJson1DeleteResourceCommand = async (
  8590. output: __HttpResponse,
  8591. context: __SerdeContext
  8592. ): Promise<DeleteResourceCommandOutput> => {
  8593. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8594. return deserializeAws_restJson1DeleteResourceCommandError(output, context);
  8595. }
  8596. const contents: DeleteResourceCommandOutput = {
  8597. $metadata: deserializeMetadata(output),
  8598. };
  8599. await collectBody(output.body, context);
  8600. return Promise.resolve(contents);
  8601. };
  8602. const deserializeAws_restJson1DeleteResourceCommandError = async (
  8603. output: __HttpResponse,
  8604. context: __SerdeContext
  8605. ): Promise<DeleteResourceCommandOutput> => {
  8606. const parsedOutput: any = {
  8607. ...output,
  8608. body: await parseBody(output.body, context),
  8609. };
  8610. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8611. let errorCode: string = "UnknownError";
  8612. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8613. switch (errorCode) {
  8614. case "BadRequestException":
  8615. case "com.amazonaws.apigateway#BadRequestException":
  8616. response = {
  8617. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8618. name: errorCode,
  8619. $metadata: deserializeMetadata(output),
  8620. };
  8621. break;
  8622. case "ConflictException":
  8623. case "com.amazonaws.apigateway#ConflictException":
  8624. response = {
  8625. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8626. name: errorCode,
  8627. $metadata: deserializeMetadata(output),
  8628. };
  8629. break;
  8630. case "NotFoundException":
  8631. case "com.amazonaws.apigateway#NotFoundException":
  8632. response = {
  8633. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8634. name: errorCode,
  8635. $metadata: deserializeMetadata(output),
  8636. };
  8637. break;
  8638. case "TooManyRequestsException":
  8639. case "com.amazonaws.apigateway#TooManyRequestsException":
  8640. response = {
  8641. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8642. name: errorCode,
  8643. $metadata: deserializeMetadata(output),
  8644. };
  8645. break;
  8646. case "UnauthorizedException":
  8647. case "com.amazonaws.apigateway#UnauthorizedException":
  8648. response = {
  8649. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8650. name: errorCode,
  8651. $metadata: deserializeMetadata(output),
  8652. };
  8653. break;
  8654. default:
  8655. const parsedBody = parsedOutput.body;
  8656. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8657. response = {
  8658. ...parsedBody,
  8659. name: `${errorCode}`,
  8660. message: parsedBody.message || parsedBody.Message || errorCode,
  8661. $fault: "client",
  8662. $metadata: deserializeMetadata(output),
  8663. } as any;
  8664. }
  8665. const message = response.message || response.Message || errorCode;
  8666. response.message = message;
  8667. delete response.Message;
  8668. return Promise.reject(Object.assign(new Error(message), response));
  8669. };
  8670. export const deserializeAws_restJson1DeleteRestApiCommand = async (
  8671. output: __HttpResponse,
  8672. context: __SerdeContext
  8673. ): Promise<DeleteRestApiCommandOutput> => {
  8674. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8675. return deserializeAws_restJson1DeleteRestApiCommandError(output, context);
  8676. }
  8677. const contents: DeleteRestApiCommandOutput = {
  8678. $metadata: deserializeMetadata(output),
  8679. };
  8680. await collectBody(output.body, context);
  8681. return Promise.resolve(contents);
  8682. };
  8683. const deserializeAws_restJson1DeleteRestApiCommandError = async (
  8684. output: __HttpResponse,
  8685. context: __SerdeContext
  8686. ): Promise<DeleteRestApiCommandOutput> => {
  8687. const parsedOutput: any = {
  8688. ...output,
  8689. body: await parseBody(output.body, context),
  8690. };
  8691. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8692. let errorCode: string = "UnknownError";
  8693. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8694. switch (errorCode) {
  8695. case "BadRequestException":
  8696. case "com.amazonaws.apigateway#BadRequestException":
  8697. response = {
  8698. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8699. name: errorCode,
  8700. $metadata: deserializeMetadata(output),
  8701. };
  8702. break;
  8703. case "NotFoundException":
  8704. case "com.amazonaws.apigateway#NotFoundException":
  8705. response = {
  8706. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8707. name: errorCode,
  8708. $metadata: deserializeMetadata(output),
  8709. };
  8710. break;
  8711. case "TooManyRequestsException":
  8712. case "com.amazonaws.apigateway#TooManyRequestsException":
  8713. response = {
  8714. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8715. name: errorCode,
  8716. $metadata: deserializeMetadata(output),
  8717. };
  8718. break;
  8719. case "UnauthorizedException":
  8720. case "com.amazonaws.apigateway#UnauthorizedException":
  8721. response = {
  8722. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8723. name: errorCode,
  8724. $metadata: deserializeMetadata(output),
  8725. };
  8726. break;
  8727. default:
  8728. const parsedBody = parsedOutput.body;
  8729. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8730. response = {
  8731. ...parsedBody,
  8732. name: `${errorCode}`,
  8733. message: parsedBody.message || parsedBody.Message || errorCode,
  8734. $fault: "client",
  8735. $metadata: deserializeMetadata(output),
  8736. } as any;
  8737. }
  8738. const message = response.message || response.Message || errorCode;
  8739. response.message = message;
  8740. delete response.Message;
  8741. return Promise.reject(Object.assign(new Error(message), response));
  8742. };
  8743. export const deserializeAws_restJson1DeleteStageCommand = async (
  8744. output: __HttpResponse,
  8745. context: __SerdeContext
  8746. ): Promise<DeleteStageCommandOutput> => {
  8747. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8748. return deserializeAws_restJson1DeleteStageCommandError(output, context);
  8749. }
  8750. const contents: DeleteStageCommandOutput = {
  8751. $metadata: deserializeMetadata(output),
  8752. };
  8753. await collectBody(output.body, context);
  8754. return Promise.resolve(contents);
  8755. };
  8756. const deserializeAws_restJson1DeleteStageCommandError = async (
  8757. output: __HttpResponse,
  8758. context: __SerdeContext
  8759. ): Promise<DeleteStageCommandOutput> => {
  8760. const parsedOutput: any = {
  8761. ...output,
  8762. body: await parseBody(output.body, context),
  8763. };
  8764. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8765. let errorCode: string = "UnknownError";
  8766. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8767. switch (errorCode) {
  8768. case "BadRequestException":
  8769. case "com.amazonaws.apigateway#BadRequestException":
  8770. response = {
  8771. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8772. name: errorCode,
  8773. $metadata: deserializeMetadata(output),
  8774. };
  8775. break;
  8776. case "NotFoundException":
  8777. case "com.amazonaws.apigateway#NotFoundException":
  8778. response = {
  8779. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8780. name: errorCode,
  8781. $metadata: deserializeMetadata(output),
  8782. };
  8783. break;
  8784. case "TooManyRequestsException":
  8785. case "com.amazonaws.apigateway#TooManyRequestsException":
  8786. response = {
  8787. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8788. name: errorCode,
  8789. $metadata: deserializeMetadata(output),
  8790. };
  8791. break;
  8792. case "UnauthorizedException":
  8793. case "com.amazonaws.apigateway#UnauthorizedException":
  8794. response = {
  8795. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8796. name: errorCode,
  8797. $metadata: deserializeMetadata(output),
  8798. };
  8799. break;
  8800. default:
  8801. const parsedBody = parsedOutput.body;
  8802. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8803. response = {
  8804. ...parsedBody,
  8805. name: `${errorCode}`,
  8806. message: parsedBody.message || parsedBody.Message || errorCode,
  8807. $fault: "client",
  8808. $metadata: deserializeMetadata(output),
  8809. } as any;
  8810. }
  8811. const message = response.message || response.Message || errorCode;
  8812. response.message = message;
  8813. delete response.Message;
  8814. return Promise.reject(Object.assign(new Error(message), response));
  8815. };
  8816. export const deserializeAws_restJson1DeleteUsagePlanCommand = async (
  8817. output: __HttpResponse,
  8818. context: __SerdeContext
  8819. ): Promise<DeleteUsagePlanCommandOutput> => {
  8820. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8821. return deserializeAws_restJson1DeleteUsagePlanCommandError(output, context);
  8822. }
  8823. const contents: DeleteUsagePlanCommandOutput = {
  8824. $metadata: deserializeMetadata(output),
  8825. };
  8826. await collectBody(output.body, context);
  8827. return Promise.resolve(contents);
  8828. };
  8829. const deserializeAws_restJson1DeleteUsagePlanCommandError = async (
  8830. output: __HttpResponse,
  8831. context: __SerdeContext
  8832. ): Promise<DeleteUsagePlanCommandOutput> => {
  8833. const parsedOutput: any = {
  8834. ...output,
  8835. body: await parseBody(output.body, context),
  8836. };
  8837. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8838. let errorCode: string = "UnknownError";
  8839. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8840. switch (errorCode) {
  8841. case "BadRequestException":
  8842. case "com.amazonaws.apigateway#BadRequestException":
  8843. response = {
  8844. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8845. name: errorCode,
  8846. $metadata: deserializeMetadata(output),
  8847. };
  8848. break;
  8849. case "NotFoundException":
  8850. case "com.amazonaws.apigateway#NotFoundException":
  8851. response = {
  8852. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8853. name: errorCode,
  8854. $metadata: deserializeMetadata(output),
  8855. };
  8856. break;
  8857. case "TooManyRequestsException":
  8858. case "com.amazonaws.apigateway#TooManyRequestsException":
  8859. response = {
  8860. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8861. name: errorCode,
  8862. $metadata: deserializeMetadata(output),
  8863. };
  8864. break;
  8865. case "UnauthorizedException":
  8866. case "com.amazonaws.apigateway#UnauthorizedException":
  8867. response = {
  8868. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8869. name: errorCode,
  8870. $metadata: deserializeMetadata(output),
  8871. };
  8872. break;
  8873. default:
  8874. const parsedBody = parsedOutput.body;
  8875. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8876. response = {
  8877. ...parsedBody,
  8878. name: `${errorCode}`,
  8879. message: parsedBody.message || parsedBody.Message || errorCode,
  8880. $fault: "client",
  8881. $metadata: deserializeMetadata(output),
  8882. } as any;
  8883. }
  8884. const message = response.message || response.Message || errorCode;
  8885. response.message = message;
  8886. delete response.Message;
  8887. return Promise.reject(Object.assign(new Error(message), response));
  8888. };
  8889. export const deserializeAws_restJson1DeleteUsagePlanKeyCommand = async (
  8890. output: __HttpResponse,
  8891. context: __SerdeContext
  8892. ): Promise<DeleteUsagePlanKeyCommandOutput> => {
  8893. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8894. return deserializeAws_restJson1DeleteUsagePlanKeyCommandError(output, context);
  8895. }
  8896. const contents: DeleteUsagePlanKeyCommandOutput = {
  8897. $metadata: deserializeMetadata(output),
  8898. };
  8899. await collectBody(output.body, context);
  8900. return Promise.resolve(contents);
  8901. };
  8902. const deserializeAws_restJson1DeleteUsagePlanKeyCommandError = async (
  8903. output: __HttpResponse,
  8904. context: __SerdeContext
  8905. ): Promise<DeleteUsagePlanKeyCommandOutput> => {
  8906. const parsedOutput: any = {
  8907. ...output,
  8908. body: await parseBody(output.body, context),
  8909. };
  8910. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8911. let errorCode: string = "UnknownError";
  8912. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8913. switch (errorCode) {
  8914. case "BadRequestException":
  8915. case "com.amazonaws.apigateway#BadRequestException":
  8916. response = {
  8917. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8918. name: errorCode,
  8919. $metadata: deserializeMetadata(output),
  8920. };
  8921. break;
  8922. case "ConflictException":
  8923. case "com.amazonaws.apigateway#ConflictException":
  8924. response = {
  8925. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  8926. name: errorCode,
  8927. $metadata: deserializeMetadata(output),
  8928. };
  8929. break;
  8930. case "NotFoundException":
  8931. case "com.amazonaws.apigateway#NotFoundException":
  8932. response = {
  8933. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  8934. name: errorCode,
  8935. $metadata: deserializeMetadata(output),
  8936. };
  8937. break;
  8938. case "TooManyRequestsException":
  8939. case "com.amazonaws.apigateway#TooManyRequestsException":
  8940. response = {
  8941. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  8942. name: errorCode,
  8943. $metadata: deserializeMetadata(output),
  8944. };
  8945. break;
  8946. case "UnauthorizedException":
  8947. case "com.amazonaws.apigateway#UnauthorizedException":
  8948. response = {
  8949. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  8950. name: errorCode,
  8951. $metadata: deserializeMetadata(output),
  8952. };
  8953. break;
  8954. default:
  8955. const parsedBody = parsedOutput.body;
  8956. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  8957. response = {
  8958. ...parsedBody,
  8959. name: `${errorCode}`,
  8960. message: parsedBody.message || parsedBody.Message || errorCode,
  8961. $fault: "client",
  8962. $metadata: deserializeMetadata(output),
  8963. } as any;
  8964. }
  8965. const message = response.message || response.Message || errorCode;
  8966. response.message = message;
  8967. delete response.Message;
  8968. return Promise.reject(Object.assign(new Error(message), response));
  8969. };
  8970. export const deserializeAws_restJson1DeleteVpcLinkCommand = async (
  8971. output: __HttpResponse,
  8972. context: __SerdeContext
  8973. ): Promise<DeleteVpcLinkCommandOutput> => {
  8974. if (output.statusCode !== 202 && output.statusCode >= 400) {
  8975. return deserializeAws_restJson1DeleteVpcLinkCommandError(output, context);
  8976. }
  8977. const contents: DeleteVpcLinkCommandOutput = {
  8978. $metadata: deserializeMetadata(output),
  8979. };
  8980. await collectBody(output.body, context);
  8981. return Promise.resolve(contents);
  8982. };
  8983. const deserializeAws_restJson1DeleteVpcLinkCommandError = async (
  8984. output: __HttpResponse,
  8985. context: __SerdeContext
  8986. ): Promise<DeleteVpcLinkCommandOutput> => {
  8987. const parsedOutput: any = {
  8988. ...output,
  8989. body: await parseBody(output.body, context),
  8990. };
  8991. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  8992. let errorCode: string = "UnknownError";
  8993. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  8994. switch (errorCode) {
  8995. case "BadRequestException":
  8996. case "com.amazonaws.apigateway#BadRequestException":
  8997. response = {
  8998. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  8999. name: errorCode,
  9000. $metadata: deserializeMetadata(output),
  9001. };
  9002. break;
  9003. case "NotFoundException":
  9004. case "com.amazonaws.apigateway#NotFoundException":
  9005. response = {
  9006. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9007. name: errorCode,
  9008. $metadata: deserializeMetadata(output),
  9009. };
  9010. break;
  9011. case "TooManyRequestsException":
  9012. case "com.amazonaws.apigateway#TooManyRequestsException":
  9013. response = {
  9014. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9015. name: errorCode,
  9016. $metadata: deserializeMetadata(output),
  9017. };
  9018. break;
  9019. case "UnauthorizedException":
  9020. case "com.amazonaws.apigateway#UnauthorizedException":
  9021. response = {
  9022. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9023. name: errorCode,
  9024. $metadata: deserializeMetadata(output),
  9025. };
  9026. break;
  9027. default:
  9028. const parsedBody = parsedOutput.body;
  9029. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9030. response = {
  9031. ...parsedBody,
  9032. name: `${errorCode}`,
  9033. message: parsedBody.message || parsedBody.Message || errorCode,
  9034. $fault: "client",
  9035. $metadata: deserializeMetadata(output),
  9036. } as any;
  9037. }
  9038. const message = response.message || response.Message || errorCode;
  9039. response.message = message;
  9040. delete response.Message;
  9041. return Promise.reject(Object.assign(new Error(message), response));
  9042. };
  9043. export const deserializeAws_restJson1FlushStageAuthorizersCacheCommand = async (
  9044. output: __HttpResponse,
  9045. context: __SerdeContext
  9046. ): Promise<FlushStageAuthorizersCacheCommandOutput> => {
  9047. if (output.statusCode !== 202 && output.statusCode >= 400) {
  9048. return deserializeAws_restJson1FlushStageAuthorizersCacheCommandError(output, context);
  9049. }
  9050. const contents: FlushStageAuthorizersCacheCommandOutput = {
  9051. $metadata: deserializeMetadata(output),
  9052. };
  9053. await collectBody(output.body, context);
  9054. return Promise.resolve(contents);
  9055. };
  9056. const deserializeAws_restJson1FlushStageAuthorizersCacheCommandError = async (
  9057. output: __HttpResponse,
  9058. context: __SerdeContext
  9059. ): Promise<FlushStageAuthorizersCacheCommandOutput> => {
  9060. const parsedOutput: any = {
  9061. ...output,
  9062. body: await parseBody(output.body, context),
  9063. };
  9064. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9065. let errorCode: string = "UnknownError";
  9066. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9067. switch (errorCode) {
  9068. case "BadRequestException":
  9069. case "com.amazonaws.apigateway#BadRequestException":
  9070. response = {
  9071. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  9072. name: errorCode,
  9073. $metadata: deserializeMetadata(output),
  9074. };
  9075. break;
  9076. case "NotFoundException":
  9077. case "com.amazonaws.apigateway#NotFoundException":
  9078. response = {
  9079. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9080. name: errorCode,
  9081. $metadata: deserializeMetadata(output),
  9082. };
  9083. break;
  9084. case "TooManyRequestsException":
  9085. case "com.amazonaws.apigateway#TooManyRequestsException":
  9086. response = {
  9087. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9088. name: errorCode,
  9089. $metadata: deserializeMetadata(output),
  9090. };
  9091. break;
  9092. case "UnauthorizedException":
  9093. case "com.amazonaws.apigateway#UnauthorizedException":
  9094. response = {
  9095. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9096. name: errorCode,
  9097. $metadata: deserializeMetadata(output),
  9098. };
  9099. break;
  9100. default:
  9101. const parsedBody = parsedOutput.body;
  9102. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9103. response = {
  9104. ...parsedBody,
  9105. name: `${errorCode}`,
  9106. message: parsedBody.message || parsedBody.Message || errorCode,
  9107. $fault: "client",
  9108. $metadata: deserializeMetadata(output),
  9109. } as any;
  9110. }
  9111. const message = response.message || response.Message || errorCode;
  9112. response.message = message;
  9113. delete response.Message;
  9114. return Promise.reject(Object.assign(new Error(message), response));
  9115. };
  9116. export const deserializeAws_restJson1FlushStageCacheCommand = async (
  9117. output: __HttpResponse,
  9118. context: __SerdeContext
  9119. ): Promise<FlushStageCacheCommandOutput> => {
  9120. if (output.statusCode !== 202 && output.statusCode >= 400) {
  9121. return deserializeAws_restJson1FlushStageCacheCommandError(output, context);
  9122. }
  9123. const contents: FlushStageCacheCommandOutput = {
  9124. $metadata: deserializeMetadata(output),
  9125. };
  9126. await collectBody(output.body, context);
  9127. return Promise.resolve(contents);
  9128. };
  9129. const deserializeAws_restJson1FlushStageCacheCommandError = async (
  9130. output: __HttpResponse,
  9131. context: __SerdeContext
  9132. ): Promise<FlushStageCacheCommandOutput> => {
  9133. const parsedOutput: any = {
  9134. ...output,
  9135. body: await parseBody(output.body, context),
  9136. };
  9137. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9138. let errorCode: string = "UnknownError";
  9139. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9140. switch (errorCode) {
  9141. case "BadRequestException":
  9142. case "com.amazonaws.apigateway#BadRequestException":
  9143. response = {
  9144. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  9145. name: errorCode,
  9146. $metadata: deserializeMetadata(output),
  9147. };
  9148. break;
  9149. case "NotFoundException":
  9150. case "com.amazonaws.apigateway#NotFoundException":
  9151. response = {
  9152. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9153. name: errorCode,
  9154. $metadata: deserializeMetadata(output),
  9155. };
  9156. break;
  9157. case "TooManyRequestsException":
  9158. case "com.amazonaws.apigateway#TooManyRequestsException":
  9159. response = {
  9160. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9161. name: errorCode,
  9162. $metadata: deserializeMetadata(output),
  9163. };
  9164. break;
  9165. case "UnauthorizedException":
  9166. case "com.amazonaws.apigateway#UnauthorizedException":
  9167. response = {
  9168. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9169. name: errorCode,
  9170. $metadata: deserializeMetadata(output),
  9171. };
  9172. break;
  9173. default:
  9174. const parsedBody = parsedOutput.body;
  9175. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9176. response = {
  9177. ...parsedBody,
  9178. name: `${errorCode}`,
  9179. message: parsedBody.message || parsedBody.Message || errorCode,
  9180. $fault: "client",
  9181. $metadata: deserializeMetadata(output),
  9182. } as any;
  9183. }
  9184. const message = response.message || response.Message || errorCode;
  9185. response.message = message;
  9186. delete response.Message;
  9187. return Promise.reject(Object.assign(new Error(message), response));
  9188. };
  9189. export const deserializeAws_restJson1GenerateClientCertificateCommand = async (
  9190. output: __HttpResponse,
  9191. context: __SerdeContext
  9192. ): Promise<GenerateClientCertificateCommandOutput> => {
  9193. if (output.statusCode !== 201 && output.statusCode >= 400) {
  9194. return deserializeAws_restJson1GenerateClientCertificateCommandError(output, context);
  9195. }
  9196. const contents: GenerateClientCertificateCommandOutput = {
  9197. $metadata: deserializeMetadata(output),
  9198. clientCertificateId: undefined,
  9199. createdDate: undefined,
  9200. description: undefined,
  9201. expirationDate: undefined,
  9202. pemEncodedCertificate: undefined,
  9203. tags: undefined,
  9204. };
  9205. const data: any = await parseBody(output.body, context);
  9206. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  9207. contents.clientCertificateId = data.clientCertificateId;
  9208. }
  9209. if (data.createdDate !== undefined && data.createdDate !== null) {
  9210. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  9211. }
  9212. if (data.description !== undefined && data.description !== null) {
  9213. contents.description = data.description;
  9214. }
  9215. if (data.expirationDate !== undefined && data.expirationDate !== null) {
  9216. contents.expirationDate = new Date(Math.round(data.expirationDate * 1000));
  9217. }
  9218. if (data.pemEncodedCertificate !== undefined && data.pemEncodedCertificate !== null) {
  9219. contents.pemEncodedCertificate = data.pemEncodedCertificate;
  9220. }
  9221. if (data.tags !== undefined && data.tags !== null) {
  9222. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  9223. }
  9224. return Promise.resolve(contents);
  9225. };
  9226. const deserializeAws_restJson1GenerateClientCertificateCommandError = async (
  9227. output: __HttpResponse,
  9228. context: __SerdeContext
  9229. ): Promise<GenerateClientCertificateCommandOutput> => {
  9230. const parsedOutput: any = {
  9231. ...output,
  9232. body: await parseBody(output.body, context),
  9233. };
  9234. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9235. let errorCode: string = "UnknownError";
  9236. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9237. switch (errorCode) {
  9238. case "LimitExceededException":
  9239. case "com.amazonaws.apigateway#LimitExceededException":
  9240. response = {
  9241. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  9242. name: errorCode,
  9243. $metadata: deserializeMetadata(output),
  9244. };
  9245. break;
  9246. case "TooManyRequestsException":
  9247. case "com.amazonaws.apigateway#TooManyRequestsException":
  9248. response = {
  9249. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9250. name: errorCode,
  9251. $metadata: deserializeMetadata(output),
  9252. };
  9253. break;
  9254. case "UnauthorizedException":
  9255. case "com.amazonaws.apigateway#UnauthorizedException":
  9256. response = {
  9257. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9258. name: errorCode,
  9259. $metadata: deserializeMetadata(output),
  9260. };
  9261. break;
  9262. default:
  9263. const parsedBody = parsedOutput.body;
  9264. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9265. response = {
  9266. ...parsedBody,
  9267. name: `${errorCode}`,
  9268. message: parsedBody.message || parsedBody.Message || errorCode,
  9269. $fault: "client",
  9270. $metadata: deserializeMetadata(output),
  9271. } as any;
  9272. }
  9273. const message = response.message || response.Message || errorCode;
  9274. response.message = message;
  9275. delete response.Message;
  9276. return Promise.reject(Object.assign(new Error(message), response));
  9277. };
  9278. export const deserializeAws_restJson1GetAccountCommand = async (
  9279. output: __HttpResponse,
  9280. context: __SerdeContext
  9281. ): Promise<GetAccountCommandOutput> => {
  9282. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9283. return deserializeAws_restJson1GetAccountCommandError(output, context);
  9284. }
  9285. const contents: GetAccountCommandOutput = {
  9286. $metadata: deserializeMetadata(output),
  9287. apiKeyVersion: undefined,
  9288. cloudwatchRoleArn: undefined,
  9289. features: undefined,
  9290. throttleSettings: undefined,
  9291. };
  9292. const data: any = await parseBody(output.body, context);
  9293. if (data.apiKeyVersion !== undefined && data.apiKeyVersion !== null) {
  9294. contents.apiKeyVersion = data.apiKeyVersion;
  9295. }
  9296. if (data.cloudwatchRoleArn !== undefined && data.cloudwatchRoleArn !== null) {
  9297. contents.cloudwatchRoleArn = data.cloudwatchRoleArn;
  9298. }
  9299. if (data.features !== undefined && data.features !== null) {
  9300. contents.features = deserializeAws_restJson1ListOfString(data.features, context);
  9301. }
  9302. if (data.throttleSettings !== undefined && data.throttleSettings !== null) {
  9303. contents.throttleSettings = deserializeAws_restJson1ThrottleSettings(data.throttleSettings, context);
  9304. }
  9305. return Promise.resolve(contents);
  9306. };
  9307. const deserializeAws_restJson1GetAccountCommandError = async (
  9308. output: __HttpResponse,
  9309. context: __SerdeContext
  9310. ): Promise<GetAccountCommandOutput> => {
  9311. const parsedOutput: any = {
  9312. ...output,
  9313. body: await parseBody(output.body, context),
  9314. };
  9315. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9316. let errorCode: string = "UnknownError";
  9317. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9318. switch (errorCode) {
  9319. case "NotFoundException":
  9320. case "com.amazonaws.apigateway#NotFoundException":
  9321. response = {
  9322. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9323. name: errorCode,
  9324. $metadata: deserializeMetadata(output),
  9325. };
  9326. break;
  9327. case "TooManyRequestsException":
  9328. case "com.amazonaws.apigateway#TooManyRequestsException":
  9329. response = {
  9330. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9331. name: errorCode,
  9332. $metadata: deserializeMetadata(output),
  9333. };
  9334. break;
  9335. case "UnauthorizedException":
  9336. case "com.amazonaws.apigateway#UnauthorizedException":
  9337. response = {
  9338. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9339. name: errorCode,
  9340. $metadata: deserializeMetadata(output),
  9341. };
  9342. break;
  9343. default:
  9344. const parsedBody = parsedOutput.body;
  9345. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9346. response = {
  9347. ...parsedBody,
  9348. name: `${errorCode}`,
  9349. message: parsedBody.message || parsedBody.Message || errorCode,
  9350. $fault: "client",
  9351. $metadata: deserializeMetadata(output),
  9352. } as any;
  9353. }
  9354. const message = response.message || response.Message || errorCode;
  9355. response.message = message;
  9356. delete response.Message;
  9357. return Promise.reject(Object.assign(new Error(message), response));
  9358. };
  9359. export const deserializeAws_restJson1GetApiKeyCommand = async (
  9360. output: __HttpResponse,
  9361. context: __SerdeContext
  9362. ): Promise<GetApiKeyCommandOutput> => {
  9363. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9364. return deserializeAws_restJson1GetApiKeyCommandError(output, context);
  9365. }
  9366. const contents: GetApiKeyCommandOutput = {
  9367. $metadata: deserializeMetadata(output),
  9368. createdDate: undefined,
  9369. customerId: undefined,
  9370. description: undefined,
  9371. enabled: undefined,
  9372. id: undefined,
  9373. lastUpdatedDate: undefined,
  9374. name: undefined,
  9375. stageKeys: undefined,
  9376. tags: undefined,
  9377. value: undefined,
  9378. };
  9379. const data: any = await parseBody(output.body, context);
  9380. if (data.createdDate !== undefined && data.createdDate !== null) {
  9381. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  9382. }
  9383. if (data.customerId !== undefined && data.customerId !== null) {
  9384. contents.customerId = data.customerId;
  9385. }
  9386. if (data.description !== undefined && data.description !== null) {
  9387. contents.description = data.description;
  9388. }
  9389. if (data.enabled !== undefined && data.enabled !== null) {
  9390. contents.enabled = data.enabled;
  9391. }
  9392. if (data.id !== undefined && data.id !== null) {
  9393. contents.id = data.id;
  9394. }
  9395. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  9396. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  9397. }
  9398. if (data.name !== undefined && data.name !== null) {
  9399. contents.name = data.name;
  9400. }
  9401. if (data.stageKeys !== undefined && data.stageKeys !== null) {
  9402. contents.stageKeys = deserializeAws_restJson1ListOfString(data.stageKeys, context);
  9403. }
  9404. if (data.tags !== undefined && data.tags !== null) {
  9405. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  9406. }
  9407. if (data.value !== undefined && data.value !== null) {
  9408. contents.value = data.value;
  9409. }
  9410. return Promise.resolve(contents);
  9411. };
  9412. const deserializeAws_restJson1GetApiKeyCommandError = async (
  9413. output: __HttpResponse,
  9414. context: __SerdeContext
  9415. ): Promise<GetApiKeyCommandOutput> => {
  9416. const parsedOutput: any = {
  9417. ...output,
  9418. body: await parseBody(output.body, context),
  9419. };
  9420. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9421. let errorCode: string = "UnknownError";
  9422. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9423. switch (errorCode) {
  9424. case "NotFoundException":
  9425. case "com.amazonaws.apigateway#NotFoundException":
  9426. response = {
  9427. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9428. name: errorCode,
  9429. $metadata: deserializeMetadata(output),
  9430. };
  9431. break;
  9432. case "TooManyRequestsException":
  9433. case "com.amazonaws.apigateway#TooManyRequestsException":
  9434. response = {
  9435. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9436. name: errorCode,
  9437. $metadata: deserializeMetadata(output),
  9438. };
  9439. break;
  9440. case "UnauthorizedException":
  9441. case "com.amazonaws.apigateway#UnauthorizedException":
  9442. response = {
  9443. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9444. name: errorCode,
  9445. $metadata: deserializeMetadata(output),
  9446. };
  9447. break;
  9448. default:
  9449. const parsedBody = parsedOutput.body;
  9450. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9451. response = {
  9452. ...parsedBody,
  9453. name: `${errorCode}`,
  9454. message: parsedBody.message || parsedBody.Message || errorCode,
  9455. $fault: "client",
  9456. $metadata: deserializeMetadata(output),
  9457. } as any;
  9458. }
  9459. const message = response.message || response.Message || errorCode;
  9460. response.message = message;
  9461. delete response.Message;
  9462. return Promise.reject(Object.assign(new Error(message), response));
  9463. };
  9464. export const deserializeAws_restJson1GetApiKeysCommand = async (
  9465. output: __HttpResponse,
  9466. context: __SerdeContext
  9467. ): Promise<GetApiKeysCommandOutput> => {
  9468. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9469. return deserializeAws_restJson1GetApiKeysCommandError(output, context);
  9470. }
  9471. const contents: GetApiKeysCommandOutput = {
  9472. $metadata: deserializeMetadata(output),
  9473. items: undefined,
  9474. position: undefined,
  9475. warnings: undefined,
  9476. };
  9477. const data: any = await parseBody(output.body, context);
  9478. if (data.item !== undefined && data.item !== null) {
  9479. contents.items = deserializeAws_restJson1ListOfApiKey(data.item, context);
  9480. }
  9481. if (data.position !== undefined && data.position !== null) {
  9482. contents.position = data.position;
  9483. }
  9484. if (data.warnings !== undefined && data.warnings !== null) {
  9485. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  9486. }
  9487. return Promise.resolve(contents);
  9488. };
  9489. const deserializeAws_restJson1GetApiKeysCommandError = async (
  9490. output: __HttpResponse,
  9491. context: __SerdeContext
  9492. ): Promise<GetApiKeysCommandOutput> => {
  9493. const parsedOutput: any = {
  9494. ...output,
  9495. body: await parseBody(output.body, context),
  9496. };
  9497. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9498. let errorCode: string = "UnknownError";
  9499. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9500. switch (errorCode) {
  9501. case "BadRequestException":
  9502. case "com.amazonaws.apigateway#BadRequestException":
  9503. response = {
  9504. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  9505. name: errorCode,
  9506. $metadata: deserializeMetadata(output),
  9507. };
  9508. break;
  9509. case "TooManyRequestsException":
  9510. case "com.amazonaws.apigateway#TooManyRequestsException":
  9511. response = {
  9512. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9513. name: errorCode,
  9514. $metadata: deserializeMetadata(output),
  9515. };
  9516. break;
  9517. case "UnauthorizedException":
  9518. case "com.amazonaws.apigateway#UnauthorizedException":
  9519. response = {
  9520. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9521. name: errorCode,
  9522. $metadata: deserializeMetadata(output),
  9523. };
  9524. break;
  9525. default:
  9526. const parsedBody = parsedOutput.body;
  9527. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9528. response = {
  9529. ...parsedBody,
  9530. name: `${errorCode}`,
  9531. message: parsedBody.message || parsedBody.Message || errorCode,
  9532. $fault: "client",
  9533. $metadata: deserializeMetadata(output),
  9534. } as any;
  9535. }
  9536. const message = response.message || response.Message || errorCode;
  9537. response.message = message;
  9538. delete response.Message;
  9539. return Promise.reject(Object.assign(new Error(message), response));
  9540. };
  9541. export const deserializeAws_restJson1GetAuthorizerCommand = async (
  9542. output: __HttpResponse,
  9543. context: __SerdeContext
  9544. ): Promise<GetAuthorizerCommandOutput> => {
  9545. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9546. return deserializeAws_restJson1GetAuthorizerCommandError(output, context);
  9547. }
  9548. const contents: GetAuthorizerCommandOutput = {
  9549. $metadata: deserializeMetadata(output),
  9550. authType: undefined,
  9551. authorizerCredentials: undefined,
  9552. authorizerResultTtlInSeconds: undefined,
  9553. authorizerUri: undefined,
  9554. id: undefined,
  9555. identitySource: undefined,
  9556. identityValidationExpression: undefined,
  9557. name: undefined,
  9558. providerARNs: undefined,
  9559. type: undefined,
  9560. };
  9561. const data: any = await parseBody(output.body, context);
  9562. if (data.authType !== undefined && data.authType !== null) {
  9563. contents.authType = data.authType;
  9564. }
  9565. if (data.authorizerCredentials !== undefined && data.authorizerCredentials !== null) {
  9566. contents.authorizerCredentials = data.authorizerCredentials;
  9567. }
  9568. if (data.authorizerResultTtlInSeconds !== undefined && data.authorizerResultTtlInSeconds !== null) {
  9569. contents.authorizerResultTtlInSeconds = data.authorizerResultTtlInSeconds;
  9570. }
  9571. if (data.authorizerUri !== undefined && data.authorizerUri !== null) {
  9572. contents.authorizerUri = data.authorizerUri;
  9573. }
  9574. if (data.id !== undefined && data.id !== null) {
  9575. contents.id = data.id;
  9576. }
  9577. if (data.identitySource !== undefined && data.identitySource !== null) {
  9578. contents.identitySource = data.identitySource;
  9579. }
  9580. if (data.identityValidationExpression !== undefined && data.identityValidationExpression !== null) {
  9581. contents.identityValidationExpression = data.identityValidationExpression;
  9582. }
  9583. if (data.name !== undefined && data.name !== null) {
  9584. contents.name = data.name;
  9585. }
  9586. if (data.providerARNs !== undefined && data.providerARNs !== null) {
  9587. contents.providerARNs = deserializeAws_restJson1ListOfARNs(data.providerARNs, context);
  9588. }
  9589. if (data.type !== undefined && data.type !== null) {
  9590. contents.type = data.type;
  9591. }
  9592. return Promise.resolve(contents);
  9593. };
  9594. const deserializeAws_restJson1GetAuthorizerCommandError = async (
  9595. output: __HttpResponse,
  9596. context: __SerdeContext
  9597. ): Promise<GetAuthorizerCommandOutput> => {
  9598. const parsedOutput: any = {
  9599. ...output,
  9600. body: await parseBody(output.body, context),
  9601. };
  9602. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9603. let errorCode: string = "UnknownError";
  9604. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9605. switch (errorCode) {
  9606. case "NotFoundException":
  9607. case "com.amazonaws.apigateway#NotFoundException":
  9608. response = {
  9609. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9610. name: errorCode,
  9611. $metadata: deserializeMetadata(output),
  9612. };
  9613. break;
  9614. case "TooManyRequestsException":
  9615. case "com.amazonaws.apigateway#TooManyRequestsException":
  9616. response = {
  9617. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9618. name: errorCode,
  9619. $metadata: deserializeMetadata(output),
  9620. };
  9621. break;
  9622. case "UnauthorizedException":
  9623. case "com.amazonaws.apigateway#UnauthorizedException":
  9624. response = {
  9625. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9626. name: errorCode,
  9627. $metadata: deserializeMetadata(output),
  9628. };
  9629. break;
  9630. default:
  9631. const parsedBody = parsedOutput.body;
  9632. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9633. response = {
  9634. ...parsedBody,
  9635. name: `${errorCode}`,
  9636. message: parsedBody.message || parsedBody.Message || errorCode,
  9637. $fault: "client",
  9638. $metadata: deserializeMetadata(output),
  9639. } as any;
  9640. }
  9641. const message = response.message || response.Message || errorCode;
  9642. response.message = message;
  9643. delete response.Message;
  9644. return Promise.reject(Object.assign(new Error(message), response));
  9645. };
  9646. export const deserializeAws_restJson1GetAuthorizersCommand = async (
  9647. output: __HttpResponse,
  9648. context: __SerdeContext
  9649. ): Promise<GetAuthorizersCommandOutput> => {
  9650. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9651. return deserializeAws_restJson1GetAuthorizersCommandError(output, context);
  9652. }
  9653. const contents: GetAuthorizersCommandOutput = {
  9654. $metadata: deserializeMetadata(output),
  9655. items: undefined,
  9656. position: undefined,
  9657. };
  9658. const data: any = await parseBody(output.body, context);
  9659. if (data.item !== undefined && data.item !== null) {
  9660. contents.items = deserializeAws_restJson1ListOfAuthorizer(data.item, context);
  9661. }
  9662. if (data.position !== undefined && data.position !== null) {
  9663. contents.position = data.position;
  9664. }
  9665. return Promise.resolve(contents);
  9666. };
  9667. const deserializeAws_restJson1GetAuthorizersCommandError = async (
  9668. output: __HttpResponse,
  9669. context: __SerdeContext
  9670. ): Promise<GetAuthorizersCommandOutput> => {
  9671. const parsedOutput: any = {
  9672. ...output,
  9673. body: await parseBody(output.body, context),
  9674. };
  9675. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9676. let errorCode: string = "UnknownError";
  9677. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9678. switch (errorCode) {
  9679. case "BadRequestException":
  9680. case "com.amazonaws.apigateway#BadRequestException":
  9681. response = {
  9682. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  9683. name: errorCode,
  9684. $metadata: deserializeMetadata(output),
  9685. };
  9686. break;
  9687. case "NotFoundException":
  9688. case "com.amazonaws.apigateway#NotFoundException":
  9689. response = {
  9690. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9691. name: errorCode,
  9692. $metadata: deserializeMetadata(output),
  9693. };
  9694. break;
  9695. case "TooManyRequestsException":
  9696. case "com.amazonaws.apigateway#TooManyRequestsException":
  9697. response = {
  9698. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9699. name: errorCode,
  9700. $metadata: deserializeMetadata(output),
  9701. };
  9702. break;
  9703. case "UnauthorizedException":
  9704. case "com.amazonaws.apigateway#UnauthorizedException":
  9705. response = {
  9706. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9707. name: errorCode,
  9708. $metadata: deserializeMetadata(output),
  9709. };
  9710. break;
  9711. default:
  9712. const parsedBody = parsedOutput.body;
  9713. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9714. response = {
  9715. ...parsedBody,
  9716. name: `${errorCode}`,
  9717. message: parsedBody.message || parsedBody.Message || errorCode,
  9718. $fault: "client",
  9719. $metadata: deserializeMetadata(output),
  9720. } as any;
  9721. }
  9722. const message = response.message || response.Message || errorCode;
  9723. response.message = message;
  9724. delete response.Message;
  9725. return Promise.reject(Object.assign(new Error(message), response));
  9726. };
  9727. export const deserializeAws_restJson1GetBasePathMappingCommand = async (
  9728. output: __HttpResponse,
  9729. context: __SerdeContext
  9730. ): Promise<GetBasePathMappingCommandOutput> => {
  9731. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9732. return deserializeAws_restJson1GetBasePathMappingCommandError(output, context);
  9733. }
  9734. const contents: GetBasePathMappingCommandOutput = {
  9735. $metadata: deserializeMetadata(output),
  9736. basePath: undefined,
  9737. restApiId: undefined,
  9738. stage: undefined,
  9739. };
  9740. const data: any = await parseBody(output.body, context);
  9741. if (data.basePath !== undefined && data.basePath !== null) {
  9742. contents.basePath = data.basePath;
  9743. }
  9744. if (data.restApiId !== undefined && data.restApiId !== null) {
  9745. contents.restApiId = data.restApiId;
  9746. }
  9747. if (data.stage !== undefined && data.stage !== null) {
  9748. contents.stage = data.stage;
  9749. }
  9750. return Promise.resolve(contents);
  9751. };
  9752. const deserializeAws_restJson1GetBasePathMappingCommandError = async (
  9753. output: __HttpResponse,
  9754. context: __SerdeContext
  9755. ): Promise<GetBasePathMappingCommandOutput> => {
  9756. const parsedOutput: any = {
  9757. ...output,
  9758. body: await parseBody(output.body, context),
  9759. };
  9760. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9761. let errorCode: string = "UnknownError";
  9762. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9763. switch (errorCode) {
  9764. case "NotFoundException":
  9765. case "com.amazonaws.apigateway#NotFoundException":
  9766. response = {
  9767. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9768. name: errorCode,
  9769. $metadata: deserializeMetadata(output),
  9770. };
  9771. break;
  9772. case "TooManyRequestsException":
  9773. case "com.amazonaws.apigateway#TooManyRequestsException":
  9774. response = {
  9775. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9776. name: errorCode,
  9777. $metadata: deserializeMetadata(output),
  9778. };
  9779. break;
  9780. case "UnauthorizedException":
  9781. case "com.amazonaws.apigateway#UnauthorizedException":
  9782. response = {
  9783. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9784. name: errorCode,
  9785. $metadata: deserializeMetadata(output),
  9786. };
  9787. break;
  9788. default:
  9789. const parsedBody = parsedOutput.body;
  9790. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9791. response = {
  9792. ...parsedBody,
  9793. name: `${errorCode}`,
  9794. message: parsedBody.message || parsedBody.Message || errorCode,
  9795. $fault: "client",
  9796. $metadata: deserializeMetadata(output),
  9797. } as any;
  9798. }
  9799. const message = response.message || response.Message || errorCode;
  9800. response.message = message;
  9801. delete response.Message;
  9802. return Promise.reject(Object.assign(new Error(message), response));
  9803. };
  9804. export const deserializeAws_restJson1GetBasePathMappingsCommand = async (
  9805. output: __HttpResponse,
  9806. context: __SerdeContext
  9807. ): Promise<GetBasePathMappingsCommandOutput> => {
  9808. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9809. return deserializeAws_restJson1GetBasePathMappingsCommandError(output, context);
  9810. }
  9811. const contents: GetBasePathMappingsCommandOutput = {
  9812. $metadata: deserializeMetadata(output),
  9813. items: undefined,
  9814. position: undefined,
  9815. };
  9816. const data: any = await parseBody(output.body, context);
  9817. if (data.item !== undefined && data.item !== null) {
  9818. contents.items = deserializeAws_restJson1ListOfBasePathMapping(data.item, context);
  9819. }
  9820. if (data.position !== undefined && data.position !== null) {
  9821. contents.position = data.position;
  9822. }
  9823. return Promise.resolve(contents);
  9824. };
  9825. const deserializeAws_restJson1GetBasePathMappingsCommandError = async (
  9826. output: __HttpResponse,
  9827. context: __SerdeContext
  9828. ): Promise<GetBasePathMappingsCommandOutput> => {
  9829. const parsedOutput: any = {
  9830. ...output,
  9831. body: await parseBody(output.body, context),
  9832. };
  9833. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9834. let errorCode: string = "UnknownError";
  9835. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9836. switch (errorCode) {
  9837. case "NotFoundException":
  9838. case "com.amazonaws.apigateway#NotFoundException":
  9839. response = {
  9840. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9841. name: errorCode,
  9842. $metadata: deserializeMetadata(output),
  9843. };
  9844. break;
  9845. case "TooManyRequestsException":
  9846. case "com.amazonaws.apigateway#TooManyRequestsException":
  9847. response = {
  9848. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9849. name: errorCode,
  9850. $metadata: deserializeMetadata(output),
  9851. };
  9852. break;
  9853. case "UnauthorizedException":
  9854. case "com.amazonaws.apigateway#UnauthorizedException":
  9855. response = {
  9856. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9857. name: errorCode,
  9858. $metadata: deserializeMetadata(output),
  9859. };
  9860. break;
  9861. default:
  9862. const parsedBody = parsedOutput.body;
  9863. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9864. response = {
  9865. ...parsedBody,
  9866. name: `${errorCode}`,
  9867. message: parsedBody.message || parsedBody.Message || errorCode,
  9868. $fault: "client",
  9869. $metadata: deserializeMetadata(output),
  9870. } as any;
  9871. }
  9872. const message = response.message || response.Message || errorCode;
  9873. response.message = message;
  9874. delete response.Message;
  9875. return Promise.reject(Object.assign(new Error(message), response));
  9876. };
  9877. export const deserializeAws_restJson1GetClientCertificateCommand = async (
  9878. output: __HttpResponse,
  9879. context: __SerdeContext
  9880. ): Promise<GetClientCertificateCommandOutput> => {
  9881. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9882. return deserializeAws_restJson1GetClientCertificateCommandError(output, context);
  9883. }
  9884. const contents: GetClientCertificateCommandOutput = {
  9885. $metadata: deserializeMetadata(output),
  9886. clientCertificateId: undefined,
  9887. createdDate: undefined,
  9888. description: undefined,
  9889. expirationDate: undefined,
  9890. pemEncodedCertificate: undefined,
  9891. tags: undefined,
  9892. };
  9893. const data: any = await parseBody(output.body, context);
  9894. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  9895. contents.clientCertificateId = data.clientCertificateId;
  9896. }
  9897. if (data.createdDate !== undefined && data.createdDate !== null) {
  9898. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  9899. }
  9900. if (data.description !== undefined && data.description !== null) {
  9901. contents.description = data.description;
  9902. }
  9903. if (data.expirationDate !== undefined && data.expirationDate !== null) {
  9904. contents.expirationDate = new Date(Math.round(data.expirationDate * 1000));
  9905. }
  9906. if (data.pemEncodedCertificate !== undefined && data.pemEncodedCertificate !== null) {
  9907. contents.pemEncodedCertificate = data.pemEncodedCertificate;
  9908. }
  9909. if (data.tags !== undefined && data.tags !== null) {
  9910. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  9911. }
  9912. return Promise.resolve(contents);
  9913. };
  9914. const deserializeAws_restJson1GetClientCertificateCommandError = async (
  9915. output: __HttpResponse,
  9916. context: __SerdeContext
  9917. ): Promise<GetClientCertificateCommandOutput> => {
  9918. const parsedOutput: any = {
  9919. ...output,
  9920. body: await parseBody(output.body, context),
  9921. };
  9922. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9923. let errorCode: string = "UnknownError";
  9924. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9925. switch (errorCode) {
  9926. case "NotFoundException":
  9927. case "com.amazonaws.apigateway#NotFoundException":
  9928. response = {
  9929. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  9930. name: errorCode,
  9931. $metadata: deserializeMetadata(output),
  9932. };
  9933. break;
  9934. case "TooManyRequestsException":
  9935. case "com.amazonaws.apigateway#TooManyRequestsException":
  9936. response = {
  9937. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  9938. name: errorCode,
  9939. $metadata: deserializeMetadata(output),
  9940. };
  9941. break;
  9942. case "UnauthorizedException":
  9943. case "com.amazonaws.apigateway#UnauthorizedException":
  9944. response = {
  9945. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  9946. name: errorCode,
  9947. $metadata: deserializeMetadata(output),
  9948. };
  9949. break;
  9950. default:
  9951. const parsedBody = parsedOutput.body;
  9952. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  9953. response = {
  9954. ...parsedBody,
  9955. name: `${errorCode}`,
  9956. message: parsedBody.message || parsedBody.Message || errorCode,
  9957. $fault: "client",
  9958. $metadata: deserializeMetadata(output),
  9959. } as any;
  9960. }
  9961. const message = response.message || response.Message || errorCode;
  9962. response.message = message;
  9963. delete response.Message;
  9964. return Promise.reject(Object.assign(new Error(message), response));
  9965. };
  9966. export const deserializeAws_restJson1GetClientCertificatesCommand = async (
  9967. output: __HttpResponse,
  9968. context: __SerdeContext
  9969. ): Promise<GetClientCertificatesCommandOutput> => {
  9970. if (output.statusCode !== 200 && output.statusCode >= 400) {
  9971. return deserializeAws_restJson1GetClientCertificatesCommandError(output, context);
  9972. }
  9973. const contents: GetClientCertificatesCommandOutput = {
  9974. $metadata: deserializeMetadata(output),
  9975. items: undefined,
  9976. position: undefined,
  9977. };
  9978. const data: any = await parseBody(output.body, context);
  9979. if (data.item !== undefined && data.item !== null) {
  9980. contents.items = deserializeAws_restJson1ListOfClientCertificate(data.item, context);
  9981. }
  9982. if (data.position !== undefined && data.position !== null) {
  9983. contents.position = data.position;
  9984. }
  9985. return Promise.resolve(contents);
  9986. };
  9987. const deserializeAws_restJson1GetClientCertificatesCommandError = async (
  9988. output: __HttpResponse,
  9989. context: __SerdeContext
  9990. ): Promise<GetClientCertificatesCommandOutput> => {
  9991. const parsedOutput: any = {
  9992. ...output,
  9993. body: await parseBody(output.body, context),
  9994. };
  9995. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  9996. let errorCode: string = "UnknownError";
  9997. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  9998. switch (errorCode) {
  9999. case "BadRequestException":
  10000. case "com.amazonaws.apigateway#BadRequestException":
  10001. response = {
  10002. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10003. name: errorCode,
  10004. $metadata: deserializeMetadata(output),
  10005. };
  10006. break;
  10007. case "TooManyRequestsException":
  10008. case "com.amazonaws.apigateway#TooManyRequestsException":
  10009. response = {
  10010. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10011. name: errorCode,
  10012. $metadata: deserializeMetadata(output),
  10013. };
  10014. break;
  10015. case "UnauthorizedException":
  10016. case "com.amazonaws.apigateway#UnauthorizedException":
  10017. response = {
  10018. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10019. name: errorCode,
  10020. $metadata: deserializeMetadata(output),
  10021. };
  10022. break;
  10023. default:
  10024. const parsedBody = parsedOutput.body;
  10025. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10026. response = {
  10027. ...parsedBody,
  10028. name: `${errorCode}`,
  10029. message: parsedBody.message || parsedBody.Message || errorCode,
  10030. $fault: "client",
  10031. $metadata: deserializeMetadata(output),
  10032. } as any;
  10033. }
  10034. const message = response.message || response.Message || errorCode;
  10035. response.message = message;
  10036. delete response.Message;
  10037. return Promise.reject(Object.assign(new Error(message), response));
  10038. };
  10039. export const deserializeAws_restJson1GetDeploymentCommand = async (
  10040. output: __HttpResponse,
  10041. context: __SerdeContext
  10042. ): Promise<GetDeploymentCommandOutput> => {
  10043. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10044. return deserializeAws_restJson1GetDeploymentCommandError(output, context);
  10045. }
  10046. const contents: GetDeploymentCommandOutput = {
  10047. $metadata: deserializeMetadata(output),
  10048. apiSummary: undefined,
  10049. createdDate: undefined,
  10050. description: undefined,
  10051. id: undefined,
  10052. };
  10053. const data: any = await parseBody(output.body, context);
  10054. if (data.apiSummary !== undefined && data.apiSummary !== null) {
  10055. contents.apiSummary = deserializeAws_restJson1PathToMapOfMethodSnapshot(data.apiSummary, context);
  10056. }
  10057. if (data.createdDate !== undefined && data.createdDate !== null) {
  10058. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  10059. }
  10060. if (data.description !== undefined && data.description !== null) {
  10061. contents.description = data.description;
  10062. }
  10063. if (data.id !== undefined && data.id !== null) {
  10064. contents.id = data.id;
  10065. }
  10066. return Promise.resolve(contents);
  10067. };
  10068. const deserializeAws_restJson1GetDeploymentCommandError = async (
  10069. output: __HttpResponse,
  10070. context: __SerdeContext
  10071. ): Promise<GetDeploymentCommandOutput> => {
  10072. const parsedOutput: any = {
  10073. ...output,
  10074. body: await parseBody(output.body, context),
  10075. };
  10076. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10077. let errorCode: string = "UnknownError";
  10078. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10079. switch (errorCode) {
  10080. case "NotFoundException":
  10081. case "com.amazonaws.apigateway#NotFoundException":
  10082. response = {
  10083. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10084. name: errorCode,
  10085. $metadata: deserializeMetadata(output),
  10086. };
  10087. break;
  10088. case "ServiceUnavailableException":
  10089. case "com.amazonaws.apigateway#ServiceUnavailableException":
  10090. response = {
  10091. ...(await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context)),
  10092. name: errorCode,
  10093. $metadata: deserializeMetadata(output),
  10094. };
  10095. break;
  10096. case "TooManyRequestsException":
  10097. case "com.amazonaws.apigateway#TooManyRequestsException":
  10098. response = {
  10099. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10100. name: errorCode,
  10101. $metadata: deserializeMetadata(output),
  10102. };
  10103. break;
  10104. case "UnauthorizedException":
  10105. case "com.amazonaws.apigateway#UnauthorizedException":
  10106. response = {
  10107. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10108. name: errorCode,
  10109. $metadata: deserializeMetadata(output),
  10110. };
  10111. break;
  10112. default:
  10113. const parsedBody = parsedOutput.body;
  10114. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10115. response = {
  10116. ...parsedBody,
  10117. name: `${errorCode}`,
  10118. message: parsedBody.message || parsedBody.Message || errorCode,
  10119. $fault: "client",
  10120. $metadata: deserializeMetadata(output),
  10121. } as any;
  10122. }
  10123. const message = response.message || response.Message || errorCode;
  10124. response.message = message;
  10125. delete response.Message;
  10126. return Promise.reject(Object.assign(new Error(message), response));
  10127. };
  10128. export const deserializeAws_restJson1GetDeploymentsCommand = async (
  10129. output: __HttpResponse,
  10130. context: __SerdeContext
  10131. ): Promise<GetDeploymentsCommandOutput> => {
  10132. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10133. return deserializeAws_restJson1GetDeploymentsCommandError(output, context);
  10134. }
  10135. const contents: GetDeploymentsCommandOutput = {
  10136. $metadata: deserializeMetadata(output),
  10137. items: undefined,
  10138. position: undefined,
  10139. };
  10140. const data: any = await parseBody(output.body, context);
  10141. if (data.item !== undefined && data.item !== null) {
  10142. contents.items = deserializeAws_restJson1ListOfDeployment(data.item, context);
  10143. }
  10144. if (data.position !== undefined && data.position !== null) {
  10145. contents.position = data.position;
  10146. }
  10147. return Promise.resolve(contents);
  10148. };
  10149. const deserializeAws_restJson1GetDeploymentsCommandError = async (
  10150. output: __HttpResponse,
  10151. context: __SerdeContext
  10152. ): Promise<GetDeploymentsCommandOutput> => {
  10153. const parsedOutput: any = {
  10154. ...output,
  10155. body: await parseBody(output.body, context),
  10156. };
  10157. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10158. let errorCode: string = "UnknownError";
  10159. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10160. switch (errorCode) {
  10161. case "BadRequestException":
  10162. case "com.amazonaws.apigateway#BadRequestException":
  10163. response = {
  10164. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10165. name: errorCode,
  10166. $metadata: deserializeMetadata(output),
  10167. };
  10168. break;
  10169. case "ServiceUnavailableException":
  10170. case "com.amazonaws.apigateway#ServiceUnavailableException":
  10171. response = {
  10172. ...(await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context)),
  10173. name: errorCode,
  10174. $metadata: deserializeMetadata(output),
  10175. };
  10176. break;
  10177. case "TooManyRequestsException":
  10178. case "com.amazonaws.apigateway#TooManyRequestsException":
  10179. response = {
  10180. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10181. name: errorCode,
  10182. $metadata: deserializeMetadata(output),
  10183. };
  10184. break;
  10185. case "UnauthorizedException":
  10186. case "com.amazonaws.apigateway#UnauthorizedException":
  10187. response = {
  10188. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10189. name: errorCode,
  10190. $metadata: deserializeMetadata(output),
  10191. };
  10192. break;
  10193. default:
  10194. const parsedBody = parsedOutput.body;
  10195. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10196. response = {
  10197. ...parsedBody,
  10198. name: `${errorCode}`,
  10199. message: parsedBody.message || parsedBody.Message || errorCode,
  10200. $fault: "client",
  10201. $metadata: deserializeMetadata(output),
  10202. } as any;
  10203. }
  10204. const message = response.message || response.Message || errorCode;
  10205. response.message = message;
  10206. delete response.Message;
  10207. return Promise.reject(Object.assign(new Error(message), response));
  10208. };
  10209. export const deserializeAws_restJson1GetDocumentationPartCommand = async (
  10210. output: __HttpResponse,
  10211. context: __SerdeContext
  10212. ): Promise<GetDocumentationPartCommandOutput> => {
  10213. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10214. return deserializeAws_restJson1GetDocumentationPartCommandError(output, context);
  10215. }
  10216. const contents: GetDocumentationPartCommandOutput = {
  10217. $metadata: deserializeMetadata(output),
  10218. id: undefined,
  10219. location: undefined,
  10220. properties: undefined,
  10221. };
  10222. const data: any = await parseBody(output.body, context);
  10223. if (data.id !== undefined && data.id !== null) {
  10224. contents.id = data.id;
  10225. }
  10226. if (data.location !== undefined && data.location !== null) {
  10227. contents.location = deserializeAws_restJson1DocumentationPartLocation(data.location, context);
  10228. }
  10229. if (data.properties !== undefined && data.properties !== null) {
  10230. contents.properties = data.properties;
  10231. }
  10232. return Promise.resolve(contents);
  10233. };
  10234. const deserializeAws_restJson1GetDocumentationPartCommandError = async (
  10235. output: __HttpResponse,
  10236. context: __SerdeContext
  10237. ): Promise<GetDocumentationPartCommandOutput> => {
  10238. const parsedOutput: any = {
  10239. ...output,
  10240. body: await parseBody(output.body, context),
  10241. };
  10242. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10243. let errorCode: string = "UnknownError";
  10244. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10245. switch (errorCode) {
  10246. case "NotFoundException":
  10247. case "com.amazonaws.apigateway#NotFoundException":
  10248. response = {
  10249. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10250. name: errorCode,
  10251. $metadata: deserializeMetadata(output),
  10252. };
  10253. break;
  10254. case "TooManyRequestsException":
  10255. case "com.amazonaws.apigateway#TooManyRequestsException":
  10256. response = {
  10257. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10258. name: errorCode,
  10259. $metadata: deserializeMetadata(output),
  10260. };
  10261. break;
  10262. case "UnauthorizedException":
  10263. case "com.amazonaws.apigateway#UnauthorizedException":
  10264. response = {
  10265. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10266. name: errorCode,
  10267. $metadata: deserializeMetadata(output),
  10268. };
  10269. break;
  10270. default:
  10271. const parsedBody = parsedOutput.body;
  10272. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10273. response = {
  10274. ...parsedBody,
  10275. name: `${errorCode}`,
  10276. message: parsedBody.message || parsedBody.Message || errorCode,
  10277. $fault: "client",
  10278. $metadata: deserializeMetadata(output),
  10279. } as any;
  10280. }
  10281. const message = response.message || response.Message || errorCode;
  10282. response.message = message;
  10283. delete response.Message;
  10284. return Promise.reject(Object.assign(new Error(message), response));
  10285. };
  10286. export const deserializeAws_restJson1GetDocumentationPartsCommand = async (
  10287. output: __HttpResponse,
  10288. context: __SerdeContext
  10289. ): Promise<GetDocumentationPartsCommandOutput> => {
  10290. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10291. return deserializeAws_restJson1GetDocumentationPartsCommandError(output, context);
  10292. }
  10293. const contents: GetDocumentationPartsCommandOutput = {
  10294. $metadata: deserializeMetadata(output),
  10295. items: undefined,
  10296. position: undefined,
  10297. };
  10298. const data: any = await parseBody(output.body, context);
  10299. if (data.item !== undefined && data.item !== null) {
  10300. contents.items = deserializeAws_restJson1ListOfDocumentationPart(data.item, context);
  10301. }
  10302. if (data.position !== undefined && data.position !== null) {
  10303. contents.position = data.position;
  10304. }
  10305. return Promise.resolve(contents);
  10306. };
  10307. const deserializeAws_restJson1GetDocumentationPartsCommandError = async (
  10308. output: __HttpResponse,
  10309. context: __SerdeContext
  10310. ): Promise<GetDocumentationPartsCommandOutput> => {
  10311. const parsedOutput: any = {
  10312. ...output,
  10313. body: await parseBody(output.body, context),
  10314. };
  10315. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10316. let errorCode: string = "UnknownError";
  10317. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10318. switch (errorCode) {
  10319. case "BadRequestException":
  10320. case "com.amazonaws.apigateway#BadRequestException":
  10321. response = {
  10322. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10323. name: errorCode,
  10324. $metadata: deserializeMetadata(output),
  10325. };
  10326. break;
  10327. case "NotFoundException":
  10328. case "com.amazonaws.apigateway#NotFoundException":
  10329. response = {
  10330. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10331. name: errorCode,
  10332. $metadata: deserializeMetadata(output),
  10333. };
  10334. break;
  10335. case "TooManyRequestsException":
  10336. case "com.amazonaws.apigateway#TooManyRequestsException":
  10337. response = {
  10338. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10339. name: errorCode,
  10340. $metadata: deserializeMetadata(output),
  10341. };
  10342. break;
  10343. case "UnauthorizedException":
  10344. case "com.amazonaws.apigateway#UnauthorizedException":
  10345. response = {
  10346. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10347. name: errorCode,
  10348. $metadata: deserializeMetadata(output),
  10349. };
  10350. break;
  10351. default:
  10352. const parsedBody = parsedOutput.body;
  10353. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10354. response = {
  10355. ...parsedBody,
  10356. name: `${errorCode}`,
  10357. message: parsedBody.message || parsedBody.Message || errorCode,
  10358. $fault: "client",
  10359. $metadata: deserializeMetadata(output),
  10360. } as any;
  10361. }
  10362. const message = response.message || response.Message || errorCode;
  10363. response.message = message;
  10364. delete response.Message;
  10365. return Promise.reject(Object.assign(new Error(message), response));
  10366. };
  10367. export const deserializeAws_restJson1GetDocumentationVersionCommand = async (
  10368. output: __HttpResponse,
  10369. context: __SerdeContext
  10370. ): Promise<GetDocumentationVersionCommandOutput> => {
  10371. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10372. return deserializeAws_restJson1GetDocumentationVersionCommandError(output, context);
  10373. }
  10374. const contents: GetDocumentationVersionCommandOutput = {
  10375. $metadata: deserializeMetadata(output),
  10376. createdDate: undefined,
  10377. description: undefined,
  10378. version: undefined,
  10379. };
  10380. const data: any = await parseBody(output.body, context);
  10381. if (data.createdDate !== undefined && data.createdDate !== null) {
  10382. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  10383. }
  10384. if (data.description !== undefined && data.description !== null) {
  10385. contents.description = data.description;
  10386. }
  10387. if (data.version !== undefined && data.version !== null) {
  10388. contents.version = data.version;
  10389. }
  10390. return Promise.resolve(contents);
  10391. };
  10392. const deserializeAws_restJson1GetDocumentationVersionCommandError = async (
  10393. output: __HttpResponse,
  10394. context: __SerdeContext
  10395. ): Promise<GetDocumentationVersionCommandOutput> => {
  10396. const parsedOutput: any = {
  10397. ...output,
  10398. body: await parseBody(output.body, context),
  10399. };
  10400. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10401. let errorCode: string = "UnknownError";
  10402. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10403. switch (errorCode) {
  10404. case "NotFoundException":
  10405. case "com.amazonaws.apigateway#NotFoundException":
  10406. response = {
  10407. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10408. name: errorCode,
  10409. $metadata: deserializeMetadata(output),
  10410. };
  10411. break;
  10412. case "TooManyRequestsException":
  10413. case "com.amazonaws.apigateway#TooManyRequestsException":
  10414. response = {
  10415. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10416. name: errorCode,
  10417. $metadata: deserializeMetadata(output),
  10418. };
  10419. break;
  10420. case "UnauthorizedException":
  10421. case "com.amazonaws.apigateway#UnauthorizedException":
  10422. response = {
  10423. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10424. name: errorCode,
  10425. $metadata: deserializeMetadata(output),
  10426. };
  10427. break;
  10428. default:
  10429. const parsedBody = parsedOutput.body;
  10430. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10431. response = {
  10432. ...parsedBody,
  10433. name: `${errorCode}`,
  10434. message: parsedBody.message || parsedBody.Message || errorCode,
  10435. $fault: "client",
  10436. $metadata: deserializeMetadata(output),
  10437. } as any;
  10438. }
  10439. const message = response.message || response.Message || errorCode;
  10440. response.message = message;
  10441. delete response.Message;
  10442. return Promise.reject(Object.assign(new Error(message), response));
  10443. };
  10444. export const deserializeAws_restJson1GetDocumentationVersionsCommand = async (
  10445. output: __HttpResponse,
  10446. context: __SerdeContext
  10447. ): Promise<GetDocumentationVersionsCommandOutput> => {
  10448. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10449. return deserializeAws_restJson1GetDocumentationVersionsCommandError(output, context);
  10450. }
  10451. const contents: GetDocumentationVersionsCommandOutput = {
  10452. $metadata: deserializeMetadata(output),
  10453. items: undefined,
  10454. position: undefined,
  10455. };
  10456. const data: any = await parseBody(output.body, context);
  10457. if (data.item !== undefined && data.item !== null) {
  10458. contents.items = deserializeAws_restJson1ListOfDocumentationVersion(data.item, context);
  10459. }
  10460. if (data.position !== undefined && data.position !== null) {
  10461. contents.position = data.position;
  10462. }
  10463. return Promise.resolve(contents);
  10464. };
  10465. const deserializeAws_restJson1GetDocumentationVersionsCommandError = async (
  10466. output: __HttpResponse,
  10467. context: __SerdeContext
  10468. ): Promise<GetDocumentationVersionsCommandOutput> => {
  10469. const parsedOutput: any = {
  10470. ...output,
  10471. body: await parseBody(output.body, context),
  10472. };
  10473. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10474. let errorCode: string = "UnknownError";
  10475. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10476. switch (errorCode) {
  10477. case "BadRequestException":
  10478. case "com.amazonaws.apigateway#BadRequestException":
  10479. response = {
  10480. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10481. name: errorCode,
  10482. $metadata: deserializeMetadata(output),
  10483. };
  10484. break;
  10485. case "NotFoundException":
  10486. case "com.amazonaws.apigateway#NotFoundException":
  10487. response = {
  10488. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10489. name: errorCode,
  10490. $metadata: deserializeMetadata(output),
  10491. };
  10492. break;
  10493. case "TooManyRequestsException":
  10494. case "com.amazonaws.apigateway#TooManyRequestsException":
  10495. response = {
  10496. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10497. name: errorCode,
  10498. $metadata: deserializeMetadata(output),
  10499. };
  10500. break;
  10501. case "UnauthorizedException":
  10502. case "com.amazonaws.apigateway#UnauthorizedException":
  10503. response = {
  10504. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10505. name: errorCode,
  10506. $metadata: deserializeMetadata(output),
  10507. };
  10508. break;
  10509. default:
  10510. const parsedBody = parsedOutput.body;
  10511. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10512. response = {
  10513. ...parsedBody,
  10514. name: `${errorCode}`,
  10515. message: parsedBody.message || parsedBody.Message || errorCode,
  10516. $fault: "client",
  10517. $metadata: deserializeMetadata(output),
  10518. } as any;
  10519. }
  10520. const message = response.message || response.Message || errorCode;
  10521. response.message = message;
  10522. delete response.Message;
  10523. return Promise.reject(Object.assign(new Error(message), response));
  10524. };
  10525. export const deserializeAws_restJson1GetDomainNameCommand = async (
  10526. output: __HttpResponse,
  10527. context: __SerdeContext
  10528. ): Promise<GetDomainNameCommandOutput> => {
  10529. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10530. return deserializeAws_restJson1GetDomainNameCommandError(output, context);
  10531. }
  10532. const contents: GetDomainNameCommandOutput = {
  10533. $metadata: deserializeMetadata(output),
  10534. certificateArn: undefined,
  10535. certificateName: undefined,
  10536. certificateUploadDate: undefined,
  10537. distributionDomainName: undefined,
  10538. distributionHostedZoneId: undefined,
  10539. domainName: undefined,
  10540. domainNameStatus: undefined,
  10541. domainNameStatusMessage: undefined,
  10542. endpointConfiguration: undefined,
  10543. regionalCertificateArn: undefined,
  10544. regionalCertificateName: undefined,
  10545. regionalDomainName: undefined,
  10546. regionalHostedZoneId: undefined,
  10547. securityPolicy: undefined,
  10548. tags: undefined,
  10549. };
  10550. const data: any = await parseBody(output.body, context);
  10551. if (data.certificateArn !== undefined && data.certificateArn !== null) {
  10552. contents.certificateArn = data.certificateArn;
  10553. }
  10554. if (data.certificateName !== undefined && data.certificateName !== null) {
  10555. contents.certificateName = data.certificateName;
  10556. }
  10557. if (data.certificateUploadDate !== undefined && data.certificateUploadDate !== null) {
  10558. contents.certificateUploadDate = new Date(Math.round(data.certificateUploadDate * 1000));
  10559. }
  10560. if (data.distributionDomainName !== undefined && data.distributionDomainName !== null) {
  10561. contents.distributionDomainName = data.distributionDomainName;
  10562. }
  10563. if (data.distributionHostedZoneId !== undefined && data.distributionHostedZoneId !== null) {
  10564. contents.distributionHostedZoneId = data.distributionHostedZoneId;
  10565. }
  10566. if (data.domainName !== undefined && data.domainName !== null) {
  10567. contents.domainName = data.domainName;
  10568. }
  10569. if (data.domainNameStatus !== undefined && data.domainNameStatus !== null) {
  10570. contents.domainNameStatus = data.domainNameStatus;
  10571. }
  10572. if (data.domainNameStatusMessage !== undefined && data.domainNameStatusMessage !== null) {
  10573. contents.domainNameStatusMessage = data.domainNameStatusMessage;
  10574. }
  10575. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  10576. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  10577. }
  10578. if (data.regionalCertificateArn !== undefined && data.regionalCertificateArn !== null) {
  10579. contents.regionalCertificateArn = data.regionalCertificateArn;
  10580. }
  10581. if (data.regionalCertificateName !== undefined && data.regionalCertificateName !== null) {
  10582. contents.regionalCertificateName = data.regionalCertificateName;
  10583. }
  10584. if (data.regionalDomainName !== undefined && data.regionalDomainName !== null) {
  10585. contents.regionalDomainName = data.regionalDomainName;
  10586. }
  10587. if (data.regionalHostedZoneId !== undefined && data.regionalHostedZoneId !== null) {
  10588. contents.regionalHostedZoneId = data.regionalHostedZoneId;
  10589. }
  10590. if (data.securityPolicy !== undefined && data.securityPolicy !== null) {
  10591. contents.securityPolicy = data.securityPolicy;
  10592. }
  10593. if (data.tags !== undefined && data.tags !== null) {
  10594. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  10595. }
  10596. return Promise.resolve(contents);
  10597. };
  10598. const deserializeAws_restJson1GetDomainNameCommandError = async (
  10599. output: __HttpResponse,
  10600. context: __SerdeContext
  10601. ): Promise<GetDomainNameCommandOutput> => {
  10602. const parsedOutput: any = {
  10603. ...output,
  10604. body: await parseBody(output.body, context),
  10605. };
  10606. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10607. let errorCode: string = "UnknownError";
  10608. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10609. switch (errorCode) {
  10610. case "NotFoundException":
  10611. case "com.amazonaws.apigateway#NotFoundException":
  10612. response = {
  10613. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10614. name: errorCode,
  10615. $metadata: deserializeMetadata(output),
  10616. };
  10617. break;
  10618. case "ServiceUnavailableException":
  10619. case "com.amazonaws.apigateway#ServiceUnavailableException":
  10620. response = {
  10621. ...(await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context)),
  10622. name: errorCode,
  10623. $metadata: deserializeMetadata(output),
  10624. };
  10625. break;
  10626. case "TooManyRequestsException":
  10627. case "com.amazonaws.apigateway#TooManyRequestsException":
  10628. response = {
  10629. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10630. name: errorCode,
  10631. $metadata: deserializeMetadata(output),
  10632. };
  10633. break;
  10634. case "UnauthorizedException":
  10635. case "com.amazonaws.apigateway#UnauthorizedException":
  10636. response = {
  10637. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10638. name: errorCode,
  10639. $metadata: deserializeMetadata(output),
  10640. };
  10641. break;
  10642. default:
  10643. const parsedBody = parsedOutput.body;
  10644. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10645. response = {
  10646. ...parsedBody,
  10647. name: `${errorCode}`,
  10648. message: parsedBody.message || parsedBody.Message || errorCode,
  10649. $fault: "client",
  10650. $metadata: deserializeMetadata(output),
  10651. } as any;
  10652. }
  10653. const message = response.message || response.Message || errorCode;
  10654. response.message = message;
  10655. delete response.Message;
  10656. return Promise.reject(Object.assign(new Error(message), response));
  10657. };
  10658. export const deserializeAws_restJson1GetDomainNamesCommand = async (
  10659. output: __HttpResponse,
  10660. context: __SerdeContext
  10661. ): Promise<GetDomainNamesCommandOutput> => {
  10662. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10663. return deserializeAws_restJson1GetDomainNamesCommandError(output, context);
  10664. }
  10665. const contents: GetDomainNamesCommandOutput = {
  10666. $metadata: deserializeMetadata(output),
  10667. items: undefined,
  10668. position: undefined,
  10669. };
  10670. const data: any = await parseBody(output.body, context);
  10671. if (data.item !== undefined && data.item !== null) {
  10672. contents.items = deserializeAws_restJson1ListOfDomainName(data.item, context);
  10673. }
  10674. if (data.position !== undefined && data.position !== null) {
  10675. contents.position = data.position;
  10676. }
  10677. return Promise.resolve(contents);
  10678. };
  10679. const deserializeAws_restJson1GetDomainNamesCommandError = async (
  10680. output: __HttpResponse,
  10681. context: __SerdeContext
  10682. ): Promise<GetDomainNamesCommandOutput> => {
  10683. const parsedOutput: any = {
  10684. ...output,
  10685. body: await parseBody(output.body, context),
  10686. };
  10687. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10688. let errorCode: string = "UnknownError";
  10689. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10690. switch (errorCode) {
  10691. case "BadRequestException":
  10692. case "com.amazonaws.apigateway#BadRequestException":
  10693. response = {
  10694. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10695. name: errorCode,
  10696. $metadata: deserializeMetadata(output),
  10697. };
  10698. break;
  10699. case "TooManyRequestsException":
  10700. case "com.amazonaws.apigateway#TooManyRequestsException":
  10701. response = {
  10702. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10703. name: errorCode,
  10704. $metadata: deserializeMetadata(output),
  10705. };
  10706. break;
  10707. case "UnauthorizedException":
  10708. case "com.amazonaws.apigateway#UnauthorizedException":
  10709. response = {
  10710. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10711. name: errorCode,
  10712. $metadata: deserializeMetadata(output),
  10713. };
  10714. break;
  10715. default:
  10716. const parsedBody = parsedOutput.body;
  10717. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10718. response = {
  10719. ...parsedBody,
  10720. name: `${errorCode}`,
  10721. message: parsedBody.message || parsedBody.Message || errorCode,
  10722. $fault: "client",
  10723. $metadata: deserializeMetadata(output),
  10724. } as any;
  10725. }
  10726. const message = response.message || response.Message || errorCode;
  10727. response.message = message;
  10728. delete response.Message;
  10729. return Promise.reject(Object.assign(new Error(message), response));
  10730. };
  10731. export const deserializeAws_restJson1GetExportCommand = async (
  10732. output: __HttpResponse,
  10733. context: __SerdeContext
  10734. ): Promise<GetExportCommandOutput> => {
  10735. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10736. return deserializeAws_restJson1GetExportCommandError(output, context);
  10737. }
  10738. const contents: GetExportCommandOutput = {
  10739. $metadata: deserializeMetadata(output),
  10740. body: undefined,
  10741. contentDisposition: undefined,
  10742. contentType: undefined,
  10743. };
  10744. if (output.headers["content-type"] !== undefined) {
  10745. contents.contentType = output.headers["content-type"];
  10746. }
  10747. if (output.headers["content-disposition"] !== undefined) {
  10748. contents.contentDisposition = output.headers["content-disposition"];
  10749. }
  10750. const data: any = await collectBody(output.body, context);
  10751. contents.body = data;
  10752. return Promise.resolve(contents);
  10753. };
  10754. const deserializeAws_restJson1GetExportCommandError = async (
  10755. output: __HttpResponse,
  10756. context: __SerdeContext
  10757. ): Promise<GetExportCommandOutput> => {
  10758. const parsedOutput: any = {
  10759. ...output,
  10760. body: await parseBody(output.body, context),
  10761. };
  10762. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10763. let errorCode: string = "UnknownError";
  10764. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10765. switch (errorCode) {
  10766. case "BadRequestException":
  10767. case "com.amazonaws.apigateway#BadRequestException":
  10768. response = {
  10769. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10770. name: errorCode,
  10771. $metadata: deserializeMetadata(output),
  10772. };
  10773. break;
  10774. case "ConflictException":
  10775. case "com.amazonaws.apigateway#ConflictException":
  10776. response = {
  10777. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  10778. name: errorCode,
  10779. $metadata: deserializeMetadata(output),
  10780. };
  10781. break;
  10782. case "NotFoundException":
  10783. case "com.amazonaws.apigateway#NotFoundException":
  10784. response = {
  10785. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10786. name: errorCode,
  10787. $metadata: deserializeMetadata(output),
  10788. };
  10789. break;
  10790. case "TooManyRequestsException":
  10791. case "com.amazonaws.apigateway#TooManyRequestsException":
  10792. response = {
  10793. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10794. name: errorCode,
  10795. $metadata: deserializeMetadata(output),
  10796. };
  10797. break;
  10798. case "UnauthorizedException":
  10799. case "com.amazonaws.apigateway#UnauthorizedException":
  10800. response = {
  10801. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10802. name: errorCode,
  10803. $metadata: deserializeMetadata(output),
  10804. };
  10805. break;
  10806. default:
  10807. const parsedBody = parsedOutput.body;
  10808. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10809. response = {
  10810. ...parsedBody,
  10811. name: `${errorCode}`,
  10812. message: parsedBody.message || parsedBody.Message || errorCode,
  10813. $fault: "client",
  10814. $metadata: deserializeMetadata(output),
  10815. } as any;
  10816. }
  10817. const message = response.message || response.Message || errorCode;
  10818. response.message = message;
  10819. delete response.Message;
  10820. return Promise.reject(Object.assign(new Error(message), response));
  10821. };
  10822. export const deserializeAws_restJson1GetGatewayResponseCommand = async (
  10823. output: __HttpResponse,
  10824. context: __SerdeContext
  10825. ): Promise<GetGatewayResponseCommandOutput> => {
  10826. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10827. return deserializeAws_restJson1GetGatewayResponseCommandError(output, context);
  10828. }
  10829. const contents: GetGatewayResponseCommandOutput = {
  10830. $metadata: deserializeMetadata(output),
  10831. defaultResponse: undefined,
  10832. responseParameters: undefined,
  10833. responseTemplates: undefined,
  10834. responseType: undefined,
  10835. statusCode: undefined,
  10836. };
  10837. const data: any = await parseBody(output.body, context);
  10838. if (data.defaultResponse !== undefined && data.defaultResponse !== null) {
  10839. contents.defaultResponse = data.defaultResponse;
  10840. }
  10841. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  10842. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  10843. }
  10844. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  10845. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  10846. }
  10847. if (data.responseType !== undefined && data.responseType !== null) {
  10848. contents.responseType = data.responseType;
  10849. }
  10850. if (data.statusCode !== undefined && data.statusCode !== null) {
  10851. contents.statusCode = data.statusCode;
  10852. }
  10853. return Promise.resolve(contents);
  10854. };
  10855. const deserializeAws_restJson1GetGatewayResponseCommandError = async (
  10856. output: __HttpResponse,
  10857. context: __SerdeContext
  10858. ): Promise<GetGatewayResponseCommandOutput> => {
  10859. const parsedOutput: any = {
  10860. ...output,
  10861. body: await parseBody(output.body, context),
  10862. };
  10863. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10864. let errorCode: string = "UnknownError";
  10865. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10866. switch (errorCode) {
  10867. case "NotFoundException":
  10868. case "com.amazonaws.apigateway#NotFoundException":
  10869. response = {
  10870. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10871. name: errorCode,
  10872. $metadata: deserializeMetadata(output),
  10873. };
  10874. break;
  10875. case "TooManyRequestsException":
  10876. case "com.amazonaws.apigateway#TooManyRequestsException":
  10877. response = {
  10878. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10879. name: errorCode,
  10880. $metadata: deserializeMetadata(output),
  10881. };
  10882. break;
  10883. case "UnauthorizedException":
  10884. case "com.amazonaws.apigateway#UnauthorizedException":
  10885. response = {
  10886. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10887. name: errorCode,
  10888. $metadata: deserializeMetadata(output),
  10889. };
  10890. break;
  10891. default:
  10892. const parsedBody = parsedOutput.body;
  10893. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10894. response = {
  10895. ...parsedBody,
  10896. name: `${errorCode}`,
  10897. message: parsedBody.message || parsedBody.Message || errorCode,
  10898. $fault: "client",
  10899. $metadata: deserializeMetadata(output),
  10900. } as any;
  10901. }
  10902. const message = response.message || response.Message || errorCode;
  10903. response.message = message;
  10904. delete response.Message;
  10905. return Promise.reject(Object.assign(new Error(message), response));
  10906. };
  10907. export const deserializeAws_restJson1GetGatewayResponsesCommand = async (
  10908. output: __HttpResponse,
  10909. context: __SerdeContext
  10910. ): Promise<GetGatewayResponsesCommandOutput> => {
  10911. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10912. return deserializeAws_restJson1GetGatewayResponsesCommandError(output, context);
  10913. }
  10914. const contents: GetGatewayResponsesCommandOutput = {
  10915. $metadata: deserializeMetadata(output),
  10916. items: undefined,
  10917. position: undefined,
  10918. };
  10919. const data: any = await parseBody(output.body, context);
  10920. if (data.item !== undefined && data.item !== null) {
  10921. contents.items = deserializeAws_restJson1ListOfGatewayResponse(data.item, context);
  10922. }
  10923. if (data.position !== undefined && data.position !== null) {
  10924. contents.position = data.position;
  10925. }
  10926. return Promise.resolve(contents);
  10927. };
  10928. const deserializeAws_restJson1GetGatewayResponsesCommandError = async (
  10929. output: __HttpResponse,
  10930. context: __SerdeContext
  10931. ): Promise<GetGatewayResponsesCommandOutput> => {
  10932. const parsedOutput: any = {
  10933. ...output,
  10934. body: await parseBody(output.body, context),
  10935. };
  10936. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  10937. let errorCode: string = "UnknownError";
  10938. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  10939. switch (errorCode) {
  10940. case "BadRequestException":
  10941. case "com.amazonaws.apigateway#BadRequestException":
  10942. response = {
  10943. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  10944. name: errorCode,
  10945. $metadata: deserializeMetadata(output),
  10946. };
  10947. break;
  10948. case "NotFoundException":
  10949. case "com.amazonaws.apigateway#NotFoundException":
  10950. response = {
  10951. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  10952. name: errorCode,
  10953. $metadata: deserializeMetadata(output),
  10954. };
  10955. break;
  10956. case "TooManyRequestsException":
  10957. case "com.amazonaws.apigateway#TooManyRequestsException":
  10958. response = {
  10959. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  10960. name: errorCode,
  10961. $metadata: deserializeMetadata(output),
  10962. };
  10963. break;
  10964. case "UnauthorizedException":
  10965. case "com.amazonaws.apigateway#UnauthorizedException":
  10966. response = {
  10967. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  10968. name: errorCode,
  10969. $metadata: deserializeMetadata(output),
  10970. };
  10971. break;
  10972. default:
  10973. const parsedBody = parsedOutput.body;
  10974. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  10975. response = {
  10976. ...parsedBody,
  10977. name: `${errorCode}`,
  10978. message: parsedBody.message || parsedBody.Message || errorCode,
  10979. $fault: "client",
  10980. $metadata: deserializeMetadata(output),
  10981. } as any;
  10982. }
  10983. const message = response.message || response.Message || errorCode;
  10984. response.message = message;
  10985. delete response.Message;
  10986. return Promise.reject(Object.assign(new Error(message), response));
  10987. };
  10988. export const deserializeAws_restJson1GetIntegrationCommand = async (
  10989. output: __HttpResponse,
  10990. context: __SerdeContext
  10991. ): Promise<GetIntegrationCommandOutput> => {
  10992. if (output.statusCode !== 200 && output.statusCode >= 400) {
  10993. return deserializeAws_restJson1GetIntegrationCommandError(output, context);
  10994. }
  10995. const contents: GetIntegrationCommandOutput = {
  10996. $metadata: deserializeMetadata(output),
  10997. cacheKeyParameters: undefined,
  10998. cacheNamespace: undefined,
  10999. connectionId: undefined,
  11000. connectionType: undefined,
  11001. contentHandling: undefined,
  11002. credentials: undefined,
  11003. httpMethod: undefined,
  11004. integrationResponses: undefined,
  11005. passthroughBehavior: undefined,
  11006. requestParameters: undefined,
  11007. requestTemplates: undefined,
  11008. timeoutInMillis: undefined,
  11009. tlsConfig: undefined,
  11010. type: undefined,
  11011. uri: undefined,
  11012. };
  11013. const data: any = await parseBody(output.body, context);
  11014. if (data.cacheKeyParameters !== undefined && data.cacheKeyParameters !== null) {
  11015. contents.cacheKeyParameters = deserializeAws_restJson1ListOfString(data.cacheKeyParameters, context);
  11016. }
  11017. if (data.cacheNamespace !== undefined && data.cacheNamespace !== null) {
  11018. contents.cacheNamespace = data.cacheNamespace;
  11019. }
  11020. if (data.connectionId !== undefined && data.connectionId !== null) {
  11021. contents.connectionId = data.connectionId;
  11022. }
  11023. if (data.connectionType !== undefined && data.connectionType !== null) {
  11024. contents.connectionType = data.connectionType;
  11025. }
  11026. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  11027. contents.contentHandling = data.contentHandling;
  11028. }
  11029. if (data.credentials !== undefined && data.credentials !== null) {
  11030. contents.credentials = data.credentials;
  11031. }
  11032. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  11033. contents.httpMethod = data.httpMethod;
  11034. }
  11035. if (data.integrationResponses !== undefined && data.integrationResponses !== null) {
  11036. contents.integrationResponses = deserializeAws_restJson1MapOfIntegrationResponse(
  11037. data.integrationResponses,
  11038. context
  11039. );
  11040. }
  11041. if (data.passthroughBehavior !== undefined && data.passthroughBehavior !== null) {
  11042. contents.passthroughBehavior = data.passthroughBehavior;
  11043. }
  11044. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  11045. contents.requestParameters = deserializeAws_restJson1MapOfStringToString(data.requestParameters, context);
  11046. }
  11047. if (data.requestTemplates !== undefined && data.requestTemplates !== null) {
  11048. contents.requestTemplates = deserializeAws_restJson1MapOfStringToString(data.requestTemplates, context);
  11049. }
  11050. if (data.timeoutInMillis !== undefined && data.timeoutInMillis !== null) {
  11051. contents.timeoutInMillis = data.timeoutInMillis;
  11052. }
  11053. if (data.tlsConfig !== undefined && data.tlsConfig !== null) {
  11054. contents.tlsConfig = deserializeAws_restJson1TlsConfig(data.tlsConfig, context);
  11055. }
  11056. if (data.type !== undefined && data.type !== null) {
  11057. contents.type = data.type;
  11058. }
  11059. if (data.uri !== undefined && data.uri !== null) {
  11060. contents.uri = data.uri;
  11061. }
  11062. return Promise.resolve(contents);
  11063. };
  11064. const deserializeAws_restJson1GetIntegrationCommandError = async (
  11065. output: __HttpResponse,
  11066. context: __SerdeContext
  11067. ): Promise<GetIntegrationCommandOutput> => {
  11068. const parsedOutput: any = {
  11069. ...output,
  11070. body: await parseBody(output.body, context),
  11071. };
  11072. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11073. let errorCode: string = "UnknownError";
  11074. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11075. switch (errorCode) {
  11076. case "NotFoundException":
  11077. case "com.amazonaws.apigateway#NotFoundException":
  11078. response = {
  11079. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11080. name: errorCode,
  11081. $metadata: deserializeMetadata(output),
  11082. };
  11083. break;
  11084. case "TooManyRequestsException":
  11085. case "com.amazonaws.apigateway#TooManyRequestsException":
  11086. response = {
  11087. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11088. name: errorCode,
  11089. $metadata: deserializeMetadata(output),
  11090. };
  11091. break;
  11092. case "UnauthorizedException":
  11093. case "com.amazonaws.apigateway#UnauthorizedException":
  11094. response = {
  11095. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11096. name: errorCode,
  11097. $metadata: deserializeMetadata(output),
  11098. };
  11099. break;
  11100. default:
  11101. const parsedBody = parsedOutput.body;
  11102. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11103. response = {
  11104. ...parsedBody,
  11105. name: `${errorCode}`,
  11106. message: parsedBody.message || parsedBody.Message || errorCode,
  11107. $fault: "client",
  11108. $metadata: deserializeMetadata(output),
  11109. } as any;
  11110. }
  11111. const message = response.message || response.Message || errorCode;
  11112. response.message = message;
  11113. delete response.Message;
  11114. return Promise.reject(Object.assign(new Error(message), response));
  11115. };
  11116. export const deserializeAws_restJson1GetIntegrationResponseCommand = async (
  11117. output: __HttpResponse,
  11118. context: __SerdeContext
  11119. ): Promise<GetIntegrationResponseCommandOutput> => {
  11120. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11121. return deserializeAws_restJson1GetIntegrationResponseCommandError(output, context);
  11122. }
  11123. const contents: GetIntegrationResponseCommandOutput = {
  11124. $metadata: deserializeMetadata(output),
  11125. contentHandling: undefined,
  11126. responseParameters: undefined,
  11127. responseTemplates: undefined,
  11128. selectionPattern: undefined,
  11129. statusCode: undefined,
  11130. };
  11131. const data: any = await parseBody(output.body, context);
  11132. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  11133. contents.contentHandling = data.contentHandling;
  11134. }
  11135. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  11136. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  11137. }
  11138. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  11139. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  11140. }
  11141. if (data.selectionPattern !== undefined && data.selectionPattern !== null) {
  11142. contents.selectionPattern = data.selectionPattern;
  11143. }
  11144. if (data.statusCode !== undefined && data.statusCode !== null) {
  11145. contents.statusCode = data.statusCode;
  11146. }
  11147. return Promise.resolve(contents);
  11148. };
  11149. const deserializeAws_restJson1GetIntegrationResponseCommandError = async (
  11150. output: __HttpResponse,
  11151. context: __SerdeContext
  11152. ): Promise<GetIntegrationResponseCommandOutput> => {
  11153. const parsedOutput: any = {
  11154. ...output,
  11155. body: await parseBody(output.body, context),
  11156. };
  11157. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11158. let errorCode: string = "UnknownError";
  11159. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11160. switch (errorCode) {
  11161. case "NotFoundException":
  11162. case "com.amazonaws.apigateway#NotFoundException":
  11163. response = {
  11164. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11165. name: errorCode,
  11166. $metadata: deserializeMetadata(output),
  11167. };
  11168. break;
  11169. case "TooManyRequestsException":
  11170. case "com.amazonaws.apigateway#TooManyRequestsException":
  11171. response = {
  11172. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11173. name: errorCode,
  11174. $metadata: deserializeMetadata(output),
  11175. };
  11176. break;
  11177. case "UnauthorizedException":
  11178. case "com.amazonaws.apigateway#UnauthorizedException":
  11179. response = {
  11180. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11181. name: errorCode,
  11182. $metadata: deserializeMetadata(output),
  11183. };
  11184. break;
  11185. default:
  11186. const parsedBody = parsedOutput.body;
  11187. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11188. response = {
  11189. ...parsedBody,
  11190. name: `${errorCode}`,
  11191. message: parsedBody.message || parsedBody.Message || errorCode,
  11192. $fault: "client",
  11193. $metadata: deserializeMetadata(output),
  11194. } as any;
  11195. }
  11196. const message = response.message || response.Message || errorCode;
  11197. response.message = message;
  11198. delete response.Message;
  11199. return Promise.reject(Object.assign(new Error(message), response));
  11200. };
  11201. export const deserializeAws_restJson1GetMethodCommand = async (
  11202. output: __HttpResponse,
  11203. context: __SerdeContext
  11204. ): Promise<GetMethodCommandOutput> => {
  11205. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11206. return deserializeAws_restJson1GetMethodCommandError(output, context);
  11207. }
  11208. const contents: GetMethodCommandOutput = {
  11209. $metadata: deserializeMetadata(output),
  11210. apiKeyRequired: undefined,
  11211. authorizationScopes: undefined,
  11212. authorizationType: undefined,
  11213. authorizerId: undefined,
  11214. httpMethod: undefined,
  11215. methodIntegration: undefined,
  11216. methodResponses: undefined,
  11217. operationName: undefined,
  11218. requestModels: undefined,
  11219. requestParameters: undefined,
  11220. requestValidatorId: undefined,
  11221. };
  11222. const data: any = await parseBody(output.body, context);
  11223. if (data.apiKeyRequired !== undefined && data.apiKeyRequired !== null) {
  11224. contents.apiKeyRequired = data.apiKeyRequired;
  11225. }
  11226. if (data.authorizationScopes !== undefined && data.authorizationScopes !== null) {
  11227. contents.authorizationScopes = deserializeAws_restJson1ListOfString(data.authorizationScopes, context);
  11228. }
  11229. if (data.authorizationType !== undefined && data.authorizationType !== null) {
  11230. contents.authorizationType = data.authorizationType;
  11231. }
  11232. if (data.authorizerId !== undefined && data.authorizerId !== null) {
  11233. contents.authorizerId = data.authorizerId;
  11234. }
  11235. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  11236. contents.httpMethod = data.httpMethod;
  11237. }
  11238. if (data.methodIntegration !== undefined && data.methodIntegration !== null) {
  11239. contents.methodIntegration = deserializeAws_restJson1Integration(data.methodIntegration, context);
  11240. }
  11241. if (data.methodResponses !== undefined && data.methodResponses !== null) {
  11242. contents.methodResponses = deserializeAws_restJson1MapOfMethodResponse(data.methodResponses, context);
  11243. }
  11244. if (data.operationName !== undefined && data.operationName !== null) {
  11245. contents.operationName = data.operationName;
  11246. }
  11247. if (data.requestModels !== undefined && data.requestModels !== null) {
  11248. contents.requestModels = deserializeAws_restJson1MapOfStringToString(data.requestModels, context);
  11249. }
  11250. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  11251. contents.requestParameters = deserializeAws_restJson1MapOfStringToBoolean(data.requestParameters, context);
  11252. }
  11253. if (data.requestValidatorId !== undefined && data.requestValidatorId !== null) {
  11254. contents.requestValidatorId = data.requestValidatorId;
  11255. }
  11256. return Promise.resolve(contents);
  11257. };
  11258. const deserializeAws_restJson1GetMethodCommandError = async (
  11259. output: __HttpResponse,
  11260. context: __SerdeContext
  11261. ): Promise<GetMethodCommandOutput> => {
  11262. const parsedOutput: any = {
  11263. ...output,
  11264. body: await parseBody(output.body, context),
  11265. };
  11266. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11267. let errorCode: string = "UnknownError";
  11268. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11269. switch (errorCode) {
  11270. case "NotFoundException":
  11271. case "com.amazonaws.apigateway#NotFoundException":
  11272. response = {
  11273. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11274. name: errorCode,
  11275. $metadata: deserializeMetadata(output),
  11276. };
  11277. break;
  11278. case "TooManyRequestsException":
  11279. case "com.amazonaws.apigateway#TooManyRequestsException":
  11280. response = {
  11281. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11282. name: errorCode,
  11283. $metadata: deserializeMetadata(output),
  11284. };
  11285. break;
  11286. case "UnauthorizedException":
  11287. case "com.amazonaws.apigateway#UnauthorizedException":
  11288. response = {
  11289. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11290. name: errorCode,
  11291. $metadata: deserializeMetadata(output),
  11292. };
  11293. break;
  11294. default:
  11295. const parsedBody = parsedOutput.body;
  11296. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11297. response = {
  11298. ...parsedBody,
  11299. name: `${errorCode}`,
  11300. message: parsedBody.message || parsedBody.Message || errorCode,
  11301. $fault: "client",
  11302. $metadata: deserializeMetadata(output),
  11303. } as any;
  11304. }
  11305. const message = response.message || response.Message || errorCode;
  11306. response.message = message;
  11307. delete response.Message;
  11308. return Promise.reject(Object.assign(new Error(message), response));
  11309. };
  11310. export const deserializeAws_restJson1GetMethodResponseCommand = async (
  11311. output: __HttpResponse,
  11312. context: __SerdeContext
  11313. ): Promise<GetMethodResponseCommandOutput> => {
  11314. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11315. return deserializeAws_restJson1GetMethodResponseCommandError(output, context);
  11316. }
  11317. const contents: GetMethodResponseCommandOutput = {
  11318. $metadata: deserializeMetadata(output),
  11319. responseModels: undefined,
  11320. responseParameters: undefined,
  11321. statusCode: undefined,
  11322. };
  11323. const data: any = await parseBody(output.body, context);
  11324. if (data.responseModels !== undefined && data.responseModels !== null) {
  11325. contents.responseModels = deserializeAws_restJson1MapOfStringToString(data.responseModels, context);
  11326. }
  11327. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  11328. contents.responseParameters = deserializeAws_restJson1MapOfStringToBoolean(data.responseParameters, context);
  11329. }
  11330. if (data.statusCode !== undefined && data.statusCode !== null) {
  11331. contents.statusCode = data.statusCode;
  11332. }
  11333. return Promise.resolve(contents);
  11334. };
  11335. const deserializeAws_restJson1GetMethodResponseCommandError = async (
  11336. output: __HttpResponse,
  11337. context: __SerdeContext
  11338. ): Promise<GetMethodResponseCommandOutput> => {
  11339. const parsedOutput: any = {
  11340. ...output,
  11341. body: await parseBody(output.body, context),
  11342. };
  11343. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11344. let errorCode: string = "UnknownError";
  11345. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11346. switch (errorCode) {
  11347. case "NotFoundException":
  11348. case "com.amazonaws.apigateway#NotFoundException":
  11349. response = {
  11350. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11351. name: errorCode,
  11352. $metadata: deserializeMetadata(output),
  11353. };
  11354. break;
  11355. case "TooManyRequestsException":
  11356. case "com.amazonaws.apigateway#TooManyRequestsException":
  11357. response = {
  11358. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11359. name: errorCode,
  11360. $metadata: deserializeMetadata(output),
  11361. };
  11362. break;
  11363. case "UnauthorizedException":
  11364. case "com.amazonaws.apigateway#UnauthorizedException":
  11365. response = {
  11366. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11367. name: errorCode,
  11368. $metadata: deserializeMetadata(output),
  11369. };
  11370. break;
  11371. default:
  11372. const parsedBody = parsedOutput.body;
  11373. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11374. response = {
  11375. ...parsedBody,
  11376. name: `${errorCode}`,
  11377. message: parsedBody.message || parsedBody.Message || errorCode,
  11378. $fault: "client",
  11379. $metadata: deserializeMetadata(output),
  11380. } as any;
  11381. }
  11382. const message = response.message || response.Message || errorCode;
  11383. response.message = message;
  11384. delete response.Message;
  11385. return Promise.reject(Object.assign(new Error(message), response));
  11386. };
  11387. export const deserializeAws_restJson1GetModelCommand = async (
  11388. output: __HttpResponse,
  11389. context: __SerdeContext
  11390. ): Promise<GetModelCommandOutput> => {
  11391. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11392. return deserializeAws_restJson1GetModelCommandError(output, context);
  11393. }
  11394. const contents: GetModelCommandOutput = {
  11395. $metadata: deserializeMetadata(output),
  11396. contentType: undefined,
  11397. description: undefined,
  11398. id: undefined,
  11399. name: undefined,
  11400. schema: undefined,
  11401. };
  11402. const data: any = await parseBody(output.body, context);
  11403. if (data.contentType !== undefined && data.contentType !== null) {
  11404. contents.contentType = data.contentType;
  11405. }
  11406. if (data.description !== undefined && data.description !== null) {
  11407. contents.description = data.description;
  11408. }
  11409. if (data.id !== undefined && data.id !== null) {
  11410. contents.id = data.id;
  11411. }
  11412. if (data.name !== undefined && data.name !== null) {
  11413. contents.name = data.name;
  11414. }
  11415. if (data.schema !== undefined && data.schema !== null) {
  11416. contents.schema = data.schema;
  11417. }
  11418. return Promise.resolve(contents);
  11419. };
  11420. const deserializeAws_restJson1GetModelCommandError = async (
  11421. output: __HttpResponse,
  11422. context: __SerdeContext
  11423. ): Promise<GetModelCommandOutput> => {
  11424. const parsedOutput: any = {
  11425. ...output,
  11426. body: await parseBody(output.body, context),
  11427. };
  11428. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11429. let errorCode: string = "UnknownError";
  11430. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11431. switch (errorCode) {
  11432. case "NotFoundException":
  11433. case "com.amazonaws.apigateway#NotFoundException":
  11434. response = {
  11435. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11436. name: errorCode,
  11437. $metadata: deserializeMetadata(output),
  11438. };
  11439. break;
  11440. case "TooManyRequestsException":
  11441. case "com.amazonaws.apigateway#TooManyRequestsException":
  11442. response = {
  11443. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11444. name: errorCode,
  11445. $metadata: deserializeMetadata(output),
  11446. };
  11447. break;
  11448. case "UnauthorizedException":
  11449. case "com.amazonaws.apigateway#UnauthorizedException":
  11450. response = {
  11451. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11452. name: errorCode,
  11453. $metadata: deserializeMetadata(output),
  11454. };
  11455. break;
  11456. default:
  11457. const parsedBody = parsedOutput.body;
  11458. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11459. response = {
  11460. ...parsedBody,
  11461. name: `${errorCode}`,
  11462. message: parsedBody.message || parsedBody.Message || errorCode,
  11463. $fault: "client",
  11464. $metadata: deserializeMetadata(output),
  11465. } as any;
  11466. }
  11467. const message = response.message || response.Message || errorCode;
  11468. response.message = message;
  11469. delete response.Message;
  11470. return Promise.reject(Object.assign(new Error(message), response));
  11471. };
  11472. export const deserializeAws_restJson1GetModelsCommand = async (
  11473. output: __HttpResponse,
  11474. context: __SerdeContext
  11475. ): Promise<GetModelsCommandOutput> => {
  11476. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11477. return deserializeAws_restJson1GetModelsCommandError(output, context);
  11478. }
  11479. const contents: GetModelsCommandOutput = {
  11480. $metadata: deserializeMetadata(output),
  11481. items: undefined,
  11482. position: undefined,
  11483. };
  11484. const data: any = await parseBody(output.body, context);
  11485. if (data.item !== undefined && data.item !== null) {
  11486. contents.items = deserializeAws_restJson1ListOfModel(data.item, context);
  11487. }
  11488. if (data.position !== undefined && data.position !== null) {
  11489. contents.position = data.position;
  11490. }
  11491. return Promise.resolve(contents);
  11492. };
  11493. const deserializeAws_restJson1GetModelsCommandError = async (
  11494. output: __HttpResponse,
  11495. context: __SerdeContext
  11496. ): Promise<GetModelsCommandOutput> => {
  11497. const parsedOutput: any = {
  11498. ...output,
  11499. body: await parseBody(output.body, context),
  11500. };
  11501. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11502. let errorCode: string = "UnknownError";
  11503. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11504. switch (errorCode) {
  11505. case "BadRequestException":
  11506. case "com.amazonaws.apigateway#BadRequestException":
  11507. response = {
  11508. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  11509. name: errorCode,
  11510. $metadata: deserializeMetadata(output),
  11511. };
  11512. break;
  11513. case "NotFoundException":
  11514. case "com.amazonaws.apigateway#NotFoundException":
  11515. response = {
  11516. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11517. name: errorCode,
  11518. $metadata: deserializeMetadata(output),
  11519. };
  11520. break;
  11521. case "TooManyRequestsException":
  11522. case "com.amazonaws.apigateway#TooManyRequestsException":
  11523. response = {
  11524. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11525. name: errorCode,
  11526. $metadata: deserializeMetadata(output),
  11527. };
  11528. break;
  11529. case "UnauthorizedException":
  11530. case "com.amazonaws.apigateway#UnauthorizedException":
  11531. response = {
  11532. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11533. name: errorCode,
  11534. $metadata: deserializeMetadata(output),
  11535. };
  11536. break;
  11537. default:
  11538. const parsedBody = parsedOutput.body;
  11539. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11540. response = {
  11541. ...parsedBody,
  11542. name: `${errorCode}`,
  11543. message: parsedBody.message || parsedBody.Message || errorCode,
  11544. $fault: "client",
  11545. $metadata: deserializeMetadata(output),
  11546. } as any;
  11547. }
  11548. const message = response.message || response.Message || errorCode;
  11549. response.message = message;
  11550. delete response.Message;
  11551. return Promise.reject(Object.assign(new Error(message), response));
  11552. };
  11553. export const deserializeAws_restJson1GetModelTemplateCommand = async (
  11554. output: __HttpResponse,
  11555. context: __SerdeContext
  11556. ): Promise<GetModelTemplateCommandOutput> => {
  11557. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11558. return deserializeAws_restJson1GetModelTemplateCommandError(output, context);
  11559. }
  11560. const contents: GetModelTemplateCommandOutput = {
  11561. $metadata: deserializeMetadata(output),
  11562. value: undefined,
  11563. };
  11564. const data: any = await parseBody(output.body, context);
  11565. if (data.value !== undefined && data.value !== null) {
  11566. contents.value = data.value;
  11567. }
  11568. return Promise.resolve(contents);
  11569. };
  11570. const deserializeAws_restJson1GetModelTemplateCommandError = async (
  11571. output: __HttpResponse,
  11572. context: __SerdeContext
  11573. ): Promise<GetModelTemplateCommandOutput> => {
  11574. const parsedOutput: any = {
  11575. ...output,
  11576. body: await parseBody(output.body, context),
  11577. };
  11578. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11579. let errorCode: string = "UnknownError";
  11580. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11581. switch (errorCode) {
  11582. case "BadRequestException":
  11583. case "com.amazonaws.apigateway#BadRequestException":
  11584. response = {
  11585. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  11586. name: errorCode,
  11587. $metadata: deserializeMetadata(output),
  11588. };
  11589. break;
  11590. case "NotFoundException":
  11591. case "com.amazonaws.apigateway#NotFoundException":
  11592. response = {
  11593. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11594. name: errorCode,
  11595. $metadata: deserializeMetadata(output),
  11596. };
  11597. break;
  11598. case "TooManyRequestsException":
  11599. case "com.amazonaws.apigateway#TooManyRequestsException":
  11600. response = {
  11601. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11602. name: errorCode,
  11603. $metadata: deserializeMetadata(output),
  11604. };
  11605. break;
  11606. case "UnauthorizedException":
  11607. case "com.amazonaws.apigateway#UnauthorizedException":
  11608. response = {
  11609. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11610. name: errorCode,
  11611. $metadata: deserializeMetadata(output),
  11612. };
  11613. break;
  11614. default:
  11615. const parsedBody = parsedOutput.body;
  11616. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11617. response = {
  11618. ...parsedBody,
  11619. name: `${errorCode}`,
  11620. message: parsedBody.message || parsedBody.Message || errorCode,
  11621. $fault: "client",
  11622. $metadata: deserializeMetadata(output),
  11623. } as any;
  11624. }
  11625. const message = response.message || response.Message || errorCode;
  11626. response.message = message;
  11627. delete response.Message;
  11628. return Promise.reject(Object.assign(new Error(message), response));
  11629. };
  11630. export const deserializeAws_restJson1GetRequestValidatorCommand = async (
  11631. output: __HttpResponse,
  11632. context: __SerdeContext
  11633. ): Promise<GetRequestValidatorCommandOutput> => {
  11634. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11635. return deserializeAws_restJson1GetRequestValidatorCommandError(output, context);
  11636. }
  11637. const contents: GetRequestValidatorCommandOutput = {
  11638. $metadata: deserializeMetadata(output),
  11639. id: undefined,
  11640. name: undefined,
  11641. validateRequestBody: undefined,
  11642. validateRequestParameters: undefined,
  11643. };
  11644. const data: any = await parseBody(output.body, context);
  11645. if (data.id !== undefined && data.id !== null) {
  11646. contents.id = data.id;
  11647. }
  11648. if (data.name !== undefined && data.name !== null) {
  11649. contents.name = data.name;
  11650. }
  11651. if (data.validateRequestBody !== undefined && data.validateRequestBody !== null) {
  11652. contents.validateRequestBody = data.validateRequestBody;
  11653. }
  11654. if (data.validateRequestParameters !== undefined && data.validateRequestParameters !== null) {
  11655. contents.validateRequestParameters = data.validateRequestParameters;
  11656. }
  11657. return Promise.resolve(contents);
  11658. };
  11659. const deserializeAws_restJson1GetRequestValidatorCommandError = async (
  11660. output: __HttpResponse,
  11661. context: __SerdeContext
  11662. ): Promise<GetRequestValidatorCommandOutput> => {
  11663. const parsedOutput: any = {
  11664. ...output,
  11665. body: await parseBody(output.body, context),
  11666. };
  11667. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11668. let errorCode: string = "UnknownError";
  11669. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11670. switch (errorCode) {
  11671. case "NotFoundException":
  11672. case "com.amazonaws.apigateway#NotFoundException":
  11673. response = {
  11674. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11675. name: errorCode,
  11676. $metadata: deserializeMetadata(output),
  11677. };
  11678. break;
  11679. case "TooManyRequestsException":
  11680. case "com.amazonaws.apigateway#TooManyRequestsException":
  11681. response = {
  11682. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11683. name: errorCode,
  11684. $metadata: deserializeMetadata(output),
  11685. };
  11686. break;
  11687. case "UnauthorizedException":
  11688. case "com.amazonaws.apigateway#UnauthorizedException":
  11689. response = {
  11690. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11691. name: errorCode,
  11692. $metadata: deserializeMetadata(output),
  11693. };
  11694. break;
  11695. default:
  11696. const parsedBody = parsedOutput.body;
  11697. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11698. response = {
  11699. ...parsedBody,
  11700. name: `${errorCode}`,
  11701. message: parsedBody.message || parsedBody.Message || errorCode,
  11702. $fault: "client",
  11703. $metadata: deserializeMetadata(output),
  11704. } as any;
  11705. }
  11706. const message = response.message || response.Message || errorCode;
  11707. response.message = message;
  11708. delete response.Message;
  11709. return Promise.reject(Object.assign(new Error(message), response));
  11710. };
  11711. export const deserializeAws_restJson1GetRequestValidatorsCommand = async (
  11712. output: __HttpResponse,
  11713. context: __SerdeContext
  11714. ): Promise<GetRequestValidatorsCommandOutput> => {
  11715. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11716. return deserializeAws_restJson1GetRequestValidatorsCommandError(output, context);
  11717. }
  11718. const contents: GetRequestValidatorsCommandOutput = {
  11719. $metadata: deserializeMetadata(output),
  11720. items: undefined,
  11721. position: undefined,
  11722. };
  11723. const data: any = await parseBody(output.body, context);
  11724. if (data.item !== undefined && data.item !== null) {
  11725. contents.items = deserializeAws_restJson1ListOfRequestValidator(data.item, context);
  11726. }
  11727. if (data.position !== undefined && data.position !== null) {
  11728. contents.position = data.position;
  11729. }
  11730. return Promise.resolve(contents);
  11731. };
  11732. const deserializeAws_restJson1GetRequestValidatorsCommandError = async (
  11733. output: __HttpResponse,
  11734. context: __SerdeContext
  11735. ): Promise<GetRequestValidatorsCommandOutput> => {
  11736. const parsedOutput: any = {
  11737. ...output,
  11738. body: await parseBody(output.body, context),
  11739. };
  11740. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11741. let errorCode: string = "UnknownError";
  11742. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11743. switch (errorCode) {
  11744. case "BadRequestException":
  11745. case "com.amazonaws.apigateway#BadRequestException":
  11746. response = {
  11747. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  11748. name: errorCode,
  11749. $metadata: deserializeMetadata(output),
  11750. };
  11751. break;
  11752. case "NotFoundException":
  11753. case "com.amazonaws.apigateway#NotFoundException":
  11754. response = {
  11755. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11756. name: errorCode,
  11757. $metadata: deserializeMetadata(output),
  11758. };
  11759. break;
  11760. case "TooManyRequestsException":
  11761. case "com.amazonaws.apigateway#TooManyRequestsException":
  11762. response = {
  11763. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11764. name: errorCode,
  11765. $metadata: deserializeMetadata(output),
  11766. };
  11767. break;
  11768. case "UnauthorizedException":
  11769. case "com.amazonaws.apigateway#UnauthorizedException":
  11770. response = {
  11771. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11772. name: errorCode,
  11773. $metadata: deserializeMetadata(output),
  11774. };
  11775. break;
  11776. default:
  11777. const parsedBody = parsedOutput.body;
  11778. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11779. response = {
  11780. ...parsedBody,
  11781. name: `${errorCode}`,
  11782. message: parsedBody.message || parsedBody.Message || errorCode,
  11783. $fault: "client",
  11784. $metadata: deserializeMetadata(output),
  11785. } as any;
  11786. }
  11787. const message = response.message || response.Message || errorCode;
  11788. response.message = message;
  11789. delete response.Message;
  11790. return Promise.reject(Object.assign(new Error(message), response));
  11791. };
  11792. export const deserializeAws_restJson1GetResourceCommand = async (
  11793. output: __HttpResponse,
  11794. context: __SerdeContext
  11795. ): Promise<GetResourceCommandOutput> => {
  11796. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11797. return deserializeAws_restJson1GetResourceCommandError(output, context);
  11798. }
  11799. const contents: GetResourceCommandOutput = {
  11800. $metadata: deserializeMetadata(output),
  11801. id: undefined,
  11802. parentId: undefined,
  11803. path: undefined,
  11804. pathPart: undefined,
  11805. resourceMethods: undefined,
  11806. };
  11807. const data: any = await parseBody(output.body, context);
  11808. if (data.id !== undefined && data.id !== null) {
  11809. contents.id = data.id;
  11810. }
  11811. if (data.parentId !== undefined && data.parentId !== null) {
  11812. contents.parentId = data.parentId;
  11813. }
  11814. if (data.path !== undefined && data.path !== null) {
  11815. contents.path = data.path;
  11816. }
  11817. if (data.pathPart !== undefined && data.pathPart !== null) {
  11818. contents.pathPart = data.pathPart;
  11819. }
  11820. if (data.resourceMethods !== undefined && data.resourceMethods !== null) {
  11821. contents.resourceMethods = deserializeAws_restJson1MapOfMethod(data.resourceMethods, context);
  11822. }
  11823. return Promise.resolve(contents);
  11824. };
  11825. const deserializeAws_restJson1GetResourceCommandError = async (
  11826. output: __HttpResponse,
  11827. context: __SerdeContext
  11828. ): Promise<GetResourceCommandOutput> => {
  11829. const parsedOutput: any = {
  11830. ...output,
  11831. body: await parseBody(output.body, context),
  11832. };
  11833. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11834. let errorCode: string = "UnknownError";
  11835. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11836. switch (errorCode) {
  11837. case "NotFoundException":
  11838. case "com.amazonaws.apigateway#NotFoundException":
  11839. response = {
  11840. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11841. name: errorCode,
  11842. $metadata: deserializeMetadata(output),
  11843. };
  11844. break;
  11845. case "TooManyRequestsException":
  11846. case "com.amazonaws.apigateway#TooManyRequestsException":
  11847. response = {
  11848. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11849. name: errorCode,
  11850. $metadata: deserializeMetadata(output),
  11851. };
  11852. break;
  11853. case "UnauthorizedException":
  11854. case "com.amazonaws.apigateway#UnauthorizedException":
  11855. response = {
  11856. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11857. name: errorCode,
  11858. $metadata: deserializeMetadata(output),
  11859. };
  11860. break;
  11861. default:
  11862. const parsedBody = parsedOutput.body;
  11863. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11864. response = {
  11865. ...parsedBody,
  11866. name: `${errorCode}`,
  11867. message: parsedBody.message || parsedBody.Message || errorCode,
  11868. $fault: "client",
  11869. $metadata: deserializeMetadata(output),
  11870. } as any;
  11871. }
  11872. const message = response.message || response.Message || errorCode;
  11873. response.message = message;
  11874. delete response.Message;
  11875. return Promise.reject(Object.assign(new Error(message), response));
  11876. };
  11877. export const deserializeAws_restJson1GetResourcesCommand = async (
  11878. output: __HttpResponse,
  11879. context: __SerdeContext
  11880. ): Promise<GetResourcesCommandOutput> => {
  11881. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11882. return deserializeAws_restJson1GetResourcesCommandError(output, context);
  11883. }
  11884. const contents: GetResourcesCommandOutput = {
  11885. $metadata: deserializeMetadata(output),
  11886. items: undefined,
  11887. position: undefined,
  11888. };
  11889. const data: any = await parseBody(output.body, context);
  11890. if (data.item !== undefined && data.item !== null) {
  11891. contents.items = deserializeAws_restJson1ListOfResource(data.item, context);
  11892. }
  11893. if (data.position !== undefined && data.position !== null) {
  11894. contents.position = data.position;
  11895. }
  11896. return Promise.resolve(contents);
  11897. };
  11898. const deserializeAws_restJson1GetResourcesCommandError = async (
  11899. output: __HttpResponse,
  11900. context: __SerdeContext
  11901. ): Promise<GetResourcesCommandOutput> => {
  11902. const parsedOutput: any = {
  11903. ...output,
  11904. body: await parseBody(output.body, context),
  11905. };
  11906. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  11907. let errorCode: string = "UnknownError";
  11908. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  11909. switch (errorCode) {
  11910. case "BadRequestException":
  11911. case "com.amazonaws.apigateway#BadRequestException":
  11912. response = {
  11913. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  11914. name: errorCode,
  11915. $metadata: deserializeMetadata(output),
  11916. };
  11917. break;
  11918. case "NotFoundException":
  11919. case "com.amazonaws.apigateway#NotFoundException":
  11920. response = {
  11921. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  11922. name: errorCode,
  11923. $metadata: deserializeMetadata(output),
  11924. };
  11925. break;
  11926. case "TooManyRequestsException":
  11927. case "com.amazonaws.apigateway#TooManyRequestsException":
  11928. response = {
  11929. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  11930. name: errorCode,
  11931. $metadata: deserializeMetadata(output),
  11932. };
  11933. break;
  11934. case "UnauthorizedException":
  11935. case "com.amazonaws.apigateway#UnauthorizedException":
  11936. response = {
  11937. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  11938. name: errorCode,
  11939. $metadata: deserializeMetadata(output),
  11940. };
  11941. break;
  11942. default:
  11943. const parsedBody = parsedOutput.body;
  11944. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  11945. response = {
  11946. ...parsedBody,
  11947. name: `${errorCode}`,
  11948. message: parsedBody.message || parsedBody.Message || errorCode,
  11949. $fault: "client",
  11950. $metadata: deserializeMetadata(output),
  11951. } as any;
  11952. }
  11953. const message = response.message || response.Message || errorCode;
  11954. response.message = message;
  11955. delete response.Message;
  11956. return Promise.reject(Object.assign(new Error(message), response));
  11957. };
  11958. export const deserializeAws_restJson1GetRestApiCommand = async (
  11959. output: __HttpResponse,
  11960. context: __SerdeContext
  11961. ): Promise<GetRestApiCommandOutput> => {
  11962. if (output.statusCode !== 200 && output.statusCode >= 400) {
  11963. return deserializeAws_restJson1GetRestApiCommandError(output, context);
  11964. }
  11965. const contents: GetRestApiCommandOutput = {
  11966. $metadata: deserializeMetadata(output),
  11967. apiKeySource: undefined,
  11968. binaryMediaTypes: undefined,
  11969. createdDate: undefined,
  11970. description: undefined,
  11971. endpointConfiguration: undefined,
  11972. id: undefined,
  11973. minimumCompressionSize: undefined,
  11974. name: undefined,
  11975. policy: undefined,
  11976. tags: undefined,
  11977. version: undefined,
  11978. warnings: undefined,
  11979. };
  11980. const data: any = await parseBody(output.body, context);
  11981. if (data.apiKeySource !== undefined && data.apiKeySource !== null) {
  11982. contents.apiKeySource = data.apiKeySource;
  11983. }
  11984. if (data.binaryMediaTypes !== undefined && data.binaryMediaTypes !== null) {
  11985. contents.binaryMediaTypes = deserializeAws_restJson1ListOfString(data.binaryMediaTypes, context);
  11986. }
  11987. if (data.createdDate !== undefined && data.createdDate !== null) {
  11988. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  11989. }
  11990. if (data.description !== undefined && data.description !== null) {
  11991. contents.description = data.description;
  11992. }
  11993. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  11994. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  11995. }
  11996. if (data.id !== undefined && data.id !== null) {
  11997. contents.id = data.id;
  11998. }
  11999. if (data.minimumCompressionSize !== undefined && data.minimumCompressionSize !== null) {
  12000. contents.minimumCompressionSize = data.minimumCompressionSize;
  12001. }
  12002. if (data.name !== undefined && data.name !== null) {
  12003. contents.name = data.name;
  12004. }
  12005. if (data.policy !== undefined && data.policy !== null) {
  12006. contents.policy = data.policy;
  12007. }
  12008. if (data.tags !== undefined && data.tags !== null) {
  12009. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  12010. }
  12011. if (data.version !== undefined && data.version !== null) {
  12012. contents.version = data.version;
  12013. }
  12014. if (data.warnings !== undefined && data.warnings !== null) {
  12015. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  12016. }
  12017. return Promise.resolve(contents);
  12018. };
  12019. const deserializeAws_restJson1GetRestApiCommandError = async (
  12020. output: __HttpResponse,
  12021. context: __SerdeContext
  12022. ): Promise<GetRestApiCommandOutput> => {
  12023. const parsedOutput: any = {
  12024. ...output,
  12025. body: await parseBody(output.body, context),
  12026. };
  12027. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12028. let errorCode: string = "UnknownError";
  12029. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12030. switch (errorCode) {
  12031. case "NotFoundException":
  12032. case "com.amazonaws.apigateway#NotFoundException":
  12033. response = {
  12034. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12035. name: errorCode,
  12036. $metadata: deserializeMetadata(output),
  12037. };
  12038. break;
  12039. case "TooManyRequestsException":
  12040. case "com.amazonaws.apigateway#TooManyRequestsException":
  12041. response = {
  12042. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12043. name: errorCode,
  12044. $metadata: deserializeMetadata(output),
  12045. };
  12046. break;
  12047. case "UnauthorizedException":
  12048. case "com.amazonaws.apigateway#UnauthorizedException":
  12049. response = {
  12050. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12051. name: errorCode,
  12052. $metadata: deserializeMetadata(output),
  12053. };
  12054. break;
  12055. default:
  12056. const parsedBody = parsedOutput.body;
  12057. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12058. response = {
  12059. ...parsedBody,
  12060. name: `${errorCode}`,
  12061. message: parsedBody.message || parsedBody.Message || errorCode,
  12062. $fault: "client",
  12063. $metadata: deserializeMetadata(output),
  12064. } as any;
  12065. }
  12066. const message = response.message || response.Message || errorCode;
  12067. response.message = message;
  12068. delete response.Message;
  12069. return Promise.reject(Object.assign(new Error(message), response));
  12070. };
  12071. export const deserializeAws_restJson1GetRestApisCommand = async (
  12072. output: __HttpResponse,
  12073. context: __SerdeContext
  12074. ): Promise<GetRestApisCommandOutput> => {
  12075. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12076. return deserializeAws_restJson1GetRestApisCommandError(output, context);
  12077. }
  12078. const contents: GetRestApisCommandOutput = {
  12079. $metadata: deserializeMetadata(output),
  12080. items: undefined,
  12081. position: undefined,
  12082. };
  12083. const data: any = await parseBody(output.body, context);
  12084. if (data.item !== undefined && data.item !== null) {
  12085. contents.items = deserializeAws_restJson1ListOfRestApi(data.item, context);
  12086. }
  12087. if (data.position !== undefined && data.position !== null) {
  12088. contents.position = data.position;
  12089. }
  12090. return Promise.resolve(contents);
  12091. };
  12092. const deserializeAws_restJson1GetRestApisCommandError = async (
  12093. output: __HttpResponse,
  12094. context: __SerdeContext
  12095. ): Promise<GetRestApisCommandOutput> => {
  12096. const parsedOutput: any = {
  12097. ...output,
  12098. body: await parseBody(output.body, context),
  12099. };
  12100. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12101. let errorCode: string = "UnknownError";
  12102. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12103. switch (errorCode) {
  12104. case "BadRequestException":
  12105. case "com.amazonaws.apigateway#BadRequestException":
  12106. response = {
  12107. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12108. name: errorCode,
  12109. $metadata: deserializeMetadata(output),
  12110. };
  12111. break;
  12112. case "TooManyRequestsException":
  12113. case "com.amazonaws.apigateway#TooManyRequestsException":
  12114. response = {
  12115. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12116. name: errorCode,
  12117. $metadata: deserializeMetadata(output),
  12118. };
  12119. break;
  12120. case "UnauthorizedException":
  12121. case "com.amazonaws.apigateway#UnauthorizedException":
  12122. response = {
  12123. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12124. name: errorCode,
  12125. $metadata: deserializeMetadata(output),
  12126. };
  12127. break;
  12128. default:
  12129. const parsedBody = parsedOutput.body;
  12130. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12131. response = {
  12132. ...parsedBody,
  12133. name: `${errorCode}`,
  12134. message: parsedBody.message || parsedBody.Message || errorCode,
  12135. $fault: "client",
  12136. $metadata: deserializeMetadata(output),
  12137. } as any;
  12138. }
  12139. const message = response.message || response.Message || errorCode;
  12140. response.message = message;
  12141. delete response.Message;
  12142. return Promise.reject(Object.assign(new Error(message), response));
  12143. };
  12144. export const deserializeAws_restJson1GetSdkCommand = async (
  12145. output: __HttpResponse,
  12146. context: __SerdeContext
  12147. ): Promise<GetSdkCommandOutput> => {
  12148. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12149. return deserializeAws_restJson1GetSdkCommandError(output, context);
  12150. }
  12151. const contents: GetSdkCommandOutput = {
  12152. $metadata: deserializeMetadata(output),
  12153. body: undefined,
  12154. contentDisposition: undefined,
  12155. contentType: undefined,
  12156. };
  12157. if (output.headers["content-disposition"] !== undefined) {
  12158. contents.contentDisposition = output.headers["content-disposition"];
  12159. }
  12160. if (output.headers["content-type"] !== undefined) {
  12161. contents.contentType = output.headers["content-type"];
  12162. }
  12163. const data: any = await collectBody(output.body, context);
  12164. contents.body = data;
  12165. return Promise.resolve(contents);
  12166. };
  12167. const deserializeAws_restJson1GetSdkCommandError = async (
  12168. output: __HttpResponse,
  12169. context: __SerdeContext
  12170. ): Promise<GetSdkCommandOutput> => {
  12171. const parsedOutput: any = {
  12172. ...output,
  12173. body: await parseBody(output.body, context),
  12174. };
  12175. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12176. let errorCode: string = "UnknownError";
  12177. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12178. switch (errorCode) {
  12179. case "BadRequestException":
  12180. case "com.amazonaws.apigateway#BadRequestException":
  12181. response = {
  12182. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12183. name: errorCode,
  12184. $metadata: deserializeMetadata(output),
  12185. };
  12186. break;
  12187. case "ConflictException":
  12188. case "com.amazonaws.apigateway#ConflictException":
  12189. response = {
  12190. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  12191. name: errorCode,
  12192. $metadata: deserializeMetadata(output),
  12193. };
  12194. break;
  12195. case "NotFoundException":
  12196. case "com.amazonaws.apigateway#NotFoundException":
  12197. response = {
  12198. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12199. name: errorCode,
  12200. $metadata: deserializeMetadata(output),
  12201. };
  12202. break;
  12203. case "TooManyRequestsException":
  12204. case "com.amazonaws.apigateway#TooManyRequestsException":
  12205. response = {
  12206. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12207. name: errorCode,
  12208. $metadata: deserializeMetadata(output),
  12209. };
  12210. break;
  12211. case "UnauthorizedException":
  12212. case "com.amazonaws.apigateway#UnauthorizedException":
  12213. response = {
  12214. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12215. name: errorCode,
  12216. $metadata: deserializeMetadata(output),
  12217. };
  12218. break;
  12219. default:
  12220. const parsedBody = parsedOutput.body;
  12221. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12222. response = {
  12223. ...parsedBody,
  12224. name: `${errorCode}`,
  12225. message: parsedBody.message || parsedBody.Message || errorCode,
  12226. $fault: "client",
  12227. $metadata: deserializeMetadata(output),
  12228. } as any;
  12229. }
  12230. const message = response.message || response.Message || errorCode;
  12231. response.message = message;
  12232. delete response.Message;
  12233. return Promise.reject(Object.assign(new Error(message), response));
  12234. };
  12235. export const deserializeAws_restJson1GetSdkTypeCommand = async (
  12236. output: __HttpResponse,
  12237. context: __SerdeContext
  12238. ): Promise<GetSdkTypeCommandOutput> => {
  12239. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12240. return deserializeAws_restJson1GetSdkTypeCommandError(output, context);
  12241. }
  12242. const contents: GetSdkTypeCommandOutput = {
  12243. $metadata: deserializeMetadata(output),
  12244. configurationProperties: undefined,
  12245. description: undefined,
  12246. friendlyName: undefined,
  12247. id: undefined,
  12248. };
  12249. const data: any = await parseBody(output.body, context);
  12250. if (data.configurationProperties !== undefined && data.configurationProperties !== null) {
  12251. contents.configurationProperties = deserializeAws_restJson1ListOfSdkConfigurationProperty(
  12252. data.configurationProperties,
  12253. context
  12254. );
  12255. }
  12256. if (data.description !== undefined && data.description !== null) {
  12257. contents.description = data.description;
  12258. }
  12259. if (data.friendlyName !== undefined && data.friendlyName !== null) {
  12260. contents.friendlyName = data.friendlyName;
  12261. }
  12262. if (data.id !== undefined && data.id !== null) {
  12263. contents.id = data.id;
  12264. }
  12265. return Promise.resolve(contents);
  12266. };
  12267. const deserializeAws_restJson1GetSdkTypeCommandError = async (
  12268. output: __HttpResponse,
  12269. context: __SerdeContext
  12270. ): Promise<GetSdkTypeCommandOutput> => {
  12271. const parsedOutput: any = {
  12272. ...output,
  12273. body: await parseBody(output.body, context),
  12274. };
  12275. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12276. let errorCode: string = "UnknownError";
  12277. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12278. switch (errorCode) {
  12279. case "NotFoundException":
  12280. case "com.amazonaws.apigateway#NotFoundException":
  12281. response = {
  12282. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12283. name: errorCode,
  12284. $metadata: deserializeMetadata(output),
  12285. };
  12286. break;
  12287. case "TooManyRequestsException":
  12288. case "com.amazonaws.apigateway#TooManyRequestsException":
  12289. response = {
  12290. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12291. name: errorCode,
  12292. $metadata: deserializeMetadata(output),
  12293. };
  12294. break;
  12295. case "UnauthorizedException":
  12296. case "com.amazonaws.apigateway#UnauthorizedException":
  12297. response = {
  12298. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12299. name: errorCode,
  12300. $metadata: deserializeMetadata(output),
  12301. };
  12302. break;
  12303. default:
  12304. const parsedBody = parsedOutput.body;
  12305. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12306. response = {
  12307. ...parsedBody,
  12308. name: `${errorCode}`,
  12309. message: parsedBody.message || parsedBody.Message || errorCode,
  12310. $fault: "client",
  12311. $metadata: deserializeMetadata(output),
  12312. } as any;
  12313. }
  12314. const message = response.message || response.Message || errorCode;
  12315. response.message = message;
  12316. delete response.Message;
  12317. return Promise.reject(Object.assign(new Error(message), response));
  12318. };
  12319. export const deserializeAws_restJson1GetSdkTypesCommand = async (
  12320. output: __HttpResponse,
  12321. context: __SerdeContext
  12322. ): Promise<GetSdkTypesCommandOutput> => {
  12323. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12324. return deserializeAws_restJson1GetSdkTypesCommandError(output, context);
  12325. }
  12326. const contents: GetSdkTypesCommandOutput = {
  12327. $metadata: deserializeMetadata(output),
  12328. items: undefined,
  12329. };
  12330. const data: any = await parseBody(output.body, context);
  12331. if (data.item !== undefined && data.item !== null) {
  12332. contents.items = deserializeAws_restJson1ListOfSdkType(data.item, context);
  12333. }
  12334. return Promise.resolve(contents);
  12335. };
  12336. const deserializeAws_restJson1GetSdkTypesCommandError = async (
  12337. output: __HttpResponse,
  12338. context: __SerdeContext
  12339. ): Promise<GetSdkTypesCommandOutput> => {
  12340. const parsedOutput: any = {
  12341. ...output,
  12342. body: await parseBody(output.body, context),
  12343. };
  12344. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12345. let errorCode: string = "UnknownError";
  12346. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12347. switch (errorCode) {
  12348. case "TooManyRequestsException":
  12349. case "com.amazonaws.apigateway#TooManyRequestsException":
  12350. response = {
  12351. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12352. name: errorCode,
  12353. $metadata: deserializeMetadata(output),
  12354. };
  12355. break;
  12356. case "UnauthorizedException":
  12357. case "com.amazonaws.apigateway#UnauthorizedException":
  12358. response = {
  12359. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12360. name: errorCode,
  12361. $metadata: deserializeMetadata(output),
  12362. };
  12363. break;
  12364. default:
  12365. const parsedBody = parsedOutput.body;
  12366. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12367. response = {
  12368. ...parsedBody,
  12369. name: `${errorCode}`,
  12370. message: parsedBody.message || parsedBody.Message || errorCode,
  12371. $fault: "client",
  12372. $metadata: deserializeMetadata(output),
  12373. } as any;
  12374. }
  12375. const message = response.message || response.Message || errorCode;
  12376. response.message = message;
  12377. delete response.Message;
  12378. return Promise.reject(Object.assign(new Error(message), response));
  12379. };
  12380. export const deserializeAws_restJson1GetStageCommand = async (
  12381. output: __HttpResponse,
  12382. context: __SerdeContext
  12383. ): Promise<GetStageCommandOutput> => {
  12384. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12385. return deserializeAws_restJson1GetStageCommandError(output, context);
  12386. }
  12387. const contents: GetStageCommandOutput = {
  12388. $metadata: deserializeMetadata(output),
  12389. accessLogSettings: undefined,
  12390. cacheClusterEnabled: undefined,
  12391. cacheClusterSize: undefined,
  12392. cacheClusterStatus: undefined,
  12393. canarySettings: undefined,
  12394. clientCertificateId: undefined,
  12395. createdDate: undefined,
  12396. deploymentId: undefined,
  12397. description: undefined,
  12398. documentationVersion: undefined,
  12399. lastUpdatedDate: undefined,
  12400. methodSettings: undefined,
  12401. stageName: undefined,
  12402. tags: undefined,
  12403. tracingEnabled: undefined,
  12404. variables: undefined,
  12405. webAclArn: undefined,
  12406. };
  12407. const data: any = await parseBody(output.body, context);
  12408. if (data.accessLogSettings !== undefined && data.accessLogSettings !== null) {
  12409. contents.accessLogSettings = deserializeAws_restJson1AccessLogSettings(data.accessLogSettings, context);
  12410. }
  12411. if (data.cacheClusterEnabled !== undefined && data.cacheClusterEnabled !== null) {
  12412. contents.cacheClusterEnabled = data.cacheClusterEnabled;
  12413. }
  12414. if (data.cacheClusterSize !== undefined && data.cacheClusterSize !== null) {
  12415. contents.cacheClusterSize = data.cacheClusterSize;
  12416. }
  12417. if (data.cacheClusterStatus !== undefined && data.cacheClusterStatus !== null) {
  12418. contents.cacheClusterStatus = data.cacheClusterStatus;
  12419. }
  12420. if (data.canarySettings !== undefined && data.canarySettings !== null) {
  12421. contents.canarySettings = deserializeAws_restJson1CanarySettings(data.canarySettings, context);
  12422. }
  12423. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  12424. contents.clientCertificateId = data.clientCertificateId;
  12425. }
  12426. if (data.createdDate !== undefined && data.createdDate !== null) {
  12427. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  12428. }
  12429. if (data.deploymentId !== undefined && data.deploymentId !== null) {
  12430. contents.deploymentId = data.deploymentId;
  12431. }
  12432. if (data.description !== undefined && data.description !== null) {
  12433. contents.description = data.description;
  12434. }
  12435. if (data.documentationVersion !== undefined && data.documentationVersion !== null) {
  12436. contents.documentationVersion = data.documentationVersion;
  12437. }
  12438. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  12439. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  12440. }
  12441. if (data.methodSettings !== undefined && data.methodSettings !== null) {
  12442. contents.methodSettings = deserializeAws_restJson1MapOfMethodSettings(data.methodSettings, context);
  12443. }
  12444. if (data.stageName !== undefined && data.stageName !== null) {
  12445. contents.stageName = data.stageName;
  12446. }
  12447. if (data.tags !== undefined && data.tags !== null) {
  12448. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  12449. }
  12450. if (data.tracingEnabled !== undefined && data.tracingEnabled !== null) {
  12451. contents.tracingEnabled = data.tracingEnabled;
  12452. }
  12453. if (data.variables !== undefined && data.variables !== null) {
  12454. contents.variables = deserializeAws_restJson1MapOfStringToString(data.variables, context);
  12455. }
  12456. if (data.webAclArn !== undefined && data.webAclArn !== null) {
  12457. contents.webAclArn = data.webAclArn;
  12458. }
  12459. return Promise.resolve(contents);
  12460. };
  12461. const deserializeAws_restJson1GetStageCommandError = async (
  12462. output: __HttpResponse,
  12463. context: __SerdeContext
  12464. ): Promise<GetStageCommandOutput> => {
  12465. const parsedOutput: any = {
  12466. ...output,
  12467. body: await parseBody(output.body, context),
  12468. };
  12469. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12470. let errorCode: string = "UnknownError";
  12471. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12472. switch (errorCode) {
  12473. case "NotFoundException":
  12474. case "com.amazonaws.apigateway#NotFoundException":
  12475. response = {
  12476. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12477. name: errorCode,
  12478. $metadata: deserializeMetadata(output),
  12479. };
  12480. break;
  12481. case "TooManyRequestsException":
  12482. case "com.amazonaws.apigateway#TooManyRequestsException":
  12483. response = {
  12484. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12485. name: errorCode,
  12486. $metadata: deserializeMetadata(output),
  12487. };
  12488. break;
  12489. case "UnauthorizedException":
  12490. case "com.amazonaws.apigateway#UnauthorizedException":
  12491. response = {
  12492. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12493. name: errorCode,
  12494. $metadata: deserializeMetadata(output),
  12495. };
  12496. break;
  12497. default:
  12498. const parsedBody = parsedOutput.body;
  12499. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12500. response = {
  12501. ...parsedBody,
  12502. name: `${errorCode}`,
  12503. message: parsedBody.message || parsedBody.Message || errorCode,
  12504. $fault: "client",
  12505. $metadata: deserializeMetadata(output),
  12506. } as any;
  12507. }
  12508. const message = response.message || response.Message || errorCode;
  12509. response.message = message;
  12510. delete response.Message;
  12511. return Promise.reject(Object.assign(new Error(message), response));
  12512. };
  12513. export const deserializeAws_restJson1GetStagesCommand = async (
  12514. output: __HttpResponse,
  12515. context: __SerdeContext
  12516. ): Promise<GetStagesCommandOutput> => {
  12517. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12518. return deserializeAws_restJson1GetStagesCommandError(output, context);
  12519. }
  12520. const contents: GetStagesCommandOutput = {
  12521. $metadata: deserializeMetadata(output),
  12522. item: undefined,
  12523. };
  12524. const data: any = await parseBody(output.body, context);
  12525. if (data.item !== undefined && data.item !== null) {
  12526. contents.item = deserializeAws_restJson1ListOfStage(data.item, context);
  12527. }
  12528. return Promise.resolve(contents);
  12529. };
  12530. const deserializeAws_restJson1GetStagesCommandError = async (
  12531. output: __HttpResponse,
  12532. context: __SerdeContext
  12533. ): Promise<GetStagesCommandOutput> => {
  12534. const parsedOutput: any = {
  12535. ...output,
  12536. body: await parseBody(output.body, context),
  12537. };
  12538. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12539. let errorCode: string = "UnknownError";
  12540. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12541. switch (errorCode) {
  12542. case "NotFoundException":
  12543. case "com.amazonaws.apigateway#NotFoundException":
  12544. response = {
  12545. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12546. name: errorCode,
  12547. $metadata: deserializeMetadata(output),
  12548. };
  12549. break;
  12550. case "TooManyRequestsException":
  12551. case "com.amazonaws.apigateway#TooManyRequestsException":
  12552. response = {
  12553. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12554. name: errorCode,
  12555. $metadata: deserializeMetadata(output),
  12556. };
  12557. break;
  12558. case "UnauthorizedException":
  12559. case "com.amazonaws.apigateway#UnauthorizedException":
  12560. response = {
  12561. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12562. name: errorCode,
  12563. $metadata: deserializeMetadata(output),
  12564. };
  12565. break;
  12566. default:
  12567. const parsedBody = parsedOutput.body;
  12568. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12569. response = {
  12570. ...parsedBody,
  12571. name: `${errorCode}`,
  12572. message: parsedBody.message || parsedBody.Message || errorCode,
  12573. $fault: "client",
  12574. $metadata: deserializeMetadata(output),
  12575. } as any;
  12576. }
  12577. const message = response.message || response.Message || errorCode;
  12578. response.message = message;
  12579. delete response.Message;
  12580. return Promise.reject(Object.assign(new Error(message), response));
  12581. };
  12582. export const deserializeAws_restJson1GetTagsCommand = async (
  12583. output: __HttpResponse,
  12584. context: __SerdeContext
  12585. ): Promise<GetTagsCommandOutput> => {
  12586. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12587. return deserializeAws_restJson1GetTagsCommandError(output, context);
  12588. }
  12589. const contents: GetTagsCommandOutput = {
  12590. $metadata: deserializeMetadata(output),
  12591. tags: undefined,
  12592. };
  12593. const data: any = await parseBody(output.body, context);
  12594. if (data.tags !== undefined && data.tags !== null) {
  12595. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  12596. }
  12597. return Promise.resolve(contents);
  12598. };
  12599. const deserializeAws_restJson1GetTagsCommandError = async (
  12600. output: __HttpResponse,
  12601. context: __SerdeContext
  12602. ): Promise<GetTagsCommandOutput> => {
  12603. const parsedOutput: any = {
  12604. ...output,
  12605. body: await parseBody(output.body, context),
  12606. };
  12607. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12608. let errorCode: string = "UnknownError";
  12609. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12610. switch (errorCode) {
  12611. case "BadRequestException":
  12612. case "com.amazonaws.apigateway#BadRequestException":
  12613. response = {
  12614. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12615. name: errorCode,
  12616. $metadata: deserializeMetadata(output),
  12617. };
  12618. break;
  12619. case "LimitExceededException":
  12620. case "com.amazonaws.apigateway#LimitExceededException":
  12621. response = {
  12622. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  12623. name: errorCode,
  12624. $metadata: deserializeMetadata(output),
  12625. };
  12626. break;
  12627. case "NotFoundException":
  12628. case "com.amazonaws.apigateway#NotFoundException":
  12629. response = {
  12630. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12631. name: errorCode,
  12632. $metadata: deserializeMetadata(output),
  12633. };
  12634. break;
  12635. case "TooManyRequestsException":
  12636. case "com.amazonaws.apigateway#TooManyRequestsException":
  12637. response = {
  12638. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12639. name: errorCode,
  12640. $metadata: deserializeMetadata(output),
  12641. };
  12642. break;
  12643. case "UnauthorizedException":
  12644. case "com.amazonaws.apigateway#UnauthorizedException":
  12645. response = {
  12646. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12647. name: errorCode,
  12648. $metadata: deserializeMetadata(output),
  12649. };
  12650. break;
  12651. default:
  12652. const parsedBody = parsedOutput.body;
  12653. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12654. response = {
  12655. ...parsedBody,
  12656. name: `${errorCode}`,
  12657. message: parsedBody.message || parsedBody.Message || errorCode,
  12658. $fault: "client",
  12659. $metadata: deserializeMetadata(output),
  12660. } as any;
  12661. }
  12662. const message = response.message || response.Message || errorCode;
  12663. response.message = message;
  12664. delete response.Message;
  12665. return Promise.reject(Object.assign(new Error(message), response));
  12666. };
  12667. export const deserializeAws_restJson1GetUsageCommand = async (
  12668. output: __HttpResponse,
  12669. context: __SerdeContext
  12670. ): Promise<GetUsageCommandOutput> => {
  12671. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12672. return deserializeAws_restJson1GetUsageCommandError(output, context);
  12673. }
  12674. const contents: GetUsageCommandOutput = {
  12675. $metadata: deserializeMetadata(output),
  12676. endDate: undefined,
  12677. items: undefined,
  12678. position: undefined,
  12679. startDate: undefined,
  12680. usagePlanId: undefined,
  12681. };
  12682. const data: any = await parseBody(output.body, context);
  12683. if (data.endDate !== undefined && data.endDate !== null) {
  12684. contents.endDate = data.endDate;
  12685. }
  12686. if (data.values !== undefined && data.values !== null) {
  12687. contents.items = deserializeAws_restJson1MapOfKeyUsages(data.values, context);
  12688. }
  12689. if (data.position !== undefined && data.position !== null) {
  12690. contents.position = data.position;
  12691. }
  12692. if (data.startDate !== undefined && data.startDate !== null) {
  12693. contents.startDate = data.startDate;
  12694. }
  12695. if (data.usagePlanId !== undefined && data.usagePlanId !== null) {
  12696. contents.usagePlanId = data.usagePlanId;
  12697. }
  12698. return Promise.resolve(contents);
  12699. };
  12700. const deserializeAws_restJson1GetUsageCommandError = async (
  12701. output: __HttpResponse,
  12702. context: __SerdeContext
  12703. ): Promise<GetUsageCommandOutput> => {
  12704. const parsedOutput: any = {
  12705. ...output,
  12706. body: await parseBody(output.body, context),
  12707. };
  12708. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12709. let errorCode: string = "UnknownError";
  12710. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12711. switch (errorCode) {
  12712. case "BadRequestException":
  12713. case "com.amazonaws.apigateway#BadRequestException":
  12714. response = {
  12715. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12716. name: errorCode,
  12717. $metadata: deserializeMetadata(output),
  12718. };
  12719. break;
  12720. case "NotFoundException":
  12721. case "com.amazonaws.apigateway#NotFoundException":
  12722. response = {
  12723. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12724. name: errorCode,
  12725. $metadata: deserializeMetadata(output),
  12726. };
  12727. break;
  12728. case "TooManyRequestsException":
  12729. case "com.amazonaws.apigateway#TooManyRequestsException":
  12730. response = {
  12731. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12732. name: errorCode,
  12733. $metadata: deserializeMetadata(output),
  12734. };
  12735. break;
  12736. case "UnauthorizedException":
  12737. case "com.amazonaws.apigateway#UnauthorizedException":
  12738. response = {
  12739. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12740. name: errorCode,
  12741. $metadata: deserializeMetadata(output),
  12742. };
  12743. break;
  12744. default:
  12745. const parsedBody = parsedOutput.body;
  12746. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12747. response = {
  12748. ...parsedBody,
  12749. name: `${errorCode}`,
  12750. message: parsedBody.message || parsedBody.Message || errorCode,
  12751. $fault: "client",
  12752. $metadata: deserializeMetadata(output),
  12753. } as any;
  12754. }
  12755. const message = response.message || response.Message || errorCode;
  12756. response.message = message;
  12757. delete response.Message;
  12758. return Promise.reject(Object.assign(new Error(message), response));
  12759. };
  12760. export const deserializeAws_restJson1GetUsagePlanCommand = async (
  12761. output: __HttpResponse,
  12762. context: __SerdeContext
  12763. ): Promise<GetUsagePlanCommandOutput> => {
  12764. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12765. return deserializeAws_restJson1GetUsagePlanCommandError(output, context);
  12766. }
  12767. const contents: GetUsagePlanCommandOutput = {
  12768. $metadata: deserializeMetadata(output),
  12769. apiStages: undefined,
  12770. description: undefined,
  12771. id: undefined,
  12772. name: undefined,
  12773. productCode: undefined,
  12774. quota: undefined,
  12775. tags: undefined,
  12776. throttle: undefined,
  12777. };
  12778. const data: any = await parseBody(output.body, context);
  12779. if (data.apiStages !== undefined && data.apiStages !== null) {
  12780. contents.apiStages = deserializeAws_restJson1ListOfApiStage(data.apiStages, context);
  12781. }
  12782. if (data.description !== undefined && data.description !== null) {
  12783. contents.description = data.description;
  12784. }
  12785. if (data.id !== undefined && data.id !== null) {
  12786. contents.id = data.id;
  12787. }
  12788. if (data.name !== undefined && data.name !== null) {
  12789. contents.name = data.name;
  12790. }
  12791. if (data.productCode !== undefined && data.productCode !== null) {
  12792. contents.productCode = data.productCode;
  12793. }
  12794. if (data.quota !== undefined && data.quota !== null) {
  12795. contents.quota = deserializeAws_restJson1QuotaSettings(data.quota, context);
  12796. }
  12797. if (data.tags !== undefined && data.tags !== null) {
  12798. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  12799. }
  12800. if (data.throttle !== undefined && data.throttle !== null) {
  12801. contents.throttle = deserializeAws_restJson1ThrottleSettings(data.throttle, context);
  12802. }
  12803. return Promise.resolve(contents);
  12804. };
  12805. const deserializeAws_restJson1GetUsagePlanCommandError = async (
  12806. output: __HttpResponse,
  12807. context: __SerdeContext
  12808. ): Promise<GetUsagePlanCommandOutput> => {
  12809. const parsedOutput: any = {
  12810. ...output,
  12811. body: await parseBody(output.body, context),
  12812. };
  12813. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12814. let errorCode: string = "UnknownError";
  12815. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12816. switch (errorCode) {
  12817. case "BadRequestException":
  12818. case "com.amazonaws.apigateway#BadRequestException":
  12819. response = {
  12820. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12821. name: errorCode,
  12822. $metadata: deserializeMetadata(output),
  12823. };
  12824. break;
  12825. case "NotFoundException":
  12826. case "com.amazonaws.apigateway#NotFoundException":
  12827. response = {
  12828. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12829. name: errorCode,
  12830. $metadata: deserializeMetadata(output),
  12831. };
  12832. break;
  12833. case "TooManyRequestsException":
  12834. case "com.amazonaws.apigateway#TooManyRequestsException":
  12835. response = {
  12836. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12837. name: errorCode,
  12838. $metadata: deserializeMetadata(output),
  12839. };
  12840. break;
  12841. case "UnauthorizedException":
  12842. case "com.amazonaws.apigateway#UnauthorizedException":
  12843. response = {
  12844. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12845. name: errorCode,
  12846. $metadata: deserializeMetadata(output),
  12847. };
  12848. break;
  12849. default:
  12850. const parsedBody = parsedOutput.body;
  12851. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12852. response = {
  12853. ...parsedBody,
  12854. name: `${errorCode}`,
  12855. message: parsedBody.message || parsedBody.Message || errorCode,
  12856. $fault: "client",
  12857. $metadata: deserializeMetadata(output),
  12858. } as any;
  12859. }
  12860. const message = response.message || response.Message || errorCode;
  12861. response.message = message;
  12862. delete response.Message;
  12863. return Promise.reject(Object.assign(new Error(message), response));
  12864. };
  12865. export const deserializeAws_restJson1GetUsagePlanKeyCommand = async (
  12866. output: __HttpResponse,
  12867. context: __SerdeContext
  12868. ): Promise<GetUsagePlanKeyCommandOutput> => {
  12869. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12870. return deserializeAws_restJson1GetUsagePlanKeyCommandError(output, context);
  12871. }
  12872. const contents: GetUsagePlanKeyCommandOutput = {
  12873. $metadata: deserializeMetadata(output),
  12874. id: undefined,
  12875. name: undefined,
  12876. type: undefined,
  12877. value: undefined,
  12878. };
  12879. const data: any = await parseBody(output.body, context);
  12880. if (data.id !== undefined && data.id !== null) {
  12881. contents.id = data.id;
  12882. }
  12883. if (data.name !== undefined && data.name !== null) {
  12884. contents.name = data.name;
  12885. }
  12886. if (data.type !== undefined && data.type !== null) {
  12887. contents.type = data.type;
  12888. }
  12889. if (data.value !== undefined && data.value !== null) {
  12890. contents.value = data.value;
  12891. }
  12892. return Promise.resolve(contents);
  12893. };
  12894. const deserializeAws_restJson1GetUsagePlanKeyCommandError = async (
  12895. output: __HttpResponse,
  12896. context: __SerdeContext
  12897. ): Promise<GetUsagePlanKeyCommandOutput> => {
  12898. const parsedOutput: any = {
  12899. ...output,
  12900. body: await parseBody(output.body, context),
  12901. };
  12902. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12903. let errorCode: string = "UnknownError";
  12904. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12905. switch (errorCode) {
  12906. case "BadRequestException":
  12907. case "com.amazonaws.apigateway#BadRequestException":
  12908. response = {
  12909. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12910. name: errorCode,
  12911. $metadata: deserializeMetadata(output),
  12912. };
  12913. break;
  12914. case "NotFoundException":
  12915. case "com.amazonaws.apigateway#NotFoundException":
  12916. response = {
  12917. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12918. name: errorCode,
  12919. $metadata: deserializeMetadata(output),
  12920. };
  12921. break;
  12922. case "TooManyRequestsException":
  12923. case "com.amazonaws.apigateway#TooManyRequestsException":
  12924. response = {
  12925. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  12926. name: errorCode,
  12927. $metadata: deserializeMetadata(output),
  12928. };
  12929. break;
  12930. case "UnauthorizedException":
  12931. case "com.amazonaws.apigateway#UnauthorizedException":
  12932. response = {
  12933. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  12934. name: errorCode,
  12935. $metadata: deserializeMetadata(output),
  12936. };
  12937. break;
  12938. default:
  12939. const parsedBody = parsedOutput.body;
  12940. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  12941. response = {
  12942. ...parsedBody,
  12943. name: `${errorCode}`,
  12944. message: parsedBody.message || parsedBody.Message || errorCode,
  12945. $fault: "client",
  12946. $metadata: deserializeMetadata(output),
  12947. } as any;
  12948. }
  12949. const message = response.message || response.Message || errorCode;
  12950. response.message = message;
  12951. delete response.Message;
  12952. return Promise.reject(Object.assign(new Error(message), response));
  12953. };
  12954. export const deserializeAws_restJson1GetUsagePlanKeysCommand = async (
  12955. output: __HttpResponse,
  12956. context: __SerdeContext
  12957. ): Promise<GetUsagePlanKeysCommandOutput> => {
  12958. if (output.statusCode !== 200 && output.statusCode >= 400) {
  12959. return deserializeAws_restJson1GetUsagePlanKeysCommandError(output, context);
  12960. }
  12961. const contents: GetUsagePlanKeysCommandOutput = {
  12962. $metadata: deserializeMetadata(output),
  12963. items: undefined,
  12964. position: undefined,
  12965. };
  12966. const data: any = await parseBody(output.body, context);
  12967. if (data.item !== undefined && data.item !== null) {
  12968. contents.items = deserializeAws_restJson1ListOfUsagePlanKey(data.item, context);
  12969. }
  12970. if (data.position !== undefined && data.position !== null) {
  12971. contents.position = data.position;
  12972. }
  12973. return Promise.resolve(contents);
  12974. };
  12975. const deserializeAws_restJson1GetUsagePlanKeysCommandError = async (
  12976. output: __HttpResponse,
  12977. context: __SerdeContext
  12978. ): Promise<GetUsagePlanKeysCommandOutput> => {
  12979. const parsedOutput: any = {
  12980. ...output,
  12981. body: await parseBody(output.body, context),
  12982. };
  12983. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  12984. let errorCode: string = "UnknownError";
  12985. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  12986. switch (errorCode) {
  12987. case "BadRequestException":
  12988. case "com.amazonaws.apigateway#BadRequestException":
  12989. response = {
  12990. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  12991. name: errorCode,
  12992. $metadata: deserializeMetadata(output),
  12993. };
  12994. break;
  12995. case "NotFoundException":
  12996. case "com.amazonaws.apigateway#NotFoundException":
  12997. response = {
  12998. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  12999. name: errorCode,
  13000. $metadata: deserializeMetadata(output),
  13001. };
  13002. break;
  13003. case "TooManyRequestsException":
  13004. case "com.amazonaws.apigateway#TooManyRequestsException":
  13005. response = {
  13006. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13007. name: errorCode,
  13008. $metadata: deserializeMetadata(output),
  13009. };
  13010. break;
  13011. case "UnauthorizedException":
  13012. case "com.amazonaws.apigateway#UnauthorizedException":
  13013. response = {
  13014. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13015. name: errorCode,
  13016. $metadata: deserializeMetadata(output),
  13017. };
  13018. break;
  13019. default:
  13020. const parsedBody = parsedOutput.body;
  13021. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13022. response = {
  13023. ...parsedBody,
  13024. name: `${errorCode}`,
  13025. message: parsedBody.message || parsedBody.Message || errorCode,
  13026. $fault: "client",
  13027. $metadata: deserializeMetadata(output),
  13028. } as any;
  13029. }
  13030. const message = response.message || response.Message || errorCode;
  13031. response.message = message;
  13032. delete response.Message;
  13033. return Promise.reject(Object.assign(new Error(message), response));
  13034. };
  13035. export const deserializeAws_restJson1GetUsagePlansCommand = async (
  13036. output: __HttpResponse,
  13037. context: __SerdeContext
  13038. ): Promise<GetUsagePlansCommandOutput> => {
  13039. if (output.statusCode !== 200 && output.statusCode >= 400) {
  13040. return deserializeAws_restJson1GetUsagePlansCommandError(output, context);
  13041. }
  13042. const contents: GetUsagePlansCommandOutput = {
  13043. $metadata: deserializeMetadata(output),
  13044. items: undefined,
  13045. position: undefined,
  13046. };
  13047. const data: any = await parseBody(output.body, context);
  13048. if (data.item !== undefined && data.item !== null) {
  13049. contents.items = deserializeAws_restJson1ListOfUsagePlan(data.item, context);
  13050. }
  13051. if (data.position !== undefined && data.position !== null) {
  13052. contents.position = data.position;
  13053. }
  13054. return Promise.resolve(contents);
  13055. };
  13056. const deserializeAws_restJson1GetUsagePlansCommandError = async (
  13057. output: __HttpResponse,
  13058. context: __SerdeContext
  13059. ): Promise<GetUsagePlansCommandOutput> => {
  13060. const parsedOutput: any = {
  13061. ...output,
  13062. body: await parseBody(output.body, context),
  13063. };
  13064. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13065. let errorCode: string = "UnknownError";
  13066. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13067. switch (errorCode) {
  13068. case "BadRequestException":
  13069. case "com.amazonaws.apigateway#BadRequestException":
  13070. response = {
  13071. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13072. name: errorCode,
  13073. $metadata: deserializeMetadata(output),
  13074. };
  13075. break;
  13076. case "ConflictException":
  13077. case "com.amazonaws.apigateway#ConflictException":
  13078. response = {
  13079. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  13080. name: errorCode,
  13081. $metadata: deserializeMetadata(output),
  13082. };
  13083. break;
  13084. case "NotFoundException":
  13085. case "com.amazonaws.apigateway#NotFoundException":
  13086. response = {
  13087. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13088. name: errorCode,
  13089. $metadata: deserializeMetadata(output),
  13090. };
  13091. break;
  13092. case "TooManyRequestsException":
  13093. case "com.amazonaws.apigateway#TooManyRequestsException":
  13094. response = {
  13095. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13096. name: errorCode,
  13097. $metadata: deserializeMetadata(output),
  13098. };
  13099. break;
  13100. case "UnauthorizedException":
  13101. case "com.amazonaws.apigateway#UnauthorizedException":
  13102. response = {
  13103. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13104. name: errorCode,
  13105. $metadata: deserializeMetadata(output),
  13106. };
  13107. break;
  13108. default:
  13109. const parsedBody = parsedOutput.body;
  13110. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13111. response = {
  13112. ...parsedBody,
  13113. name: `${errorCode}`,
  13114. message: parsedBody.message || parsedBody.Message || errorCode,
  13115. $fault: "client",
  13116. $metadata: deserializeMetadata(output),
  13117. } as any;
  13118. }
  13119. const message = response.message || response.Message || errorCode;
  13120. response.message = message;
  13121. delete response.Message;
  13122. return Promise.reject(Object.assign(new Error(message), response));
  13123. };
  13124. export const deserializeAws_restJson1GetVpcLinkCommand = async (
  13125. output: __HttpResponse,
  13126. context: __SerdeContext
  13127. ): Promise<GetVpcLinkCommandOutput> => {
  13128. if (output.statusCode !== 200 && output.statusCode >= 400) {
  13129. return deserializeAws_restJson1GetVpcLinkCommandError(output, context);
  13130. }
  13131. const contents: GetVpcLinkCommandOutput = {
  13132. $metadata: deserializeMetadata(output),
  13133. description: undefined,
  13134. id: undefined,
  13135. name: undefined,
  13136. status: undefined,
  13137. statusMessage: undefined,
  13138. tags: undefined,
  13139. targetArns: undefined,
  13140. };
  13141. const data: any = await parseBody(output.body, context);
  13142. if (data.description !== undefined && data.description !== null) {
  13143. contents.description = data.description;
  13144. }
  13145. if (data.id !== undefined && data.id !== null) {
  13146. contents.id = data.id;
  13147. }
  13148. if (data.name !== undefined && data.name !== null) {
  13149. contents.name = data.name;
  13150. }
  13151. if (data.status !== undefined && data.status !== null) {
  13152. contents.status = data.status;
  13153. }
  13154. if (data.statusMessage !== undefined && data.statusMessage !== null) {
  13155. contents.statusMessage = data.statusMessage;
  13156. }
  13157. if (data.tags !== undefined && data.tags !== null) {
  13158. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  13159. }
  13160. if (data.targetArns !== undefined && data.targetArns !== null) {
  13161. contents.targetArns = deserializeAws_restJson1ListOfString(data.targetArns, context);
  13162. }
  13163. return Promise.resolve(contents);
  13164. };
  13165. const deserializeAws_restJson1GetVpcLinkCommandError = async (
  13166. output: __HttpResponse,
  13167. context: __SerdeContext
  13168. ): Promise<GetVpcLinkCommandOutput> => {
  13169. const parsedOutput: any = {
  13170. ...output,
  13171. body: await parseBody(output.body, context),
  13172. };
  13173. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13174. let errorCode: string = "UnknownError";
  13175. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13176. switch (errorCode) {
  13177. case "NotFoundException":
  13178. case "com.amazonaws.apigateway#NotFoundException":
  13179. response = {
  13180. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13181. name: errorCode,
  13182. $metadata: deserializeMetadata(output),
  13183. };
  13184. break;
  13185. case "TooManyRequestsException":
  13186. case "com.amazonaws.apigateway#TooManyRequestsException":
  13187. response = {
  13188. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13189. name: errorCode,
  13190. $metadata: deserializeMetadata(output),
  13191. };
  13192. break;
  13193. case "UnauthorizedException":
  13194. case "com.amazonaws.apigateway#UnauthorizedException":
  13195. response = {
  13196. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13197. name: errorCode,
  13198. $metadata: deserializeMetadata(output),
  13199. };
  13200. break;
  13201. default:
  13202. const parsedBody = parsedOutput.body;
  13203. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13204. response = {
  13205. ...parsedBody,
  13206. name: `${errorCode}`,
  13207. message: parsedBody.message || parsedBody.Message || errorCode,
  13208. $fault: "client",
  13209. $metadata: deserializeMetadata(output),
  13210. } as any;
  13211. }
  13212. const message = response.message || response.Message || errorCode;
  13213. response.message = message;
  13214. delete response.Message;
  13215. return Promise.reject(Object.assign(new Error(message), response));
  13216. };
  13217. export const deserializeAws_restJson1GetVpcLinksCommand = async (
  13218. output: __HttpResponse,
  13219. context: __SerdeContext
  13220. ): Promise<GetVpcLinksCommandOutput> => {
  13221. if (output.statusCode !== 200 && output.statusCode >= 400) {
  13222. return deserializeAws_restJson1GetVpcLinksCommandError(output, context);
  13223. }
  13224. const contents: GetVpcLinksCommandOutput = {
  13225. $metadata: deserializeMetadata(output),
  13226. items: undefined,
  13227. position: undefined,
  13228. };
  13229. const data: any = await parseBody(output.body, context);
  13230. if (data.item !== undefined && data.item !== null) {
  13231. contents.items = deserializeAws_restJson1ListOfVpcLink(data.item, context);
  13232. }
  13233. if (data.position !== undefined && data.position !== null) {
  13234. contents.position = data.position;
  13235. }
  13236. return Promise.resolve(contents);
  13237. };
  13238. const deserializeAws_restJson1GetVpcLinksCommandError = async (
  13239. output: __HttpResponse,
  13240. context: __SerdeContext
  13241. ): Promise<GetVpcLinksCommandOutput> => {
  13242. const parsedOutput: any = {
  13243. ...output,
  13244. body: await parseBody(output.body, context),
  13245. };
  13246. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13247. let errorCode: string = "UnknownError";
  13248. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13249. switch (errorCode) {
  13250. case "BadRequestException":
  13251. case "com.amazonaws.apigateway#BadRequestException":
  13252. response = {
  13253. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13254. name: errorCode,
  13255. $metadata: deserializeMetadata(output),
  13256. };
  13257. break;
  13258. case "TooManyRequestsException":
  13259. case "com.amazonaws.apigateway#TooManyRequestsException":
  13260. response = {
  13261. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13262. name: errorCode,
  13263. $metadata: deserializeMetadata(output),
  13264. };
  13265. break;
  13266. case "UnauthorizedException":
  13267. case "com.amazonaws.apigateway#UnauthorizedException":
  13268. response = {
  13269. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13270. name: errorCode,
  13271. $metadata: deserializeMetadata(output),
  13272. };
  13273. break;
  13274. default:
  13275. const parsedBody = parsedOutput.body;
  13276. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13277. response = {
  13278. ...parsedBody,
  13279. name: `${errorCode}`,
  13280. message: parsedBody.message || parsedBody.Message || errorCode,
  13281. $fault: "client",
  13282. $metadata: deserializeMetadata(output),
  13283. } as any;
  13284. }
  13285. const message = response.message || response.Message || errorCode;
  13286. response.message = message;
  13287. delete response.Message;
  13288. return Promise.reject(Object.assign(new Error(message), response));
  13289. };
  13290. export const deserializeAws_restJson1ImportApiKeysCommand = async (
  13291. output: __HttpResponse,
  13292. context: __SerdeContext
  13293. ): Promise<ImportApiKeysCommandOutput> => {
  13294. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13295. return deserializeAws_restJson1ImportApiKeysCommandError(output, context);
  13296. }
  13297. const contents: ImportApiKeysCommandOutput = {
  13298. $metadata: deserializeMetadata(output),
  13299. ids: undefined,
  13300. warnings: undefined,
  13301. };
  13302. const data: any = await parseBody(output.body, context);
  13303. if (data.ids !== undefined && data.ids !== null) {
  13304. contents.ids = deserializeAws_restJson1ListOfString(data.ids, context);
  13305. }
  13306. if (data.warnings !== undefined && data.warnings !== null) {
  13307. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  13308. }
  13309. return Promise.resolve(contents);
  13310. };
  13311. const deserializeAws_restJson1ImportApiKeysCommandError = async (
  13312. output: __HttpResponse,
  13313. context: __SerdeContext
  13314. ): Promise<ImportApiKeysCommandOutput> => {
  13315. const parsedOutput: any = {
  13316. ...output,
  13317. body: await parseBody(output.body, context),
  13318. };
  13319. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13320. let errorCode: string = "UnknownError";
  13321. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13322. switch (errorCode) {
  13323. case "BadRequestException":
  13324. case "com.amazonaws.apigateway#BadRequestException":
  13325. response = {
  13326. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13327. name: errorCode,
  13328. $metadata: deserializeMetadata(output),
  13329. };
  13330. break;
  13331. case "ConflictException":
  13332. case "com.amazonaws.apigateway#ConflictException":
  13333. response = {
  13334. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  13335. name: errorCode,
  13336. $metadata: deserializeMetadata(output),
  13337. };
  13338. break;
  13339. case "LimitExceededException":
  13340. case "com.amazonaws.apigateway#LimitExceededException":
  13341. response = {
  13342. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  13343. name: errorCode,
  13344. $metadata: deserializeMetadata(output),
  13345. };
  13346. break;
  13347. case "NotFoundException":
  13348. case "com.amazonaws.apigateway#NotFoundException":
  13349. response = {
  13350. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13351. name: errorCode,
  13352. $metadata: deserializeMetadata(output),
  13353. };
  13354. break;
  13355. case "TooManyRequestsException":
  13356. case "com.amazonaws.apigateway#TooManyRequestsException":
  13357. response = {
  13358. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13359. name: errorCode,
  13360. $metadata: deserializeMetadata(output),
  13361. };
  13362. break;
  13363. case "UnauthorizedException":
  13364. case "com.amazonaws.apigateway#UnauthorizedException":
  13365. response = {
  13366. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13367. name: errorCode,
  13368. $metadata: deserializeMetadata(output),
  13369. };
  13370. break;
  13371. default:
  13372. const parsedBody = parsedOutput.body;
  13373. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13374. response = {
  13375. ...parsedBody,
  13376. name: `${errorCode}`,
  13377. message: parsedBody.message || parsedBody.Message || errorCode,
  13378. $fault: "client",
  13379. $metadata: deserializeMetadata(output),
  13380. } as any;
  13381. }
  13382. const message = response.message || response.Message || errorCode;
  13383. response.message = message;
  13384. delete response.Message;
  13385. return Promise.reject(Object.assign(new Error(message), response));
  13386. };
  13387. export const deserializeAws_restJson1ImportDocumentationPartsCommand = async (
  13388. output: __HttpResponse,
  13389. context: __SerdeContext
  13390. ): Promise<ImportDocumentationPartsCommandOutput> => {
  13391. if (output.statusCode !== 200 && output.statusCode >= 400) {
  13392. return deserializeAws_restJson1ImportDocumentationPartsCommandError(output, context);
  13393. }
  13394. const contents: ImportDocumentationPartsCommandOutput = {
  13395. $metadata: deserializeMetadata(output),
  13396. ids: undefined,
  13397. warnings: undefined,
  13398. };
  13399. const data: any = await parseBody(output.body, context);
  13400. if (data.ids !== undefined && data.ids !== null) {
  13401. contents.ids = deserializeAws_restJson1ListOfString(data.ids, context);
  13402. }
  13403. if (data.warnings !== undefined && data.warnings !== null) {
  13404. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  13405. }
  13406. return Promise.resolve(contents);
  13407. };
  13408. const deserializeAws_restJson1ImportDocumentationPartsCommandError = async (
  13409. output: __HttpResponse,
  13410. context: __SerdeContext
  13411. ): Promise<ImportDocumentationPartsCommandOutput> => {
  13412. const parsedOutput: any = {
  13413. ...output,
  13414. body: await parseBody(output.body, context),
  13415. };
  13416. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13417. let errorCode: string = "UnknownError";
  13418. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13419. switch (errorCode) {
  13420. case "BadRequestException":
  13421. case "com.amazonaws.apigateway#BadRequestException":
  13422. response = {
  13423. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13424. name: errorCode,
  13425. $metadata: deserializeMetadata(output),
  13426. };
  13427. break;
  13428. case "LimitExceededException":
  13429. case "com.amazonaws.apigateway#LimitExceededException":
  13430. response = {
  13431. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  13432. name: errorCode,
  13433. $metadata: deserializeMetadata(output),
  13434. };
  13435. break;
  13436. case "NotFoundException":
  13437. case "com.amazonaws.apigateway#NotFoundException":
  13438. response = {
  13439. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13440. name: errorCode,
  13441. $metadata: deserializeMetadata(output),
  13442. };
  13443. break;
  13444. case "TooManyRequestsException":
  13445. case "com.amazonaws.apigateway#TooManyRequestsException":
  13446. response = {
  13447. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13448. name: errorCode,
  13449. $metadata: deserializeMetadata(output),
  13450. };
  13451. break;
  13452. case "UnauthorizedException":
  13453. case "com.amazonaws.apigateway#UnauthorizedException":
  13454. response = {
  13455. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13456. name: errorCode,
  13457. $metadata: deserializeMetadata(output),
  13458. };
  13459. break;
  13460. default:
  13461. const parsedBody = parsedOutput.body;
  13462. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13463. response = {
  13464. ...parsedBody,
  13465. name: `${errorCode}`,
  13466. message: parsedBody.message || parsedBody.Message || errorCode,
  13467. $fault: "client",
  13468. $metadata: deserializeMetadata(output),
  13469. } as any;
  13470. }
  13471. const message = response.message || response.Message || errorCode;
  13472. response.message = message;
  13473. delete response.Message;
  13474. return Promise.reject(Object.assign(new Error(message), response));
  13475. };
  13476. export const deserializeAws_restJson1ImportRestApiCommand = async (
  13477. output: __HttpResponse,
  13478. context: __SerdeContext
  13479. ): Promise<ImportRestApiCommandOutput> => {
  13480. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13481. return deserializeAws_restJson1ImportRestApiCommandError(output, context);
  13482. }
  13483. const contents: ImportRestApiCommandOutput = {
  13484. $metadata: deserializeMetadata(output),
  13485. apiKeySource: undefined,
  13486. binaryMediaTypes: undefined,
  13487. createdDate: undefined,
  13488. description: undefined,
  13489. endpointConfiguration: undefined,
  13490. id: undefined,
  13491. minimumCompressionSize: undefined,
  13492. name: undefined,
  13493. policy: undefined,
  13494. tags: undefined,
  13495. version: undefined,
  13496. warnings: undefined,
  13497. };
  13498. const data: any = await parseBody(output.body, context);
  13499. if (data.apiKeySource !== undefined && data.apiKeySource !== null) {
  13500. contents.apiKeySource = data.apiKeySource;
  13501. }
  13502. if (data.binaryMediaTypes !== undefined && data.binaryMediaTypes !== null) {
  13503. contents.binaryMediaTypes = deserializeAws_restJson1ListOfString(data.binaryMediaTypes, context);
  13504. }
  13505. if (data.createdDate !== undefined && data.createdDate !== null) {
  13506. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  13507. }
  13508. if (data.description !== undefined && data.description !== null) {
  13509. contents.description = data.description;
  13510. }
  13511. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  13512. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  13513. }
  13514. if (data.id !== undefined && data.id !== null) {
  13515. contents.id = data.id;
  13516. }
  13517. if (data.minimumCompressionSize !== undefined && data.minimumCompressionSize !== null) {
  13518. contents.minimumCompressionSize = data.minimumCompressionSize;
  13519. }
  13520. if (data.name !== undefined && data.name !== null) {
  13521. contents.name = data.name;
  13522. }
  13523. if (data.policy !== undefined && data.policy !== null) {
  13524. contents.policy = data.policy;
  13525. }
  13526. if (data.tags !== undefined && data.tags !== null) {
  13527. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  13528. }
  13529. if (data.version !== undefined && data.version !== null) {
  13530. contents.version = data.version;
  13531. }
  13532. if (data.warnings !== undefined && data.warnings !== null) {
  13533. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  13534. }
  13535. return Promise.resolve(contents);
  13536. };
  13537. const deserializeAws_restJson1ImportRestApiCommandError = async (
  13538. output: __HttpResponse,
  13539. context: __SerdeContext
  13540. ): Promise<ImportRestApiCommandOutput> => {
  13541. const parsedOutput: any = {
  13542. ...output,
  13543. body: await parseBody(output.body, context),
  13544. };
  13545. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13546. let errorCode: string = "UnknownError";
  13547. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13548. switch (errorCode) {
  13549. case "BadRequestException":
  13550. case "com.amazonaws.apigateway#BadRequestException":
  13551. response = {
  13552. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13553. name: errorCode,
  13554. $metadata: deserializeMetadata(output),
  13555. };
  13556. break;
  13557. case "ConflictException":
  13558. case "com.amazonaws.apigateway#ConflictException":
  13559. response = {
  13560. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  13561. name: errorCode,
  13562. $metadata: deserializeMetadata(output),
  13563. };
  13564. break;
  13565. case "LimitExceededException":
  13566. case "com.amazonaws.apigateway#LimitExceededException":
  13567. response = {
  13568. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  13569. name: errorCode,
  13570. $metadata: deserializeMetadata(output),
  13571. };
  13572. break;
  13573. case "TooManyRequestsException":
  13574. case "com.amazonaws.apigateway#TooManyRequestsException":
  13575. response = {
  13576. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13577. name: errorCode,
  13578. $metadata: deserializeMetadata(output),
  13579. };
  13580. break;
  13581. case "UnauthorizedException":
  13582. case "com.amazonaws.apigateway#UnauthorizedException":
  13583. response = {
  13584. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13585. name: errorCode,
  13586. $metadata: deserializeMetadata(output),
  13587. };
  13588. break;
  13589. default:
  13590. const parsedBody = parsedOutput.body;
  13591. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13592. response = {
  13593. ...parsedBody,
  13594. name: `${errorCode}`,
  13595. message: parsedBody.message || parsedBody.Message || errorCode,
  13596. $fault: "client",
  13597. $metadata: deserializeMetadata(output),
  13598. } as any;
  13599. }
  13600. const message = response.message || response.Message || errorCode;
  13601. response.message = message;
  13602. delete response.Message;
  13603. return Promise.reject(Object.assign(new Error(message), response));
  13604. };
  13605. export const deserializeAws_restJson1PutGatewayResponseCommand = async (
  13606. output: __HttpResponse,
  13607. context: __SerdeContext
  13608. ): Promise<PutGatewayResponseCommandOutput> => {
  13609. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13610. return deserializeAws_restJson1PutGatewayResponseCommandError(output, context);
  13611. }
  13612. const contents: PutGatewayResponseCommandOutput = {
  13613. $metadata: deserializeMetadata(output),
  13614. defaultResponse: undefined,
  13615. responseParameters: undefined,
  13616. responseTemplates: undefined,
  13617. responseType: undefined,
  13618. statusCode: undefined,
  13619. };
  13620. const data: any = await parseBody(output.body, context);
  13621. if (data.defaultResponse !== undefined && data.defaultResponse !== null) {
  13622. contents.defaultResponse = data.defaultResponse;
  13623. }
  13624. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  13625. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  13626. }
  13627. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  13628. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  13629. }
  13630. if (data.responseType !== undefined && data.responseType !== null) {
  13631. contents.responseType = data.responseType;
  13632. }
  13633. if (data.statusCode !== undefined && data.statusCode !== null) {
  13634. contents.statusCode = data.statusCode;
  13635. }
  13636. return Promise.resolve(contents);
  13637. };
  13638. const deserializeAws_restJson1PutGatewayResponseCommandError = async (
  13639. output: __HttpResponse,
  13640. context: __SerdeContext
  13641. ): Promise<PutGatewayResponseCommandOutput> => {
  13642. const parsedOutput: any = {
  13643. ...output,
  13644. body: await parseBody(output.body, context),
  13645. };
  13646. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13647. let errorCode: string = "UnknownError";
  13648. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13649. switch (errorCode) {
  13650. case "BadRequestException":
  13651. case "com.amazonaws.apigateway#BadRequestException":
  13652. response = {
  13653. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13654. name: errorCode,
  13655. $metadata: deserializeMetadata(output),
  13656. };
  13657. break;
  13658. case "LimitExceededException":
  13659. case "com.amazonaws.apigateway#LimitExceededException":
  13660. response = {
  13661. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  13662. name: errorCode,
  13663. $metadata: deserializeMetadata(output),
  13664. };
  13665. break;
  13666. case "NotFoundException":
  13667. case "com.amazonaws.apigateway#NotFoundException":
  13668. response = {
  13669. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13670. name: errorCode,
  13671. $metadata: deserializeMetadata(output),
  13672. };
  13673. break;
  13674. case "TooManyRequestsException":
  13675. case "com.amazonaws.apigateway#TooManyRequestsException":
  13676. response = {
  13677. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13678. name: errorCode,
  13679. $metadata: deserializeMetadata(output),
  13680. };
  13681. break;
  13682. case "UnauthorizedException":
  13683. case "com.amazonaws.apigateway#UnauthorizedException":
  13684. response = {
  13685. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13686. name: errorCode,
  13687. $metadata: deserializeMetadata(output),
  13688. };
  13689. break;
  13690. default:
  13691. const parsedBody = parsedOutput.body;
  13692. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13693. response = {
  13694. ...parsedBody,
  13695. name: `${errorCode}`,
  13696. message: parsedBody.message || parsedBody.Message || errorCode,
  13697. $fault: "client",
  13698. $metadata: deserializeMetadata(output),
  13699. } as any;
  13700. }
  13701. const message = response.message || response.Message || errorCode;
  13702. response.message = message;
  13703. delete response.Message;
  13704. return Promise.reject(Object.assign(new Error(message), response));
  13705. };
  13706. export const deserializeAws_restJson1PutIntegrationCommand = async (
  13707. output: __HttpResponse,
  13708. context: __SerdeContext
  13709. ): Promise<PutIntegrationCommandOutput> => {
  13710. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13711. return deserializeAws_restJson1PutIntegrationCommandError(output, context);
  13712. }
  13713. const contents: PutIntegrationCommandOutput = {
  13714. $metadata: deserializeMetadata(output),
  13715. cacheKeyParameters: undefined,
  13716. cacheNamespace: undefined,
  13717. connectionId: undefined,
  13718. connectionType: undefined,
  13719. contentHandling: undefined,
  13720. credentials: undefined,
  13721. httpMethod: undefined,
  13722. integrationResponses: undefined,
  13723. passthroughBehavior: undefined,
  13724. requestParameters: undefined,
  13725. requestTemplates: undefined,
  13726. timeoutInMillis: undefined,
  13727. tlsConfig: undefined,
  13728. type: undefined,
  13729. uri: undefined,
  13730. };
  13731. const data: any = await parseBody(output.body, context);
  13732. if (data.cacheKeyParameters !== undefined && data.cacheKeyParameters !== null) {
  13733. contents.cacheKeyParameters = deserializeAws_restJson1ListOfString(data.cacheKeyParameters, context);
  13734. }
  13735. if (data.cacheNamespace !== undefined && data.cacheNamespace !== null) {
  13736. contents.cacheNamespace = data.cacheNamespace;
  13737. }
  13738. if (data.connectionId !== undefined && data.connectionId !== null) {
  13739. contents.connectionId = data.connectionId;
  13740. }
  13741. if (data.connectionType !== undefined && data.connectionType !== null) {
  13742. contents.connectionType = data.connectionType;
  13743. }
  13744. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  13745. contents.contentHandling = data.contentHandling;
  13746. }
  13747. if (data.credentials !== undefined && data.credentials !== null) {
  13748. contents.credentials = data.credentials;
  13749. }
  13750. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  13751. contents.httpMethod = data.httpMethod;
  13752. }
  13753. if (data.integrationResponses !== undefined && data.integrationResponses !== null) {
  13754. contents.integrationResponses = deserializeAws_restJson1MapOfIntegrationResponse(
  13755. data.integrationResponses,
  13756. context
  13757. );
  13758. }
  13759. if (data.passthroughBehavior !== undefined && data.passthroughBehavior !== null) {
  13760. contents.passthroughBehavior = data.passthroughBehavior;
  13761. }
  13762. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  13763. contents.requestParameters = deserializeAws_restJson1MapOfStringToString(data.requestParameters, context);
  13764. }
  13765. if (data.requestTemplates !== undefined && data.requestTemplates !== null) {
  13766. contents.requestTemplates = deserializeAws_restJson1MapOfStringToString(data.requestTemplates, context);
  13767. }
  13768. if (data.timeoutInMillis !== undefined && data.timeoutInMillis !== null) {
  13769. contents.timeoutInMillis = data.timeoutInMillis;
  13770. }
  13771. if (data.tlsConfig !== undefined && data.tlsConfig !== null) {
  13772. contents.tlsConfig = deserializeAws_restJson1TlsConfig(data.tlsConfig, context);
  13773. }
  13774. if (data.type !== undefined && data.type !== null) {
  13775. contents.type = data.type;
  13776. }
  13777. if (data.uri !== undefined && data.uri !== null) {
  13778. contents.uri = data.uri;
  13779. }
  13780. return Promise.resolve(contents);
  13781. };
  13782. const deserializeAws_restJson1PutIntegrationCommandError = async (
  13783. output: __HttpResponse,
  13784. context: __SerdeContext
  13785. ): Promise<PutIntegrationCommandOutput> => {
  13786. const parsedOutput: any = {
  13787. ...output,
  13788. body: await parseBody(output.body, context),
  13789. };
  13790. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13791. let errorCode: string = "UnknownError";
  13792. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13793. switch (errorCode) {
  13794. case "BadRequestException":
  13795. case "com.amazonaws.apigateway#BadRequestException":
  13796. response = {
  13797. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13798. name: errorCode,
  13799. $metadata: deserializeMetadata(output),
  13800. };
  13801. break;
  13802. case "ConflictException":
  13803. case "com.amazonaws.apigateway#ConflictException":
  13804. response = {
  13805. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  13806. name: errorCode,
  13807. $metadata: deserializeMetadata(output),
  13808. };
  13809. break;
  13810. case "NotFoundException":
  13811. case "com.amazonaws.apigateway#NotFoundException":
  13812. response = {
  13813. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13814. name: errorCode,
  13815. $metadata: deserializeMetadata(output),
  13816. };
  13817. break;
  13818. case "TooManyRequestsException":
  13819. case "com.amazonaws.apigateway#TooManyRequestsException":
  13820. response = {
  13821. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13822. name: errorCode,
  13823. $metadata: deserializeMetadata(output),
  13824. };
  13825. break;
  13826. case "UnauthorizedException":
  13827. case "com.amazonaws.apigateway#UnauthorizedException":
  13828. response = {
  13829. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13830. name: errorCode,
  13831. $metadata: deserializeMetadata(output),
  13832. };
  13833. break;
  13834. default:
  13835. const parsedBody = parsedOutput.body;
  13836. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13837. response = {
  13838. ...parsedBody,
  13839. name: `${errorCode}`,
  13840. message: parsedBody.message || parsedBody.Message || errorCode,
  13841. $fault: "client",
  13842. $metadata: deserializeMetadata(output),
  13843. } as any;
  13844. }
  13845. const message = response.message || response.Message || errorCode;
  13846. response.message = message;
  13847. delete response.Message;
  13848. return Promise.reject(Object.assign(new Error(message), response));
  13849. };
  13850. export const deserializeAws_restJson1PutIntegrationResponseCommand = async (
  13851. output: __HttpResponse,
  13852. context: __SerdeContext
  13853. ): Promise<PutIntegrationResponseCommandOutput> => {
  13854. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13855. return deserializeAws_restJson1PutIntegrationResponseCommandError(output, context);
  13856. }
  13857. const contents: PutIntegrationResponseCommandOutput = {
  13858. $metadata: deserializeMetadata(output),
  13859. contentHandling: undefined,
  13860. responseParameters: undefined,
  13861. responseTemplates: undefined,
  13862. selectionPattern: undefined,
  13863. statusCode: undefined,
  13864. };
  13865. const data: any = await parseBody(output.body, context);
  13866. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  13867. contents.contentHandling = data.contentHandling;
  13868. }
  13869. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  13870. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  13871. }
  13872. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  13873. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  13874. }
  13875. if (data.selectionPattern !== undefined && data.selectionPattern !== null) {
  13876. contents.selectionPattern = data.selectionPattern;
  13877. }
  13878. if (data.statusCode !== undefined && data.statusCode !== null) {
  13879. contents.statusCode = data.statusCode;
  13880. }
  13881. return Promise.resolve(contents);
  13882. };
  13883. const deserializeAws_restJson1PutIntegrationResponseCommandError = async (
  13884. output: __HttpResponse,
  13885. context: __SerdeContext
  13886. ): Promise<PutIntegrationResponseCommandOutput> => {
  13887. const parsedOutput: any = {
  13888. ...output,
  13889. body: await parseBody(output.body, context),
  13890. };
  13891. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  13892. let errorCode: string = "UnknownError";
  13893. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  13894. switch (errorCode) {
  13895. case "BadRequestException":
  13896. case "com.amazonaws.apigateway#BadRequestException":
  13897. response = {
  13898. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  13899. name: errorCode,
  13900. $metadata: deserializeMetadata(output),
  13901. };
  13902. break;
  13903. case "ConflictException":
  13904. case "com.amazonaws.apigateway#ConflictException":
  13905. response = {
  13906. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  13907. name: errorCode,
  13908. $metadata: deserializeMetadata(output),
  13909. };
  13910. break;
  13911. case "LimitExceededException":
  13912. case "com.amazonaws.apigateway#LimitExceededException":
  13913. response = {
  13914. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  13915. name: errorCode,
  13916. $metadata: deserializeMetadata(output),
  13917. };
  13918. break;
  13919. case "NotFoundException":
  13920. case "com.amazonaws.apigateway#NotFoundException":
  13921. response = {
  13922. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  13923. name: errorCode,
  13924. $metadata: deserializeMetadata(output),
  13925. };
  13926. break;
  13927. case "TooManyRequestsException":
  13928. case "com.amazonaws.apigateway#TooManyRequestsException":
  13929. response = {
  13930. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  13931. name: errorCode,
  13932. $metadata: deserializeMetadata(output),
  13933. };
  13934. break;
  13935. case "UnauthorizedException":
  13936. case "com.amazonaws.apigateway#UnauthorizedException":
  13937. response = {
  13938. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  13939. name: errorCode,
  13940. $metadata: deserializeMetadata(output),
  13941. };
  13942. break;
  13943. default:
  13944. const parsedBody = parsedOutput.body;
  13945. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  13946. response = {
  13947. ...parsedBody,
  13948. name: `${errorCode}`,
  13949. message: parsedBody.message || parsedBody.Message || errorCode,
  13950. $fault: "client",
  13951. $metadata: deserializeMetadata(output),
  13952. } as any;
  13953. }
  13954. const message = response.message || response.Message || errorCode;
  13955. response.message = message;
  13956. delete response.Message;
  13957. return Promise.reject(Object.assign(new Error(message), response));
  13958. };
  13959. export const deserializeAws_restJson1PutMethodCommand = async (
  13960. output: __HttpResponse,
  13961. context: __SerdeContext
  13962. ): Promise<PutMethodCommandOutput> => {
  13963. if (output.statusCode !== 201 && output.statusCode >= 400) {
  13964. return deserializeAws_restJson1PutMethodCommandError(output, context);
  13965. }
  13966. const contents: PutMethodCommandOutput = {
  13967. $metadata: deserializeMetadata(output),
  13968. apiKeyRequired: undefined,
  13969. authorizationScopes: undefined,
  13970. authorizationType: undefined,
  13971. authorizerId: undefined,
  13972. httpMethod: undefined,
  13973. methodIntegration: undefined,
  13974. methodResponses: undefined,
  13975. operationName: undefined,
  13976. requestModels: undefined,
  13977. requestParameters: undefined,
  13978. requestValidatorId: undefined,
  13979. };
  13980. const data: any = await parseBody(output.body, context);
  13981. if (data.apiKeyRequired !== undefined && data.apiKeyRequired !== null) {
  13982. contents.apiKeyRequired = data.apiKeyRequired;
  13983. }
  13984. if (data.authorizationScopes !== undefined && data.authorizationScopes !== null) {
  13985. contents.authorizationScopes = deserializeAws_restJson1ListOfString(data.authorizationScopes, context);
  13986. }
  13987. if (data.authorizationType !== undefined && data.authorizationType !== null) {
  13988. contents.authorizationType = data.authorizationType;
  13989. }
  13990. if (data.authorizerId !== undefined && data.authorizerId !== null) {
  13991. contents.authorizerId = data.authorizerId;
  13992. }
  13993. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  13994. contents.httpMethod = data.httpMethod;
  13995. }
  13996. if (data.methodIntegration !== undefined && data.methodIntegration !== null) {
  13997. contents.methodIntegration = deserializeAws_restJson1Integration(data.methodIntegration, context);
  13998. }
  13999. if (data.methodResponses !== undefined && data.methodResponses !== null) {
  14000. contents.methodResponses = deserializeAws_restJson1MapOfMethodResponse(data.methodResponses, context);
  14001. }
  14002. if (data.operationName !== undefined && data.operationName !== null) {
  14003. contents.operationName = data.operationName;
  14004. }
  14005. if (data.requestModels !== undefined && data.requestModels !== null) {
  14006. contents.requestModels = deserializeAws_restJson1MapOfStringToString(data.requestModels, context);
  14007. }
  14008. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  14009. contents.requestParameters = deserializeAws_restJson1MapOfStringToBoolean(data.requestParameters, context);
  14010. }
  14011. if (data.requestValidatorId !== undefined && data.requestValidatorId !== null) {
  14012. contents.requestValidatorId = data.requestValidatorId;
  14013. }
  14014. return Promise.resolve(contents);
  14015. };
  14016. const deserializeAws_restJson1PutMethodCommandError = async (
  14017. output: __HttpResponse,
  14018. context: __SerdeContext
  14019. ): Promise<PutMethodCommandOutput> => {
  14020. const parsedOutput: any = {
  14021. ...output,
  14022. body: await parseBody(output.body, context),
  14023. };
  14024. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14025. let errorCode: string = "UnknownError";
  14026. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14027. switch (errorCode) {
  14028. case "BadRequestException":
  14029. case "com.amazonaws.apigateway#BadRequestException":
  14030. response = {
  14031. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14032. name: errorCode,
  14033. $metadata: deserializeMetadata(output),
  14034. };
  14035. break;
  14036. case "ConflictException":
  14037. case "com.amazonaws.apigateway#ConflictException":
  14038. response = {
  14039. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14040. name: errorCode,
  14041. $metadata: deserializeMetadata(output),
  14042. };
  14043. break;
  14044. case "LimitExceededException":
  14045. case "com.amazonaws.apigateway#LimitExceededException":
  14046. response = {
  14047. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  14048. name: errorCode,
  14049. $metadata: deserializeMetadata(output),
  14050. };
  14051. break;
  14052. case "NotFoundException":
  14053. case "com.amazonaws.apigateway#NotFoundException":
  14054. response = {
  14055. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14056. name: errorCode,
  14057. $metadata: deserializeMetadata(output),
  14058. };
  14059. break;
  14060. case "TooManyRequestsException":
  14061. case "com.amazonaws.apigateway#TooManyRequestsException":
  14062. response = {
  14063. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14064. name: errorCode,
  14065. $metadata: deserializeMetadata(output),
  14066. };
  14067. break;
  14068. case "UnauthorizedException":
  14069. case "com.amazonaws.apigateway#UnauthorizedException":
  14070. response = {
  14071. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14072. name: errorCode,
  14073. $metadata: deserializeMetadata(output),
  14074. };
  14075. break;
  14076. default:
  14077. const parsedBody = parsedOutput.body;
  14078. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14079. response = {
  14080. ...parsedBody,
  14081. name: `${errorCode}`,
  14082. message: parsedBody.message || parsedBody.Message || errorCode,
  14083. $fault: "client",
  14084. $metadata: deserializeMetadata(output),
  14085. } as any;
  14086. }
  14087. const message = response.message || response.Message || errorCode;
  14088. response.message = message;
  14089. delete response.Message;
  14090. return Promise.reject(Object.assign(new Error(message), response));
  14091. };
  14092. export const deserializeAws_restJson1PutMethodResponseCommand = async (
  14093. output: __HttpResponse,
  14094. context: __SerdeContext
  14095. ): Promise<PutMethodResponseCommandOutput> => {
  14096. if (output.statusCode !== 201 && output.statusCode >= 400) {
  14097. return deserializeAws_restJson1PutMethodResponseCommandError(output, context);
  14098. }
  14099. const contents: PutMethodResponseCommandOutput = {
  14100. $metadata: deserializeMetadata(output),
  14101. responseModels: undefined,
  14102. responseParameters: undefined,
  14103. statusCode: undefined,
  14104. };
  14105. const data: any = await parseBody(output.body, context);
  14106. if (data.responseModels !== undefined && data.responseModels !== null) {
  14107. contents.responseModels = deserializeAws_restJson1MapOfStringToString(data.responseModels, context);
  14108. }
  14109. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  14110. contents.responseParameters = deserializeAws_restJson1MapOfStringToBoolean(data.responseParameters, context);
  14111. }
  14112. if (data.statusCode !== undefined && data.statusCode !== null) {
  14113. contents.statusCode = data.statusCode;
  14114. }
  14115. return Promise.resolve(contents);
  14116. };
  14117. const deserializeAws_restJson1PutMethodResponseCommandError = async (
  14118. output: __HttpResponse,
  14119. context: __SerdeContext
  14120. ): Promise<PutMethodResponseCommandOutput> => {
  14121. const parsedOutput: any = {
  14122. ...output,
  14123. body: await parseBody(output.body, context),
  14124. };
  14125. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14126. let errorCode: string = "UnknownError";
  14127. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14128. switch (errorCode) {
  14129. case "BadRequestException":
  14130. case "com.amazonaws.apigateway#BadRequestException":
  14131. response = {
  14132. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14133. name: errorCode,
  14134. $metadata: deserializeMetadata(output),
  14135. };
  14136. break;
  14137. case "ConflictException":
  14138. case "com.amazonaws.apigateway#ConflictException":
  14139. response = {
  14140. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14141. name: errorCode,
  14142. $metadata: deserializeMetadata(output),
  14143. };
  14144. break;
  14145. case "LimitExceededException":
  14146. case "com.amazonaws.apigateway#LimitExceededException":
  14147. response = {
  14148. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  14149. name: errorCode,
  14150. $metadata: deserializeMetadata(output),
  14151. };
  14152. break;
  14153. case "NotFoundException":
  14154. case "com.amazonaws.apigateway#NotFoundException":
  14155. response = {
  14156. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14157. name: errorCode,
  14158. $metadata: deserializeMetadata(output),
  14159. };
  14160. break;
  14161. case "TooManyRequestsException":
  14162. case "com.amazonaws.apigateway#TooManyRequestsException":
  14163. response = {
  14164. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14165. name: errorCode,
  14166. $metadata: deserializeMetadata(output),
  14167. };
  14168. break;
  14169. case "UnauthorizedException":
  14170. case "com.amazonaws.apigateway#UnauthorizedException":
  14171. response = {
  14172. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14173. name: errorCode,
  14174. $metadata: deserializeMetadata(output),
  14175. };
  14176. break;
  14177. default:
  14178. const parsedBody = parsedOutput.body;
  14179. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14180. response = {
  14181. ...parsedBody,
  14182. name: `${errorCode}`,
  14183. message: parsedBody.message || parsedBody.Message || errorCode,
  14184. $fault: "client",
  14185. $metadata: deserializeMetadata(output),
  14186. } as any;
  14187. }
  14188. const message = response.message || response.Message || errorCode;
  14189. response.message = message;
  14190. delete response.Message;
  14191. return Promise.reject(Object.assign(new Error(message), response));
  14192. };
  14193. export const deserializeAws_restJson1PutRestApiCommand = async (
  14194. output: __HttpResponse,
  14195. context: __SerdeContext
  14196. ): Promise<PutRestApiCommandOutput> => {
  14197. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14198. return deserializeAws_restJson1PutRestApiCommandError(output, context);
  14199. }
  14200. const contents: PutRestApiCommandOutput = {
  14201. $metadata: deserializeMetadata(output),
  14202. apiKeySource: undefined,
  14203. binaryMediaTypes: undefined,
  14204. createdDate: undefined,
  14205. description: undefined,
  14206. endpointConfiguration: undefined,
  14207. id: undefined,
  14208. minimumCompressionSize: undefined,
  14209. name: undefined,
  14210. policy: undefined,
  14211. tags: undefined,
  14212. version: undefined,
  14213. warnings: undefined,
  14214. };
  14215. const data: any = await parseBody(output.body, context);
  14216. if (data.apiKeySource !== undefined && data.apiKeySource !== null) {
  14217. contents.apiKeySource = data.apiKeySource;
  14218. }
  14219. if (data.binaryMediaTypes !== undefined && data.binaryMediaTypes !== null) {
  14220. contents.binaryMediaTypes = deserializeAws_restJson1ListOfString(data.binaryMediaTypes, context);
  14221. }
  14222. if (data.createdDate !== undefined && data.createdDate !== null) {
  14223. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  14224. }
  14225. if (data.description !== undefined && data.description !== null) {
  14226. contents.description = data.description;
  14227. }
  14228. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  14229. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  14230. }
  14231. if (data.id !== undefined && data.id !== null) {
  14232. contents.id = data.id;
  14233. }
  14234. if (data.minimumCompressionSize !== undefined && data.minimumCompressionSize !== null) {
  14235. contents.minimumCompressionSize = data.minimumCompressionSize;
  14236. }
  14237. if (data.name !== undefined && data.name !== null) {
  14238. contents.name = data.name;
  14239. }
  14240. if (data.policy !== undefined && data.policy !== null) {
  14241. contents.policy = data.policy;
  14242. }
  14243. if (data.tags !== undefined && data.tags !== null) {
  14244. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  14245. }
  14246. if (data.version !== undefined && data.version !== null) {
  14247. contents.version = data.version;
  14248. }
  14249. if (data.warnings !== undefined && data.warnings !== null) {
  14250. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  14251. }
  14252. return Promise.resolve(contents);
  14253. };
  14254. const deserializeAws_restJson1PutRestApiCommandError = async (
  14255. output: __HttpResponse,
  14256. context: __SerdeContext
  14257. ): Promise<PutRestApiCommandOutput> => {
  14258. const parsedOutput: any = {
  14259. ...output,
  14260. body: await parseBody(output.body, context),
  14261. };
  14262. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14263. let errorCode: string = "UnknownError";
  14264. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14265. switch (errorCode) {
  14266. case "BadRequestException":
  14267. case "com.amazonaws.apigateway#BadRequestException":
  14268. response = {
  14269. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14270. name: errorCode,
  14271. $metadata: deserializeMetadata(output),
  14272. };
  14273. break;
  14274. case "ConflictException":
  14275. case "com.amazonaws.apigateway#ConflictException":
  14276. response = {
  14277. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14278. name: errorCode,
  14279. $metadata: deserializeMetadata(output),
  14280. };
  14281. break;
  14282. case "LimitExceededException":
  14283. case "com.amazonaws.apigateway#LimitExceededException":
  14284. response = {
  14285. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  14286. name: errorCode,
  14287. $metadata: deserializeMetadata(output),
  14288. };
  14289. break;
  14290. case "NotFoundException":
  14291. case "com.amazonaws.apigateway#NotFoundException":
  14292. response = {
  14293. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14294. name: errorCode,
  14295. $metadata: deserializeMetadata(output),
  14296. };
  14297. break;
  14298. case "TooManyRequestsException":
  14299. case "com.amazonaws.apigateway#TooManyRequestsException":
  14300. response = {
  14301. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14302. name: errorCode,
  14303. $metadata: deserializeMetadata(output),
  14304. };
  14305. break;
  14306. case "UnauthorizedException":
  14307. case "com.amazonaws.apigateway#UnauthorizedException":
  14308. response = {
  14309. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14310. name: errorCode,
  14311. $metadata: deserializeMetadata(output),
  14312. };
  14313. break;
  14314. default:
  14315. const parsedBody = parsedOutput.body;
  14316. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14317. response = {
  14318. ...parsedBody,
  14319. name: `${errorCode}`,
  14320. message: parsedBody.message || parsedBody.Message || errorCode,
  14321. $fault: "client",
  14322. $metadata: deserializeMetadata(output),
  14323. } as any;
  14324. }
  14325. const message = response.message || response.Message || errorCode;
  14326. response.message = message;
  14327. delete response.Message;
  14328. return Promise.reject(Object.assign(new Error(message), response));
  14329. };
  14330. export const deserializeAws_restJson1TagResourceCommand = async (
  14331. output: __HttpResponse,
  14332. context: __SerdeContext
  14333. ): Promise<TagResourceCommandOutput> => {
  14334. if (output.statusCode !== 204 && output.statusCode >= 400) {
  14335. return deserializeAws_restJson1TagResourceCommandError(output, context);
  14336. }
  14337. const contents: TagResourceCommandOutput = {
  14338. $metadata: deserializeMetadata(output),
  14339. };
  14340. await collectBody(output.body, context);
  14341. return Promise.resolve(contents);
  14342. };
  14343. const deserializeAws_restJson1TagResourceCommandError = async (
  14344. output: __HttpResponse,
  14345. context: __SerdeContext
  14346. ): Promise<TagResourceCommandOutput> => {
  14347. const parsedOutput: any = {
  14348. ...output,
  14349. body: await parseBody(output.body, context),
  14350. };
  14351. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14352. let errorCode: string = "UnknownError";
  14353. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14354. switch (errorCode) {
  14355. case "BadRequestException":
  14356. case "com.amazonaws.apigateway#BadRequestException":
  14357. response = {
  14358. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14359. name: errorCode,
  14360. $metadata: deserializeMetadata(output),
  14361. };
  14362. break;
  14363. case "ConflictException":
  14364. case "com.amazonaws.apigateway#ConflictException":
  14365. response = {
  14366. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14367. name: errorCode,
  14368. $metadata: deserializeMetadata(output),
  14369. };
  14370. break;
  14371. case "LimitExceededException":
  14372. case "com.amazonaws.apigateway#LimitExceededException":
  14373. response = {
  14374. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  14375. name: errorCode,
  14376. $metadata: deserializeMetadata(output),
  14377. };
  14378. break;
  14379. case "NotFoundException":
  14380. case "com.amazonaws.apigateway#NotFoundException":
  14381. response = {
  14382. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14383. name: errorCode,
  14384. $metadata: deserializeMetadata(output),
  14385. };
  14386. break;
  14387. case "TooManyRequestsException":
  14388. case "com.amazonaws.apigateway#TooManyRequestsException":
  14389. response = {
  14390. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14391. name: errorCode,
  14392. $metadata: deserializeMetadata(output),
  14393. };
  14394. break;
  14395. case "UnauthorizedException":
  14396. case "com.amazonaws.apigateway#UnauthorizedException":
  14397. response = {
  14398. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14399. name: errorCode,
  14400. $metadata: deserializeMetadata(output),
  14401. };
  14402. break;
  14403. default:
  14404. const parsedBody = parsedOutput.body;
  14405. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14406. response = {
  14407. ...parsedBody,
  14408. name: `${errorCode}`,
  14409. message: parsedBody.message || parsedBody.Message || errorCode,
  14410. $fault: "client",
  14411. $metadata: deserializeMetadata(output),
  14412. } as any;
  14413. }
  14414. const message = response.message || response.Message || errorCode;
  14415. response.message = message;
  14416. delete response.Message;
  14417. return Promise.reject(Object.assign(new Error(message), response));
  14418. };
  14419. export const deserializeAws_restJson1TestInvokeAuthorizerCommand = async (
  14420. output: __HttpResponse,
  14421. context: __SerdeContext
  14422. ): Promise<TestInvokeAuthorizerCommandOutput> => {
  14423. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14424. return deserializeAws_restJson1TestInvokeAuthorizerCommandError(output, context);
  14425. }
  14426. const contents: TestInvokeAuthorizerCommandOutput = {
  14427. $metadata: deserializeMetadata(output),
  14428. authorization: undefined,
  14429. claims: undefined,
  14430. clientStatus: undefined,
  14431. latency: undefined,
  14432. log: undefined,
  14433. policy: undefined,
  14434. principalId: undefined,
  14435. };
  14436. const data: any = await parseBody(output.body, context);
  14437. if (data.authorization !== undefined && data.authorization !== null) {
  14438. contents.authorization = deserializeAws_restJson1MapOfStringToList(data.authorization, context);
  14439. }
  14440. if (data.claims !== undefined && data.claims !== null) {
  14441. contents.claims = deserializeAws_restJson1MapOfStringToString(data.claims, context);
  14442. }
  14443. if (data.clientStatus !== undefined && data.clientStatus !== null) {
  14444. contents.clientStatus = data.clientStatus;
  14445. }
  14446. if (data.latency !== undefined && data.latency !== null) {
  14447. contents.latency = data.latency;
  14448. }
  14449. if (data.log !== undefined && data.log !== null) {
  14450. contents.log = data.log;
  14451. }
  14452. if (data.policy !== undefined && data.policy !== null) {
  14453. contents.policy = data.policy;
  14454. }
  14455. if (data.principalId !== undefined && data.principalId !== null) {
  14456. contents.principalId = data.principalId;
  14457. }
  14458. return Promise.resolve(contents);
  14459. };
  14460. const deserializeAws_restJson1TestInvokeAuthorizerCommandError = async (
  14461. output: __HttpResponse,
  14462. context: __SerdeContext
  14463. ): Promise<TestInvokeAuthorizerCommandOutput> => {
  14464. const parsedOutput: any = {
  14465. ...output,
  14466. body: await parseBody(output.body, context),
  14467. };
  14468. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14469. let errorCode: string = "UnknownError";
  14470. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14471. switch (errorCode) {
  14472. case "BadRequestException":
  14473. case "com.amazonaws.apigateway#BadRequestException":
  14474. response = {
  14475. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14476. name: errorCode,
  14477. $metadata: deserializeMetadata(output),
  14478. };
  14479. break;
  14480. case "NotFoundException":
  14481. case "com.amazonaws.apigateway#NotFoundException":
  14482. response = {
  14483. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14484. name: errorCode,
  14485. $metadata: deserializeMetadata(output),
  14486. };
  14487. break;
  14488. case "TooManyRequestsException":
  14489. case "com.amazonaws.apigateway#TooManyRequestsException":
  14490. response = {
  14491. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14492. name: errorCode,
  14493. $metadata: deserializeMetadata(output),
  14494. };
  14495. break;
  14496. case "UnauthorizedException":
  14497. case "com.amazonaws.apigateway#UnauthorizedException":
  14498. response = {
  14499. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14500. name: errorCode,
  14501. $metadata: deserializeMetadata(output),
  14502. };
  14503. break;
  14504. default:
  14505. const parsedBody = parsedOutput.body;
  14506. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14507. response = {
  14508. ...parsedBody,
  14509. name: `${errorCode}`,
  14510. message: parsedBody.message || parsedBody.Message || errorCode,
  14511. $fault: "client",
  14512. $metadata: deserializeMetadata(output),
  14513. } as any;
  14514. }
  14515. const message = response.message || response.Message || errorCode;
  14516. response.message = message;
  14517. delete response.Message;
  14518. return Promise.reject(Object.assign(new Error(message), response));
  14519. };
  14520. export const deserializeAws_restJson1TestInvokeMethodCommand = async (
  14521. output: __HttpResponse,
  14522. context: __SerdeContext
  14523. ): Promise<TestInvokeMethodCommandOutput> => {
  14524. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14525. return deserializeAws_restJson1TestInvokeMethodCommandError(output, context);
  14526. }
  14527. const contents: TestInvokeMethodCommandOutput = {
  14528. $metadata: deserializeMetadata(output),
  14529. body: undefined,
  14530. headers: undefined,
  14531. latency: undefined,
  14532. log: undefined,
  14533. multiValueHeaders: undefined,
  14534. status: undefined,
  14535. };
  14536. const data: any = await parseBody(output.body, context);
  14537. if (data.body !== undefined && data.body !== null) {
  14538. contents.body = data.body;
  14539. }
  14540. if (data.headers !== undefined && data.headers !== null) {
  14541. contents.headers = deserializeAws_restJson1MapOfStringToString(data.headers, context);
  14542. }
  14543. if (data.latency !== undefined && data.latency !== null) {
  14544. contents.latency = data.latency;
  14545. }
  14546. if (data.log !== undefined && data.log !== null) {
  14547. contents.log = data.log;
  14548. }
  14549. if (data.multiValueHeaders !== undefined && data.multiValueHeaders !== null) {
  14550. contents.multiValueHeaders = deserializeAws_restJson1MapOfStringToList(data.multiValueHeaders, context);
  14551. }
  14552. if (data.status !== undefined && data.status !== null) {
  14553. contents.status = data.status;
  14554. }
  14555. return Promise.resolve(contents);
  14556. };
  14557. const deserializeAws_restJson1TestInvokeMethodCommandError = async (
  14558. output: __HttpResponse,
  14559. context: __SerdeContext
  14560. ): Promise<TestInvokeMethodCommandOutput> => {
  14561. const parsedOutput: any = {
  14562. ...output,
  14563. body: await parseBody(output.body, context),
  14564. };
  14565. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14566. let errorCode: string = "UnknownError";
  14567. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14568. switch (errorCode) {
  14569. case "BadRequestException":
  14570. case "com.amazonaws.apigateway#BadRequestException":
  14571. response = {
  14572. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14573. name: errorCode,
  14574. $metadata: deserializeMetadata(output),
  14575. };
  14576. break;
  14577. case "NotFoundException":
  14578. case "com.amazonaws.apigateway#NotFoundException":
  14579. response = {
  14580. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14581. name: errorCode,
  14582. $metadata: deserializeMetadata(output),
  14583. };
  14584. break;
  14585. case "TooManyRequestsException":
  14586. case "com.amazonaws.apigateway#TooManyRequestsException":
  14587. response = {
  14588. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14589. name: errorCode,
  14590. $metadata: deserializeMetadata(output),
  14591. };
  14592. break;
  14593. case "UnauthorizedException":
  14594. case "com.amazonaws.apigateway#UnauthorizedException":
  14595. response = {
  14596. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14597. name: errorCode,
  14598. $metadata: deserializeMetadata(output),
  14599. };
  14600. break;
  14601. default:
  14602. const parsedBody = parsedOutput.body;
  14603. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14604. response = {
  14605. ...parsedBody,
  14606. name: `${errorCode}`,
  14607. message: parsedBody.message || parsedBody.Message || errorCode,
  14608. $fault: "client",
  14609. $metadata: deserializeMetadata(output),
  14610. } as any;
  14611. }
  14612. const message = response.message || response.Message || errorCode;
  14613. response.message = message;
  14614. delete response.Message;
  14615. return Promise.reject(Object.assign(new Error(message), response));
  14616. };
  14617. export const deserializeAws_restJson1UntagResourceCommand = async (
  14618. output: __HttpResponse,
  14619. context: __SerdeContext
  14620. ): Promise<UntagResourceCommandOutput> => {
  14621. if (output.statusCode !== 204 && output.statusCode >= 400) {
  14622. return deserializeAws_restJson1UntagResourceCommandError(output, context);
  14623. }
  14624. const contents: UntagResourceCommandOutput = {
  14625. $metadata: deserializeMetadata(output),
  14626. };
  14627. await collectBody(output.body, context);
  14628. return Promise.resolve(contents);
  14629. };
  14630. const deserializeAws_restJson1UntagResourceCommandError = async (
  14631. output: __HttpResponse,
  14632. context: __SerdeContext
  14633. ): Promise<UntagResourceCommandOutput> => {
  14634. const parsedOutput: any = {
  14635. ...output,
  14636. body: await parseBody(output.body, context),
  14637. };
  14638. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14639. let errorCode: string = "UnknownError";
  14640. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14641. switch (errorCode) {
  14642. case "BadRequestException":
  14643. case "com.amazonaws.apigateway#BadRequestException":
  14644. response = {
  14645. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14646. name: errorCode,
  14647. $metadata: deserializeMetadata(output),
  14648. };
  14649. break;
  14650. case "ConflictException":
  14651. case "com.amazonaws.apigateway#ConflictException":
  14652. response = {
  14653. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14654. name: errorCode,
  14655. $metadata: deserializeMetadata(output),
  14656. };
  14657. break;
  14658. case "NotFoundException":
  14659. case "com.amazonaws.apigateway#NotFoundException":
  14660. response = {
  14661. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14662. name: errorCode,
  14663. $metadata: deserializeMetadata(output),
  14664. };
  14665. break;
  14666. case "TooManyRequestsException":
  14667. case "com.amazonaws.apigateway#TooManyRequestsException":
  14668. response = {
  14669. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14670. name: errorCode,
  14671. $metadata: deserializeMetadata(output),
  14672. };
  14673. break;
  14674. case "UnauthorizedException":
  14675. case "com.amazonaws.apigateway#UnauthorizedException":
  14676. response = {
  14677. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14678. name: errorCode,
  14679. $metadata: deserializeMetadata(output),
  14680. };
  14681. break;
  14682. default:
  14683. const parsedBody = parsedOutput.body;
  14684. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14685. response = {
  14686. ...parsedBody,
  14687. name: `${errorCode}`,
  14688. message: parsedBody.message || parsedBody.Message || errorCode,
  14689. $fault: "client",
  14690. $metadata: deserializeMetadata(output),
  14691. } as any;
  14692. }
  14693. const message = response.message || response.Message || errorCode;
  14694. response.message = message;
  14695. delete response.Message;
  14696. return Promise.reject(Object.assign(new Error(message), response));
  14697. };
  14698. export const deserializeAws_restJson1UpdateAccountCommand = async (
  14699. output: __HttpResponse,
  14700. context: __SerdeContext
  14701. ): Promise<UpdateAccountCommandOutput> => {
  14702. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14703. return deserializeAws_restJson1UpdateAccountCommandError(output, context);
  14704. }
  14705. const contents: UpdateAccountCommandOutput = {
  14706. $metadata: deserializeMetadata(output),
  14707. apiKeyVersion: undefined,
  14708. cloudwatchRoleArn: undefined,
  14709. features: undefined,
  14710. throttleSettings: undefined,
  14711. };
  14712. const data: any = await parseBody(output.body, context);
  14713. if (data.apiKeyVersion !== undefined && data.apiKeyVersion !== null) {
  14714. contents.apiKeyVersion = data.apiKeyVersion;
  14715. }
  14716. if (data.cloudwatchRoleArn !== undefined && data.cloudwatchRoleArn !== null) {
  14717. contents.cloudwatchRoleArn = data.cloudwatchRoleArn;
  14718. }
  14719. if (data.features !== undefined && data.features !== null) {
  14720. contents.features = deserializeAws_restJson1ListOfString(data.features, context);
  14721. }
  14722. if (data.throttleSettings !== undefined && data.throttleSettings !== null) {
  14723. contents.throttleSettings = deserializeAws_restJson1ThrottleSettings(data.throttleSettings, context);
  14724. }
  14725. return Promise.resolve(contents);
  14726. };
  14727. const deserializeAws_restJson1UpdateAccountCommandError = async (
  14728. output: __HttpResponse,
  14729. context: __SerdeContext
  14730. ): Promise<UpdateAccountCommandOutput> => {
  14731. const parsedOutput: any = {
  14732. ...output,
  14733. body: await parseBody(output.body, context),
  14734. };
  14735. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14736. let errorCode: string = "UnknownError";
  14737. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14738. switch (errorCode) {
  14739. case "BadRequestException":
  14740. case "com.amazonaws.apigateway#BadRequestException":
  14741. response = {
  14742. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14743. name: errorCode,
  14744. $metadata: deserializeMetadata(output),
  14745. };
  14746. break;
  14747. case "NotFoundException":
  14748. case "com.amazonaws.apigateway#NotFoundException":
  14749. response = {
  14750. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14751. name: errorCode,
  14752. $metadata: deserializeMetadata(output),
  14753. };
  14754. break;
  14755. case "TooManyRequestsException":
  14756. case "com.amazonaws.apigateway#TooManyRequestsException":
  14757. response = {
  14758. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14759. name: errorCode,
  14760. $metadata: deserializeMetadata(output),
  14761. };
  14762. break;
  14763. case "UnauthorizedException":
  14764. case "com.amazonaws.apigateway#UnauthorizedException":
  14765. response = {
  14766. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14767. name: errorCode,
  14768. $metadata: deserializeMetadata(output),
  14769. };
  14770. break;
  14771. default:
  14772. const parsedBody = parsedOutput.body;
  14773. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14774. response = {
  14775. ...parsedBody,
  14776. name: `${errorCode}`,
  14777. message: parsedBody.message || parsedBody.Message || errorCode,
  14778. $fault: "client",
  14779. $metadata: deserializeMetadata(output),
  14780. } as any;
  14781. }
  14782. const message = response.message || response.Message || errorCode;
  14783. response.message = message;
  14784. delete response.Message;
  14785. return Promise.reject(Object.assign(new Error(message), response));
  14786. };
  14787. export const deserializeAws_restJson1UpdateApiKeyCommand = async (
  14788. output: __HttpResponse,
  14789. context: __SerdeContext
  14790. ): Promise<UpdateApiKeyCommandOutput> => {
  14791. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14792. return deserializeAws_restJson1UpdateApiKeyCommandError(output, context);
  14793. }
  14794. const contents: UpdateApiKeyCommandOutput = {
  14795. $metadata: deserializeMetadata(output),
  14796. createdDate: undefined,
  14797. customerId: undefined,
  14798. description: undefined,
  14799. enabled: undefined,
  14800. id: undefined,
  14801. lastUpdatedDate: undefined,
  14802. name: undefined,
  14803. stageKeys: undefined,
  14804. tags: undefined,
  14805. value: undefined,
  14806. };
  14807. const data: any = await parseBody(output.body, context);
  14808. if (data.createdDate !== undefined && data.createdDate !== null) {
  14809. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  14810. }
  14811. if (data.customerId !== undefined && data.customerId !== null) {
  14812. contents.customerId = data.customerId;
  14813. }
  14814. if (data.description !== undefined && data.description !== null) {
  14815. contents.description = data.description;
  14816. }
  14817. if (data.enabled !== undefined && data.enabled !== null) {
  14818. contents.enabled = data.enabled;
  14819. }
  14820. if (data.id !== undefined && data.id !== null) {
  14821. contents.id = data.id;
  14822. }
  14823. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  14824. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  14825. }
  14826. if (data.name !== undefined && data.name !== null) {
  14827. contents.name = data.name;
  14828. }
  14829. if (data.stageKeys !== undefined && data.stageKeys !== null) {
  14830. contents.stageKeys = deserializeAws_restJson1ListOfString(data.stageKeys, context);
  14831. }
  14832. if (data.tags !== undefined && data.tags !== null) {
  14833. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  14834. }
  14835. if (data.value !== undefined && data.value !== null) {
  14836. contents.value = data.value;
  14837. }
  14838. return Promise.resolve(contents);
  14839. };
  14840. const deserializeAws_restJson1UpdateApiKeyCommandError = async (
  14841. output: __HttpResponse,
  14842. context: __SerdeContext
  14843. ): Promise<UpdateApiKeyCommandOutput> => {
  14844. const parsedOutput: any = {
  14845. ...output,
  14846. body: await parseBody(output.body, context),
  14847. };
  14848. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14849. let errorCode: string = "UnknownError";
  14850. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14851. switch (errorCode) {
  14852. case "BadRequestException":
  14853. case "com.amazonaws.apigateway#BadRequestException":
  14854. response = {
  14855. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14856. name: errorCode,
  14857. $metadata: deserializeMetadata(output),
  14858. };
  14859. break;
  14860. case "ConflictException":
  14861. case "com.amazonaws.apigateway#ConflictException":
  14862. response = {
  14863. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  14864. name: errorCode,
  14865. $metadata: deserializeMetadata(output),
  14866. };
  14867. break;
  14868. case "NotFoundException":
  14869. case "com.amazonaws.apigateway#NotFoundException":
  14870. response = {
  14871. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14872. name: errorCode,
  14873. $metadata: deserializeMetadata(output),
  14874. };
  14875. break;
  14876. case "TooManyRequestsException":
  14877. case "com.amazonaws.apigateway#TooManyRequestsException":
  14878. response = {
  14879. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14880. name: errorCode,
  14881. $metadata: deserializeMetadata(output),
  14882. };
  14883. break;
  14884. case "UnauthorizedException":
  14885. case "com.amazonaws.apigateway#UnauthorizedException":
  14886. response = {
  14887. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  14888. name: errorCode,
  14889. $metadata: deserializeMetadata(output),
  14890. };
  14891. break;
  14892. default:
  14893. const parsedBody = parsedOutput.body;
  14894. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  14895. response = {
  14896. ...parsedBody,
  14897. name: `${errorCode}`,
  14898. message: parsedBody.message || parsedBody.Message || errorCode,
  14899. $fault: "client",
  14900. $metadata: deserializeMetadata(output),
  14901. } as any;
  14902. }
  14903. const message = response.message || response.Message || errorCode;
  14904. response.message = message;
  14905. delete response.Message;
  14906. return Promise.reject(Object.assign(new Error(message), response));
  14907. };
  14908. export const deserializeAws_restJson1UpdateAuthorizerCommand = async (
  14909. output: __HttpResponse,
  14910. context: __SerdeContext
  14911. ): Promise<UpdateAuthorizerCommandOutput> => {
  14912. if (output.statusCode !== 200 && output.statusCode >= 400) {
  14913. return deserializeAws_restJson1UpdateAuthorizerCommandError(output, context);
  14914. }
  14915. const contents: UpdateAuthorizerCommandOutput = {
  14916. $metadata: deserializeMetadata(output),
  14917. authType: undefined,
  14918. authorizerCredentials: undefined,
  14919. authorizerResultTtlInSeconds: undefined,
  14920. authorizerUri: undefined,
  14921. id: undefined,
  14922. identitySource: undefined,
  14923. identityValidationExpression: undefined,
  14924. name: undefined,
  14925. providerARNs: undefined,
  14926. type: undefined,
  14927. };
  14928. const data: any = await parseBody(output.body, context);
  14929. if (data.authType !== undefined && data.authType !== null) {
  14930. contents.authType = data.authType;
  14931. }
  14932. if (data.authorizerCredentials !== undefined && data.authorizerCredentials !== null) {
  14933. contents.authorizerCredentials = data.authorizerCredentials;
  14934. }
  14935. if (data.authorizerResultTtlInSeconds !== undefined && data.authorizerResultTtlInSeconds !== null) {
  14936. contents.authorizerResultTtlInSeconds = data.authorizerResultTtlInSeconds;
  14937. }
  14938. if (data.authorizerUri !== undefined && data.authorizerUri !== null) {
  14939. contents.authorizerUri = data.authorizerUri;
  14940. }
  14941. if (data.id !== undefined && data.id !== null) {
  14942. contents.id = data.id;
  14943. }
  14944. if (data.identitySource !== undefined && data.identitySource !== null) {
  14945. contents.identitySource = data.identitySource;
  14946. }
  14947. if (data.identityValidationExpression !== undefined && data.identityValidationExpression !== null) {
  14948. contents.identityValidationExpression = data.identityValidationExpression;
  14949. }
  14950. if (data.name !== undefined && data.name !== null) {
  14951. contents.name = data.name;
  14952. }
  14953. if (data.providerARNs !== undefined && data.providerARNs !== null) {
  14954. contents.providerARNs = deserializeAws_restJson1ListOfARNs(data.providerARNs, context);
  14955. }
  14956. if (data.type !== undefined && data.type !== null) {
  14957. contents.type = data.type;
  14958. }
  14959. return Promise.resolve(contents);
  14960. };
  14961. const deserializeAws_restJson1UpdateAuthorizerCommandError = async (
  14962. output: __HttpResponse,
  14963. context: __SerdeContext
  14964. ): Promise<UpdateAuthorizerCommandOutput> => {
  14965. const parsedOutput: any = {
  14966. ...output,
  14967. body: await parseBody(output.body, context),
  14968. };
  14969. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  14970. let errorCode: string = "UnknownError";
  14971. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  14972. switch (errorCode) {
  14973. case "BadRequestException":
  14974. case "com.amazonaws.apigateway#BadRequestException":
  14975. response = {
  14976. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  14977. name: errorCode,
  14978. $metadata: deserializeMetadata(output),
  14979. };
  14980. break;
  14981. case "NotFoundException":
  14982. case "com.amazonaws.apigateway#NotFoundException":
  14983. response = {
  14984. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  14985. name: errorCode,
  14986. $metadata: deserializeMetadata(output),
  14987. };
  14988. break;
  14989. case "TooManyRequestsException":
  14990. case "com.amazonaws.apigateway#TooManyRequestsException":
  14991. response = {
  14992. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  14993. name: errorCode,
  14994. $metadata: deserializeMetadata(output),
  14995. };
  14996. break;
  14997. case "UnauthorizedException":
  14998. case "com.amazonaws.apigateway#UnauthorizedException":
  14999. response = {
  15000. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15001. name: errorCode,
  15002. $metadata: deserializeMetadata(output),
  15003. };
  15004. break;
  15005. default:
  15006. const parsedBody = parsedOutput.body;
  15007. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15008. response = {
  15009. ...parsedBody,
  15010. name: `${errorCode}`,
  15011. message: parsedBody.message || parsedBody.Message || errorCode,
  15012. $fault: "client",
  15013. $metadata: deserializeMetadata(output),
  15014. } as any;
  15015. }
  15016. const message = response.message || response.Message || errorCode;
  15017. response.message = message;
  15018. delete response.Message;
  15019. return Promise.reject(Object.assign(new Error(message), response));
  15020. };
  15021. export const deserializeAws_restJson1UpdateBasePathMappingCommand = async (
  15022. output: __HttpResponse,
  15023. context: __SerdeContext
  15024. ): Promise<UpdateBasePathMappingCommandOutput> => {
  15025. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15026. return deserializeAws_restJson1UpdateBasePathMappingCommandError(output, context);
  15027. }
  15028. const contents: UpdateBasePathMappingCommandOutput = {
  15029. $metadata: deserializeMetadata(output),
  15030. basePath: undefined,
  15031. restApiId: undefined,
  15032. stage: undefined,
  15033. };
  15034. const data: any = await parseBody(output.body, context);
  15035. if (data.basePath !== undefined && data.basePath !== null) {
  15036. contents.basePath = data.basePath;
  15037. }
  15038. if (data.restApiId !== undefined && data.restApiId !== null) {
  15039. contents.restApiId = data.restApiId;
  15040. }
  15041. if (data.stage !== undefined && data.stage !== null) {
  15042. contents.stage = data.stage;
  15043. }
  15044. return Promise.resolve(contents);
  15045. };
  15046. const deserializeAws_restJson1UpdateBasePathMappingCommandError = async (
  15047. output: __HttpResponse,
  15048. context: __SerdeContext
  15049. ): Promise<UpdateBasePathMappingCommandOutput> => {
  15050. const parsedOutput: any = {
  15051. ...output,
  15052. body: await parseBody(output.body, context),
  15053. };
  15054. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15055. let errorCode: string = "UnknownError";
  15056. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15057. switch (errorCode) {
  15058. case "BadRequestException":
  15059. case "com.amazonaws.apigateway#BadRequestException":
  15060. response = {
  15061. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15062. name: errorCode,
  15063. $metadata: deserializeMetadata(output),
  15064. };
  15065. break;
  15066. case "ConflictException":
  15067. case "com.amazonaws.apigateway#ConflictException":
  15068. response = {
  15069. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15070. name: errorCode,
  15071. $metadata: deserializeMetadata(output),
  15072. };
  15073. break;
  15074. case "NotFoundException":
  15075. case "com.amazonaws.apigateway#NotFoundException":
  15076. response = {
  15077. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15078. name: errorCode,
  15079. $metadata: deserializeMetadata(output),
  15080. };
  15081. break;
  15082. case "TooManyRequestsException":
  15083. case "com.amazonaws.apigateway#TooManyRequestsException":
  15084. response = {
  15085. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15086. name: errorCode,
  15087. $metadata: deserializeMetadata(output),
  15088. };
  15089. break;
  15090. case "UnauthorizedException":
  15091. case "com.amazonaws.apigateway#UnauthorizedException":
  15092. response = {
  15093. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15094. name: errorCode,
  15095. $metadata: deserializeMetadata(output),
  15096. };
  15097. break;
  15098. default:
  15099. const parsedBody = parsedOutput.body;
  15100. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15101. response = {
  15102. ...parsedBody,
  15103. name: `${errorCode}`,
  15104. message: parsedBody.message || parsedBody.Message || errorCode,
  15105. $fault: "client",
  15106. $metadata: deserializeMetadata(output),
  15107. } as any;
  15108. }
  15109. const message = response.message || response.Message || errorCode;
  15110. response.message = message;
  15111. delete response.Message;
  15112. return Promise.reject(Object.assign(new Error(message), response));
  15113. };
  15114. export const deserializeAws_restJson1UpdateClientCertificateCommand = async (
  15115. output: __HttpResponse,
  15116. context: __SerdeContext
  15117. ): Promise<UpdateClientCertificateCommandOutput> => {
  15118. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15119. return deserializeAws_restJson1UpdateClientCertificateCommandError(output, context);
  15120. }
  15121. const contents: UpdateClientCertificateCommandOutput = {
  15122. $metadata: deserializeMetadata(output),
  15123. clientCertificateId: undefined,
  15124. createdDate: undefined,
  15125. description: undefined,
  15126. expirationDate: undefined,
  15127. pemEncodedCertificate: undefined,
  15128. tags: undefined,
  15129. };
  15130. const data: any = await parseBody(output.body, context);
  15131. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  15132. contents.clientCertificateId = data.clientCertificateId;
  15133. }
  15134. if (data.createdDate !== undefined && data.createdDate !== null) {
  15135. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  15136. }
  15137. if (data.description !== undefined && data.description !== null) {
  15138. contents.description = data.description;
  15139. }
  15140. if (data.expirationDate !== undefined && data.expirationDate !== null) {
  15141. contents.expirationDate = new Date(Math.round(data.expirationDate * 1000));
  15142. }
  15143. if (data.pemEncodedCertificate !== undefined && data.pemEncodedCertificate !== null) {
  15144. contents.pemEncodedCertificate = data.pemEncodedCertificate;
  15145. }
  15146. if (data.tags !== undefined && data.tags !== null) {
  15147. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  15148. }
  15149. return Promise.resolve(contents);
  15150. };
  15151. const deserializeAws_restJson1UpdateClientCertificateCommandError = async (
  15152. output: __HttpResponse,
  15153. context: __SerdeContext
  15154. ): Promise<UpdateClientCertificateCommandOutput> => {
  15155. const parsedOutput: any = {
  15156. ...output,
  15157. body: await parseBody(output.body, context),
  15158. };
  15159. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15160. let errorCode: string = "UnknownError";
  15161. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15162. switch (errorCode) {
  15163. case "BadRequestException":
  15164. case "com.amazonaws.apigateway#BadRequestException":
  15165. response = {
  15166. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15167. name: errorCode,
  15168. $metadata: deserializeMetadata(output),
  15169. };
  15170. break;
  15171. case "NotFoundException":
  15172. case "com.amazonaws.apigateway#NotFoundException":
  15173. response = {
  15174. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15175. name: errorCode,
  15176. $metadata: deserializeMetadata(output),
  15177. };
  15178. break;
  15179. case "TooManyRequestsException":
  15180. case "com.amazonaws.apigateway#TooManyRequestsException":
  15181. response = {
  15182. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15183. name: errorCode,
  15184. $metadata: deserializeMetadata(output),
  15185. };
  15186. break;
  15187. case "UnauthorizedException":
  15188. case "com.amazonaws.apigateway#UnauthorizedException":
  15189. response = {
  15190. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15191. name: errorCode,
  15192. $metadata: deserializeMetadata(output),
  15193. };
  15194. break;
  15195. default:
  15196. const parsedBody = parsedOutput.body;
  15197. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15198. response = {
  15199. ...parsedBody,
  15200. name: `${errorCode}`,
  15201. message: parsedBody.message || parsedBody.Message || errorCode,
  15202. $fault: "client",
  15203. $metadata: deserializeMetadata(output),
  15204. } as any;
  15205. }
  15206. const message = response.message || response.Message || errorCode;
  15207. response.message = message;
  15208. delete response.Message;
  15209. return Promise.reject(Object.assign(new Error(message), response));
  15210. };
  15211. export const deserializeAws_restJson1UpdateDeploymentCommand = async (
  15212. output: __HttpResponse,
  15213. context: __SerdeContext
  15214. ): Promise<UpdateDeploymentCommandOutput> => {
  15215. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15216. return deserializeAws_restJson1UpdateDeploymentCommandError(output, context);
  15217. }
  15218. const contents: UpdateDeploymentCommandOutput = {
  15219. $metadata: deserializeMetadata(output),
  15220. apiSummary: undefined,
  15221. createdDate: undefined,
  15222. description: undefined,
  15223. id: undefined,
  15224. };
  15225. const data: any = await parseBody(output.body, context);
  15226. if (data.apiSummary !== undefined && data.apiSummary !== null) {
  15227. contents.apiSummary = deserializeAws_restJson1PathToMapOfMethodSnapshot(data.apiSummary, context);
  15228. }
  15229. if (data.createdDate !== undefined && data.createdDate !== null) {
  15230. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  15231. }
  15232. if (data.description !== undefined && data.description !== null) {
  15233. contents.description = data.description;
  15234. }
  15235. if (data.id !== undefined && data.id !== null) {
  15236. contents.id = data.id;
  15237. }
  15238. return Promise.resolve(contents);
  15239. };
  15240. const deserializeAws_restJson1UpdateDeploymentCommandError = async (
  15241. output: __HttpResponse,
  15242. context: __SerdeContext
  15243. ): Promise<UpdateDeploymentCommandOutput> => {
  15244. const parsedOutput: any = {
  15245. ...output,
  15246. body: await parseBody(output.body, context),
  15247. };
  15248. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15249. let errorCode: string = "UnknownError";
  15250. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15251. switch (errorCode) {
  15252. case "BadRequestException":
  15253. case "com.amazonaws.apigateway#BadRequestException":
  15254. response = {
  15255. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15256. name: errorCode,
  15257. $metadata: deserializeMetadata(output),
  15258. };
  15259. break;
  15260. case "NotFoundException":
  15261. case "com.amazonaws.apigateway#NotFoundException":
  15262. response = {
  15263. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15264. name: errorCode,
  15265. $metadata: deserializeMetadata(output),
  15266. };
  15267. break;
  15268. case "ServiceUnavailableException":
  15269. case "com.amazonaws.apigateway#ServiceUnavailableException":
  15270. response = {
  15271. ...(await deserializeAws_restJson1ServiceUnavailableExceptionResponse(parsedOutput, context)),
  15272. name: errorCode,
  15273. $metadata: deserializeMetadata(output),
  15274. };
  15275. break;
  15276. case "TooManyRequestsException":
  15277. case "com.amazonaws.apigateway#TooManyRequestsException":
  15278. response = {
  15279. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15280. name: errorCode,
  15281. $metadata: deserializeMetadata(output),
  15282. };
  15283. break;
  15284. case "UnauthorizedException":
  15285. case "com.amazonaws.apigateway#UnauthorizedException":
  15286. response = {
  15287. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15288. name: errorCode,
  15289. $metadata: deserializeMetadata(output),
  15290. };
  15291. break;
  15292. default:
  15293. const parsedBody = parsedOutput.body;
  15294. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15295. response = {
  15296. ...parsedBody,
  15297. name: `${errorCode}`,
  15298. message: parsedBody.message || parsedBody.Message || errorCode,
  15299. $fault: "client",
  15300. $metadata: deserializeMetadata(output),
  15301. } as any;
  15302. }
  15303. const message = response.message || response.Message || errorCode;
  15304. response.message = message;
  15305. delete response.Message;
  15306. return Promise.reject(Object.assign(new Error(message), response));
  15307. };
  15308. export const deserializeAws_restJson1UpdateDocumentationPartCommand = async (
  15309. output: __HttpResponse,
  15310. context: __SerdeContext
  15311. ): Promise<UpdateDocumentationPartCommandOutput> => {
  15312. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15313. return deserializeAws_restJson1UpdateDocumentationPartCommandError(output, context);
  15314. }
  15315. const contents: UpdateDocumentationPartCommandOutput = {
  15316. $metadata: deserializeMetadata(output),
  15317. id: undefined,
  15318. location: undefined,
  15319. properties: undefined,
  15320. };
  15321. const data: any = await parseBody(output.body, context);
  15322. if (data.id !== undefined && data.id !== null) {
  15323. contents.id = data.id;
  15324. }
  15325. if (data.location !== undefined && data.location !== null) {
  15326. contents.location = deserializeAws_restJson1DocumentationPartLocation(data.location, context);
  15327. }
  15328. if (data.properties !== undefined && data.properties !== null) {
  15329. contents.properties = data.properties;
  15330. }
  15331. return Promise.resolve(contents);
  15332. };
  15333. const deserializeAws_restJson1UpdateDocumentationPartCommandError = async (
  15334. output: __HttpResponse,
  15335. context: __SerdeContext
  15336. ): Promise<UpdateDocumentationPartCommandOutput> => {
  15337. const parsedOutput: any = {
  15338. ...output,
  15339. body: await parseBody(output.body, context),
  15340. };
  15341. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15342. let errorCode: string = "UnknownError";
  15343. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15344. switch (errorCode) {
  15345. case "BadRequestException":
  15346. case "com.amazonaws.apigateway#BadRequestException":
  15347. response = {
  15348. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15349. name: errorCode,
  15350. $metadata: deserializeMetadata(output),
  15351. };
  15352. break;
  15353. case "ConflictException":
  15354. case "com.amazonaws.apigateway#ConflictException":
  15355. response = {
  15356. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15357. name: errorCode,
  15358. $metadata: deserializeMetadata(output),
  15359. };
  15360. break;
  15361. case "LimitExceededException":
  15362. case "com.amazonaws.apigateway#LimitExceededException":
  15363. response = {
  15364. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  15365. name: errorCode,
  15366. $metadata: deserializeMetadata(output),
  15367. };
  15368. break;
  15369. case "NotFoundException":
  15370. case "com.amazonaws.apigateway#NotFoundException":
  15371. response = {
  15372. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15373. name: errorCode,
  15374. $metadata: deserializeMetadata(output),
  15375. };
  15376. break;
  15377. case "TooManyRequestsException":
  15378. case "com.amazonaws.apigateway#TooManyRequestsException":
  15379. response = {
  15380. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15381. name: errorCode,
  15382. $metadata: deserializeMetadata(output),
  15383. };
  15384. break;
  15385. case "UnauthorizedException":
  15386. case "com.amazonaws.apigateway#UnauthorizedException":
  15387. response = {
  15388. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15389. name: errorCode,
  15390. $metadata: deserializeMetadata(output),
  15391. };
  15392. break;
  15393. default:
  15394. const parsedBody = parsedOutput.body;
  15395. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15396. response = {
  15397. ...parsedBody,
  15398. name: `${errorCode}`,
  15399. message: parsedBody.message || parsedBody.Message || errorCode,
  15400. $fault: "client",
  15401. $metadata: deserializeMetadata(output),
  15402. } as any;
  15403. }
  15404. const message = response.message || response.Message || errorCode;
  15405. response.message = message;
  15406. delete response.Message;
  15407. return Promise.reject(Object.assign(new Error(message), response));
  15408. };
  15409. export const deserializeAws_restJson1UpdateDocumentationVersionCommand = async (
  15410. output: __HttpResponse,
  15411. context: __SerdeContext
  15412. ): Promise<UpdateDocumentationVersionCommandOutput> => {
  15413. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15414. return deserializeAws_restJson1UpdateDocumentationVersionCommandError(output, context);
  15415. }
  15416. const contents: UpdateDocumentationVersionCommandOutput = {
  15417. $metadata: deserializeMetadata(output),
  15418. createdDate: undefined,
  15419. description: undefined,
  15420. version: undefined,
  15421. };
  15422. const data: any = await parseBody(output.body, context);
  15423. if (data.createdDate !== undefined && data.createdDate !== null) {
  15424. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  15425. }
  15426. if (data.description !== undefined && data.description !== null) {
  15427. contents.description = data.description;
  15428. }
  15429. if (data.version !== undefined && data.version !== null) {
  15430. contents.version = data.version;
  15431. }
  15432. return Promise.resolve(contents);
  15433. };
  15434. const deserializeAws_restJson1UpdateDocumentationVersionCommandError = async (
  15435. output: __HttpResponse,
  15436. context: __SerdeContext
  15437. ): Promise<UpdateDocumentationVersionCommandOutput> => {
  15438. const parsedOutput: any = {
  15439. ...output,
  15440. body: await parseBody(output.body, context),
  15441. };
  15442. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15443. let errorCode: string = "UnknownError";
  15444. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15445. switch (errorCode) {
  15446. case "BadRequestException":
  15447. case "com.amazonaws.apigateway#BadRequestException":
  15448. response = {
  15449. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15450. name: errorCode,
  15451. $metadata: deserializeMetadata(output),
  15452. };
  15453. break;
  15454. case "ConflictException":
  15455. case "com.amazonaws.apigateway#ConflictException":
  15456. response = {
  15457. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15458. name: errorCode,
  15459. $metadata: deserializeMetadata(output),
  15460. };
  15461. break;
  15462. case "NotFoundException":
  15463. case "com.amazonaws.apigateway#NotFoundException":
  15464. response = {
  15465. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15466. name: errorCode,
  15467. $metadata: deserializeMetadata(output),
  15468. };
  15469. break;
  15470. case "TooManyRequestsException":
  15471. case "com.amazonaws.apigateway#TooManyRequestsException":
  15472. response = {
  15473. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15474. name: errorCode,
  15475. $metadata: deserializeMetadata(output),
  15476. };
  15477. break;
  15478. case "UnauthorizedException":
  15479. case "com.amazonaws.apigateway#UnauthorizedException":
  15480. response = {
  15481. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15482. name: errorCode,
  15483. $metadata: deserializeMetadata(output),
  15484. };
  15485. break;
  15486. default:
  15487. const parsedBody = parsedOutput.body;
  15488. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15489. response = {
  15490. ...parsedBody,
  15491. name: `${errorCode}`,
  15492. message: parsedBody.message || parsedBody.Message || errorCode,
  15493. $fault: "client",
  15494. $metadata: deserializeMetadata(output),
  15495. } as any;
  15496. }
  15497. const message = response.message || response.Message || errorCode;
  15498. response.message = message;
  15499. delete response.Message;
  15500. return Promise.reject(Object.assign(new Error(message), response));
  15501. };
  15502. export const deserializeAws_restJson1UpdateDomainNameCommand = async (
  15503. output: __HttpResponse,
  15504. context: __SerdeContext
  15505. ): Promise<UpdateDomainNameCommandOutput> => {
  15506. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15507. return deserializeAws_restJson1UpdateDomainNameCommandError(output, context);
  15508. }
  15509. const contents: UpdateDomainNameCommandOutput = {
  15510. $metadata: deserializeMetadata(output),
  15511. certificateArn: undefined,
  15512. certificateName: undefined,
  15513. certificateUploadDate: undefined,
  15514. distributionDomainName: undefined,
  15515. distributionHostedZoneId: undefined,
  15516. domainName: undefined,
  15517. domainNameStatus: undefined,
  15518. domainNameStatusMessage: undefined,
  15519. endpointConfiguration: undefined,
  15520. regionalCertificateArn: undefined,
  15521. regionalCertificateName: undefined,
  15522. regionalDomainName: undefined,
  15523. regionalHostedZoneId: undefined,
  15524. securityPolicy: undefined,
  15525. tags: undefined,
  15526. };
  15527. const data: any = await parseBody(output.body, context);
  15528. if (data.certificateArn !== undefined && data.certificateArn !== null) {
  15529. contents.certificateArn = data.certificateArn;
  15530. }
  15531. if (data.certificateName !== undefined && data.certificateName !== null) {
  15532. contents.certificateName = data.certificateName;
  15533. }
  15534. if (data.certificateUploadDate !== undefined && data.certificateUploadDate !== null) {
  15535. contents.certificateUploadDate = new Date(Math.round(data.certificateUploadDate * 1000));
  15536. }
  15537. if (data.distributionDomainName !== undefined && data.distributionDomainName !== null) {
  15538. contents.distributionDomainName = data.distributionDomainName;
  15539. }
  15540. if (data.distributionHostedZoneId !== undefined && data.distributionHostedZoneId !== null) {
  15541. contents.distributionHostedZoneId = data.distributionHostedZoneId;
  15542. }
  15543. if (data.domainName !== undefined && data.domainName !== null) {
  15544. contents.domainName = data.domainName;
  15545. }
  15546. if (data.domainNameStatus !== undefined && data.domainNameStatus !== null) {
  15547. contents.domainNameStatus = data.domainNameStatus;
  15548. }
  15549. if (data.domainNameStatusMessage !== undefined && data.domainNameStatusMessage !== null) {
  15550. contents.domainNameStatusMessage = data.domainNameStatusMessage;
  15551. }
  15552. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  15553. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  15554. }
  15555. if (data.regionalCertificateArn !== undefined && data.regionalCertificateArn !== null) {
  15556. contents.regionalCertificateArn = data.regionalCertificateArn;
  15557. }
  15558. if (data.regionalCertificateName !== undefined && data.regionalCertificateName !== null) {
  15559. contents.regionalCertificateName = data.regionalCertificateName;
  15560. }
  15561. if (data.regionalDomainName !== undefined && data.regionalDomainName !== null) {
  15562. contents.regionalDomainName = data.regionalDomainName;
  15563. }
  15564. if (data.regionalHostedZoneId !== undefined && data.regionalHostedZoneId !== null) {
  15565. contents.regionalHostedZoneId = data.regionalHostedZoneId;
  15566. }
  15567. if (data.securityPolicy !== undefined && data.securityPolicy !== null) {
  15568. contents.securityPolicy = data.securityPolicy;
  15569. }
  15570. if (data.tags !== undefined && data.tags !== null) {
  15571. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  15572. }
  15573. return Promise.resolve(contents);
  15574. };
  15575. const deserializeAws_restJson1UpdateDomainNameCommandError = async (
  15576. output: __HttpResponse,
  15577. context: __SerdeContext
  15578. ): Promise<UpdateDomainNameCommandOutput> => {
  15579. const parsedOutput: any = {
  15580. ...output,
  15581. body: await parseBody(output.body, context),
  15582. };
  15583. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15584. let errorCode: string = "UnknownError";
  15585. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15586. switch (errorCode) {
  15587. case "BadRequestException":
  15588. case "com.amazonaws.apigateway#BadRequestException":
  15589. response = {
  15590. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15591. name: errorCode,
  15592. $metadata: deserializeMetadata(output),
  15593. };
  15594. break;
  15595. case "ConflictException":
  15596. case "com.amazonaws.apigateway#ConflictException":
  15597. response = {
  15598. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15599. name: errorCode,
  15600. $metadata: deserializeMetadata(output),
  15601. };
  15602. break;
  15603. case "NotFoundException":
  15604. case "com.amazonaws.apigateway#NotFoundException":
  15605. response = {
  15606. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15607. name: errorCode,
  15608. $metadata: deserializeMetadata(output),
  15609. };
  15610. break;
  15611. case "TooManyRequestsException":
  15612. case "com.amazonaws.apigateway#TooManyRequestsException":
  15613. response = {
  15614. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15615. name: errorCode,
  15616. $metadata: deserializeMetadata(output),
  15617. };
  15618. break;
  15619. case "UnauthorizedException":
  15620. case "com.amazonaws.apigateway#UnauthorizedException":
  15621. response = {
  15622. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15623. name: errorCode,
  15624. $metadata: deserializeMetadata(output),
  15625. };
  15626. break;
  15627. default:
  15628. const parsedBody = parsedOutput.body;
  15629. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15630. response = {
  15631. ...parsedBody,
  15632. name: `${errorCode}`,
  15633. message: parsedBody.message || parsedBody.Message || errorCode,
  15634. $fault: "client",
  15635. $metadata: deserializeMetadata(output),
  15636. } as any;
  15637. }
  15638. const message = response.message || response.Message || errorCode;
  15639. response.message = message;
  15640. delete response.Message;
  15641. return Promise.reject(Object.assign(new Error(message), response));
  15642. };
  15643. export const deserializeAws_restJson1UpdateGatewayResponseCommand = async (
  15644. output: __HttpResponse,
  15645. context: __SerdeContext
  15646. ): Promise<UpdateGatewayResponseCommandOutput> => {
  15647. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15648. return deserializeAws_restJson1UpdateGatewayResponseCommandError(output, context);
  15649. }
  15650. const contents: UpdateGatewayResponseCommandOutput = {
  15651. $metadata: deserializeMetadata(output),
  15652. defaultResponse: undefined,
  15653. responseParameters: undefined,
  15654. responseTemplates: undefined,
  15655. responseType: undefined,
  15656. statusCode: undefined,
  15657. };
  15658. const data: any = await parseBody(output.body, context);
  15659. if (data.defaultResponse !== undefined && data.defaultResponse !== null) {
  15660. contents.defaultResponse = data.defaultResponse;
  15661. }
  15662. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  15663. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  15664. }
  15665. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  15666. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  15667. }
  15668. if (data.responseType !== undefined && data.responseType !== null) {
  15669. contents.responseType = data.responseType;
  15670. }
  15671. if (data.statusCode !== undefined && data.statusCode !== null) {
  15672. contents.statusCode = data.statusCode;
  15673. }
  15674. return Promise.resolve(contents);
  15675. };
  15676. const deserializeAws_restJson1UpdateGatewayResponseCommandError = async (
  15677. output: __HttpResponse,
  15678. context: __SerdeContext
  15679. ): Promise<UpdateGatewayResponseCommandOutput> => {
  15680. const parsedOutput: any = {
  15681. ...output,
  15682. body: await parseBody(output.body, context),
  15683. };
  15684. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15685. let errorCode: string = "UnknownError";
  15686. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15687. switch (errorCode) {
  15688. case "BadRequestException":
  15689. case "com.amazonaws.apigateway#BadRequestException":
  15690. response = {
  15691. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15692. name: errorCode,
  15693. $metadata: deserializeMetadata(output),
  15694. };
  15695. break;
  15696. case "NotFoundException":
  15697. case "com.amazonaws.apigateway#NotFoundException":
  15698. response = {
  15699. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15700. name: errorCode,
  15701. $metadata: deserializeMetadata(output),
  15702. };
  15703. break;
  15704. case "TooManyRequestsException":
  15705. case "com.amazonaws.apigateway#TooManyRequestsException":
  15706. response = {
  15707. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15708. name: errorCode,
  15709. $metadata: deserializeMetadata(output),
  15710. };
  15711. break;
  15712. case "UnauthorizedException":
  15713. case "com.amazonaws.apigateway#UnauthorizedException":
  15714. response = {
  15715. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15716. name: errorCode,
  15717. $metadata: deserializeMetadata(output),
  15718. };
  15719. break;
  15720. default:
  15721. const parsedBody = parsedOutput.body;
  15722. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15723. response = {
  15724. ...parsedBody,
  15725. name: `${errorCode}`,
  15726. message: parsedBody.message || parsedBody.Message || errorCode,
  15727. $fault: "client",
  15728. $metadata: deserializeMetadata(output),
  15729. } as any;
  15730. }
  15731. const message = response.message || response.Message || errorCode;
  15732. response.message = message;
  15733. delete response.Message;
  15734. return Promise.reject(Object.assign(new Error(message), response));
  15735. };
  15736. export const deserializeAws_restJson1UpdateIntegrationCommand = async (
  15737. output: __HttpResponse,
  15738. context: __SerdeContext
  15739. ): Promise<UpdateIntegrationCommandOutput> => {
  15740. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15741. return deserializeAws_restJson1UpdateIntegrationCommandError(output, context);
  15742. }
  15743. const contents: UpdateIntegrationCommandOutput = {
  15744. $metadata: deserializeMetadata(output),
  15745. cacheKeyParameters: undefined,
  15746. cacheNamespace: undefined,
  15747. connectionId: undefined,
  15748. connectionType: undefined,
  15749. contentHandling: undefined,
  15750. credentials: undefined,
  15751. httpMethod: undefined,
  15752. integrationResponses: undefined,
  15753. passthroughBehavior: undefined,
  15754. requestParameters: undefined,
  15755. requestTemplates: undefined,
  15756. timeoutInMillis: undefined,
  15757. tlsConfig: undefined,
  15758. type: undefined,
  15759. uri: undefined,
  15760. };
  15761. const data: any = await parseBody(output.body, context);
  15762. if (data.cacheKeyParameters !== undefined && data.cacheKeyParameters !== null) {
  15763. contents.cacheKeyParameters = deserializeAws_restJson1ListOfString(data.cacheKeyParameters, context);
  15764. }
  15765. if (data.cacheNamespace !== undefined && data.cacheNamespace !== null) {
  15766. contents.cacheNamespace = data.cacheNamespace;
  15767. }
  15768. if (data.connectionId !== undefined && data.connectionId !== null) {
  15769. contents.connectionId = data.connectionId;
  15770. }
  15771. if (data.connectionType !== undefined && data.connectionType !== null) {
  15772. contents.connectionType = data.connectionType;
  15773. }
  15774. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  15775. contents.contentHandling = data.contentHandling;
  15776. }
  15777. if (data.credentials !== undefined && data.credentials !== null) {
  15778. contents.credentials = data.credentials;
  15779. }
  15780. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  15781. contents.httpMethod = data.httpMethod;
  15782. }
  15783. if (data.integrationResponses !== undefined && data.integrationResponses !== null) {
  15784. contents.integrationResponses = deserializeAws_restJson1MapOfIntegrationResponse(
  15785. data.integrationResponses,
  15786. context
  15787. );
  15788. }
  15789. if (data.passthroughBehavior !== undefined && data.passthroughBehavior !== null) {
  15790. contents.passthroughBehavior = data.passthroughBehavior;
  15791. }
  15792. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  15793. contents.requestParameters = deserializeAws_restJson1MapOfStringToString(data.requestParameters, context);
  15794. }
  15795. if (data.requestTemplates !== undefined && data.requestTemplates !== null) {
  15796. contents.requestTemplates = deserializeAws_restJson1MapOfStringToString(data.requestTemplates, context);
  15797. }
  15798. if (data.timeoutInMillis !== undefined && data.timeoutInMillis !== null) {
  15799. contents.timeoutInMillis = data.timeoutInMillis;
  15800. }
  15801. if (data.tlsConfig !== undefined && data.tlsConfig !== null) {
  15802. contents.tlsConfig = deserializeAws_restJson1TlsConfig(data.tlsConfig, context);
  15803. }
  15804. if (data.type !== undefined && data.type !== null) {
  15805. contents.type = data.type;
  15806. }
  15807. if (data.uri !== undefined && data.uri !== null) {
  15808. contents.uri = data.uri;
  15809. }
  15810. return Promise.resolve(contents);
  15811. };
  15812. const deserializeAws_restJson1UpdateIntegrationCommandError = async (
  15813. output: __HttpResponse,
  15814. context: __SerdeContext
  15815. ): Promise<UpdateIntegrationCommandOutput> => {
  15816. const parsedOutput: any = {
  15817. ...output,
  15818. body: await parseBody(output.body, context),
  15819. };
  15820. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15821. let errorCode: string = "UnknownError";
  15822. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15823. switch (errorCode) {
  15824. case "BadRequestException":
  15825. case "com.amazonaws.apigateway#BadRequestException":
  15826. response = {
  15827. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15828. name: errorCode,
  15829. $metadata: deserializeMetadata(output),
  15830. };
  15831. break;
  15832. case "ConflictException":
  15833. case "com.amazonaws.apigateway#ConflictException":
  15834. response = {
  15835. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15836. name: errorCode,
  15837. $metadata: deserializeMetadata(output),
  15838. };
  15839. break;
  15840. case "NotFoundException":
  15841. case "com.amazonaws.apigateway#NotFoundException":
  15842. response = {
  15843. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15844. name: errorCode,
  15845. $metadata: deserializeMetadata(output),
  15846. };
  15847. break;
  15848. case "TooManyRequestsException":
  15849. case "com.amazonaws.apigateway#TooManyRequestsException":
  15850. response = {
  15851. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15852. name: errorCode,
  15853. $metadata: deserializeMetadata(output),
  15854. };
  15855. break;
  15856. case "UnauthorizedException":
  15857. case "com.amazonaws.apigateway#UnauthorizedException":
  15858. response = {
  15859. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15860. name: errorCode,
  15861. $metadata: deserializeMetadata(output),
  15862. };
  15863. break;
  15864. default:
  15865. const parsedBody = parsedOutput.body;
  15866. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15867. response = {
  15868. ...parsedBody,
  15869. name: `${errorCode}`,
  15870. message: parsedBody.message || parsedBody.Message || errorCode,
  15871. $fault: "client",
  15872. $metadata: deserializeMetadata(output),
  15873. } as any;
  15874. }
  15875. const message = response.message || response.Message || errorCode;
  15876. response.message = message;
  15877. delete response.Message;
  15878. return Promise.reject(Object.assign(new Error(message), response));
  15879. };
  15880. export const deserializeAws_restJson1UpdateIntegrationResponseCommand = async (
  15881. output: __HttpResponse,
  15882. context: __SerdeContext
  15883. ): Promise<UpdateIntegrationResponseCommandOutput> => {
  15884. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15885. return deserializeAws_restJson1UpdateIntegrationResponseCommandError(output, context);
  15886. }
  15887. const contents: UpdateIntegrationResponseCommandOutput = {
  15888. $metadata: deserializeMetadata(output),
  15889. contentHandling: undefined,
  15890. responseParameters: undefined,
  15891. responseTemplates: undefined,
  15892. selectionPattern: undefined,
  15893. statusCode: undefined,
  15894. };
  15895. const data: any = await parseBody(output.body, context);
  15896. if (data.contentHandling !== undefined && data.contentHandling !== null) {
  15897. contents.contentHandling = data.contentHandling;
  15898. }
  15899. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  15900. contents.responseParameters = deserializeAws_restJson1MapOfStringToString(data.responseParameters, context);
  15901. }
  15902. if (data.responseTemplates !== undefined && data.responseTemplates !== null) {
  15903. contents.responseTemplates = deserializeAws_restJson1MapOfStringToString(data.responseTemplates, context);
  15904. }
  15905. if (data.selectionPattern !== undefined && data.selectionPattern !== null) {
  15906. contents.selectionPattern = data.selectionPattern;
  15907. }
  15908. if (data.statusCode !== undefined && data.statusCode !== null) {
  15909. contents.statusCode = data.statusCode;
  15910. }
  15911. return Promise.resolve(contents);
  15912. };
  15913. const deserializeAws_restJson1UpdateIntegrationResponseCommandError = async (
  15914. output: __HttpResponse,
  15915. context: __SerdeContext
  15916. ): Promise<UpdateIntegrationResponseCommandOutput> => {
  15917. const parsedOutput: any = {
  15918. ...output,
  15919. body: await parseBody(output.body, context),
  15920. };
  15921. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  15922. let errorCode: string = "UnknownError";
  15923. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  15924. switch (errorCode) {
  15925. case "BadRequestException":
  15926. case "com.amazonaws.apigateway#BadRequestException":
  15927. response = {
  15928. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  15929. name: errorCode,
  15930. $metadata: deserializeMetadata(output),
  15931. };
  15932. break;
  15933. case "ConflictException":
  15934. case "com.amazonaws.apigateway#ConflictException":
  15935. response = {
  15936. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  15937. name: errorCode,
  15938. $metadata: deserializeMetadata(output),
  15939. };
  15940. break;
  15941. case "NotFoundException":
  15942. case "com.amazonaws.apigateway#NotFoundException":
  15943. response = {
  15944. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  15945. name: errorCode,
  15946. $metadata: deserializeMetadata(output),
  15947. };
  15948. break;
  15949. case "TooManyRequestsException":
  15950. case "com.amazonaws.apigateway#TooManyRequestsException":
  15951. response = {
  15952. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  15953. name: errorCode,
  15954. $metadata: deserializeMetadata(output),
  15955. };
  15956. break;
  15957. case "UnauthorizedException":
  15958. case "com.amazonaws.apigateway#UnauthorizedException":
  15959. response = {
  15960. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  15961. name: errorCode,
  15962. $metadata: deserializeMetadata(output),
  15963. };
  15964. break;
  15965. default:
  15966. const parsedBody = parsedOutput.body;
  15967. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  15968. response = {
  15969. ...parsedBody,
  15970. name: `${errorCode}`,
  15971. message: parsedBody.message || parsedBody.Message || errorCode,
  15972. $fault: "client",
  15973. $metadata: deserializeMetadata(output),
  15974. } as any;
  15975. }
  15976. const message = response.message || response.Message || errorCode;
  15977. response.message = message;
  15978. delete response.Message;
  15979. return Promise.reject(Object.assign(new Error(message), response));
  15980. };
  15981. export const deserializeAws_restJson1UpdateMethodCommand = async (
  15982. output: __HttpResponse,
  15983. context: __SerdeContext
  15984. ): Promise<UpdateMethodCommandOutput> => {
  15985. if (output.statusCode !== 200 && output.statusCode >= 400) {
  15986. return deserializeAws_restJson1UpdateMethodCommandError(output, context);
  15987. }
  15988. const contents: UpdateMethodCommandOutput = {
  15989. $metadata: deserializeMetadata(output),
  15990. apiKeyRequired: undefined,
  15991. authorizationScopes: undefined,
  15992. authorizationType: undefined,
  15993. authorizerId: undefined,
  15994. httpMethod: undefined,
  15995. methodIntegration: undefined,
  15996. methodResponses: undefined,
  15997. operationName: undefined,
  15998. requestModels: undefined,
  15999. requestParameters: undefined,
  16000. requestValidatorId: undefined,
  16001. };
  16002. const data: any = await parseBody(output.body, context);
  16003. if (data.apiKeyRequired !== undefined && data.apiKeyRequired !== null) {
  16004. contents.apiKeyRequired = data.apiKeyRequired;
  16005. }
  16006. if (data.authorizationScopes !== undefined && data.authorizationScopes !== null) {
  16007. contents.authorizationScopes = deserializeAws_restJson1ListOfString(data.authorizationScopes, context);
  16008. }
  16009. if (data.authorizationType !== undefined && data.authorizationType !== null) {
  16010. contents.authorizationType = data.authorizationType;
  16011. }
  16012. if (data.authorizerId !== undefined && data.authorizerId !== null) {
  16013. contents.authorizerId = data.authorizerId;
  16014. }
  16015. if (data.httpMethod !== undefined && data.httpMethod !== null) {
  16016. contents.httpMethod = data.httpMethod;
  16017. }
  16018. if (data.methodIntegration !== undefined && data.methodIntegration !== null) {
  16019. contents.methodIntegration = deserializeAws_restJson1Integration(data.methodIntegration, context);
  16020. }
  16021. if (data.methodResponses !== undefined && data.methodResponses !== null) {
  16022. contents.methodResponses = deserializeAws_restJson1MapOfMethodResponse(data.methodResponses, context);
  16023. }
  16024. if (data.operationName !== undefined && data.operationName !== null) {
  16025. contents.operationName = data.operationName;
  16026. }
  16027. if (data.requestModels !== undefined && data.requestModels !== null) {
  16028. contents.requestModels = deserializeAws_restJson1MapOfStringToString(data.requestModels, context);
  16029. }
  16030. if (data.requestParameters !== undefined && data.requestParameters !== null) {
  16031. contents.requestParameters = deserializeAws_restJson1MapOfStringToBoolean(data.requestParameters, context);
  16032. }
  16033. if (data.requestValidatorId !== undefined && data.requestValidatorId !== null) {
  16034. contents.requestValidatorId = data.requestValidatorId;
  16035. }
  16036. return Promise.resolve(contents);
  16037. };
  16038. const deserializeAws_restJson1UpdateMethodCommandError = async (
  16039. output: __HttpResponse,
  16040. context: __SerdeContext
  16041. ): Promise<UpdateMethodCommandOutput> => {
  16042. const parsedOutput: any = {
  16043. ...output,
  16044. body: await parseBody(output.body, context),
  16045. };
  16046. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16047. let errorCode: string = "UnknownError";
  16048. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16049. switch (errorCode) {
  16050. case "BadRequestException":
  16051. case "com.amazonaws.apigateway#BadRequestException":
  16052. response = {
  16053. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16054. name: errorCode,
  16055. $metadata: deserializeMetadata(output),
  16056. };
  16057. break;
  16058. case "ConflictException":
  16059. case "com.amazonaws.apigateway#ConflictException":
  16060. response = {
  16061. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16062. name: errorCode,
  16063. $metadata: deserializeMetadata(output),
  16064. };
  16065. break;
  16066. case "NotFoundException":
  16067. case "com.amazonaws.apigateway#NotFoundException":
  16068. response = {
  16069. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16070. name: errorCode,
  16071. $metadata: deserializeMetadata(output),
  16072. };
  16073. break;
  16074. case "TooManyRequestsException":
  16075. case "com.amazonaws.apigateway#TooManyRequestsException":
  16076. response = {
  16077. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16078. name: errorCode,
  16079. $metadata: deserializeMetadata(output),
  16080. };
  16081. break;
  16082. case "UnauthorizedException":
  16083. case "com.amazonaws.apigateway#UnauthorizedException":
  16084. response = {
  16085. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16086. name: errorCode,
  16087. $metadata: deserializeMetadata(output),
  16088. };
  16089. break;
  16090. default:
  16091. const parsedBody = parsedOutput.body;
  16092. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16093. response = {
  16094. ...parsedBody,
  16095. name: `${errorCode}`,
  16096. message: parsedBody.message || parsedBody.Message || errorCode,
  16097. $fault: "client",
  16098. $metadata: deserializeMetadata(output),
  16099. } as any;
  16100. }
  16101. const message = response.message || response.Message || errorCode;
  16102. response.message = message;
  16103. delete response.Message;
  16104. return Promise.reject(Object.assign(new Error(message), response));
  16105. };
  16106. export const deserializeAws_restJson1UpdateMethodResponseCommand = async (
  16107. output: __HttpResponse,
  16108. context: __SerdeContext
  16109. ): Promise<UpdateMethodResponseCommandOutput> => {
  16110. if (output.statusCode !== 201 && output.statusCode >= 400) {
  16111. return deserializeAws_restJson1UpdateMethodResponseCommandError(output, context);
  16112. }
  16113. const contents: UpdateMethodResponseCommandOutput = {
  16114. $metadata: deserializeMetadata(output),
  16115. responseModels: undefined,
  16116. responseParameters: undefined,
  16117. statusCode: undefined,
  16118. };
  16119. const data: any = await parseBody(output.body, context);
  16120. if (data.responseModels !== undefined && data.responseModels !== null) {
  16121. contents.responseModels = deserializeAws_restJson1MapOfStringToString(data.responseModels, context);
  16122. }
  16123. if (data.responseParameters !== undefined && data.responseParameters !== null) {
  16124. contents.responseParameters = deserializeAws_restJson1MapOfStringToBoolean(data.responseParameters, context);
  16125. }
  16126. if (data.statusCode !== undefined && data.statusCode !== null) {
  16127. contents.statusCode = data.statusCode;
  16128. }
  16129. return Promise.resolve(contents);
  16130. };
  16131. const deserializeAws_restJson1UpdateMethodResponseCommandError = async (
  16132. output: __HttpResponse,
  16133. context: __SerdeContext
  16134. ): Promise<UpdateMethodResponseCommandOutput> => {
  16135. const parsedOutput: any = {
  16136. ...output,
  16137. body: await parseBody(output.body, context),
  16138. };
  16139. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16140. let errorCode: string = "UnknownError";
  16141. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16142. switch (errorCode) {
  16143. case "BadRequestException":
  16144. case "com.amazonaws.apigateway#BadRequestException":
  16145. response = {
  16146. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16147. name: errorCode,
  16148. $metadata: deserializeMetadata(output),
  16149. };
  16150. break;
  16151. case "ConflictException":
  16152. case "com.amazonaws.apigateway#ConflictException":
  16153. response = {
  16154. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16155. name: errorCode,
  16156. $metadata: deserializeMetadata(output),
  16157. };
  16158. break;
  16159. case "LimitExceededException":
  16160. case "com.amazonaws.apigateway#LimitExceededException":
  16161. response = {
  16162. ...(await deserializeAws_restJson1LimitExceededExceptionResponse(parsedOutput, context)),
  16163. name: errorCode,
  16164. $metadata: deserializeMetadata(output),
  16165. };
  16166. break;
  16167. case "NotFoundException":
  16168. case "com.amazonaws.apigateway#NotFoundException":
  16169. response = {
  16170. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16171. name: errorCode,
  16172. $metadata: deserializeMetadata(output),
  16173. };
  16174. break;
  16175. case "TooManyRequestsException":
  16176. case "com.amazonaws.apigateway#TooManyRequestsException":
  16177. response = {
  16178. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16179. name: errorCode,
  16180. $metadata: deserializeMetadata(output),
  16181. };
  16182. break;
  16183. case "UnauthorizedException":
  16184. case "com.amazonaws.apigateway#UnauthorizedException":
  16185. response = {
  16186. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16187. name: errorCode,
  16188. $metadata: deserializeMetadata(output),
  16189. };
  16190. break;
  16191. default:
  16192. const parsedBody = parsedOutput.body;
  16193. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16194. response = {
  16195. ...parsedBody,
  16196. name: `${errorCode}`,
  16197. message: parsedBody.message || parsedBody.Message || errorCode,
  16198. $fault: "client",
  16199. $metadata: deserializeMetadata(output),
  16200. } as any;
  16201. }
  16202. const message = response.message || response.Message || errorCode;
  16203. response.message = message;
  16204. delete response.Message;
  16205. return Promise.reject(Object.assign(new Error(message), response));
  16206. };
  16207. export const deserializeAws_restJson1UpdateModelCommand = async (
  16208. output: __HttpResponse,
  16209. context: __SerdeContext
  16210. ): Promise<UpdateModelCommandOutput> => {
  16211. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16212. return deserializeAws_restJson1UpdateModelCommandError(output, context);
  16213. }
  16214. const contents: UpdateModelCommandOutput = {
  16215. $metadata: deserializeMetadata(output),
  16216. contentType: undefined,
  16217. description: undefined,
  16218. id: undefined,
  16219. name: undefined,
  16220. schema: undefined,
  16221. };
  16222. const data: any = await parseBody(output.body, context);
  16223. if (data.contentType !== undefined && data.contentType !== null) {
  16224. contents.contentType = data.contentType;
  16225. }
  16226. if (data.description !== undefined && data.description !== null) {
  16227. contents.description = data.description;
  16228. }
  16229. if (data.id !== undefined && data.id !== null) {
  16230. contents.id = data.id;
  16231. }
  16232. if (data.name !== undefined && data.name !== null) {
  16233. contents.name = data.name;
  16234. }
  16235. if (data.schema !== undefined && data.schema !== null) {
  16236. contents.schema = data.schema;
  16237. }
  16238. return Promise.resolve(contents);
  16239. };
  16240. const deserializeAws_restJson1UpdateModelCommandError = async (
  16241. output: __HttpResponse,
  16242. context: __SerdeContext
  16243. ): Promise<UpdateModelCommandOutput> => {
  16244. const parsedOutput: any = {
  16245. ...output,
  16246. body: await parseBody(output.body, context),
  16247. };
  16248. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16249. let errorCode: string = "UnknownError";
  16250. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16251. switch (errorCode) {
  16252. case "BadRequestException":
  16253. case "com.amazonaws.apigateway#BadRequestException":
  16254. response = {
  16255. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16256. name: errorCode,
  16257. $metadata: deserializeMetadata(output),
  16258. };
  16259. break;
  16260. case "ConflictException":
  16261. case "com.amazonaws.apigateway#ConflictException":
  16262. response = {
  16263. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16264. name: errorCode,
  16265. $metadata: deserializeMetadata(output),
  16266. };
  16267. break;
  16268. case "NotFoundException":
  16269. case "com.amazonaws.apigateway#NotFoundException":
  16270. response = {
  16271. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16272. name: errorCode,
  16273. $metadata: deserializeMetadata(output),
  16274. };
  16275. break;
  16276. case "TooManyRequestsException":
  16277. case "com.amazonaws.apigateway#TooManyRequestsException":
  16278. response = {
  16279. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16280. name: errorCode,
  16281. $metadata: deserializeMetadata(output),
  16282. };
  16283. break;
  16284. case "UnauthorizedException":
  16285. case "com.amazonaws.apigateway#UnauthorizedException":
  16286. response = {
  16287. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16288. name: errorCode,
  16289. $metadata: deserializeMetadata(output),
  16290. };
  16291. break;
  16292. default:
  16293. const parsedBody = parsedOutput.body;
  16294. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16295. response = {
  16296. ...parsedBody,
  16297. name: `${errorCode}`,
  16298. message: parsedBody.message || parsedBody.Message || errorCode,
  16299. $fault: "client",
  16300. $metadata: deserializeMetadata(output),
  16301. } as any;
  16302. }
  16303. const message = response.message || response.Message || errorCode;
  16304. response.message = message;
  16305. delete response.Message;
  16306. return Promise.reject(Object.assign(new Error(message), response));
  16307. };
  16308. export const deserializeAws_restJson1UpdateRequestValidatorCommand = async (
  16309. output: __HttpResponse,
  16310. context: __SerdeContext
  16311. ): Promise<UpdateRequestValidatorCommandOutput> => {
  16312. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16313. return deserializeAws_restJson1UpdateRequestValidatorCommandError(output, context);
  16314. }
  16315. const contents: UpdateRequestValidatorCommandOutput = {
  16316. $metadata: deserializeMetadata(output),
  16317. id: undefined,
  16318. name: undefined,
  16319. validateRequestBody: undefined,
  16320. validateRequestParameters: undefined,
  16321. };
  16322. const data: any = await parseBody(output.body, context);
  16323. if (data.id !== undefined && data.id !== null) {
  16324. contents.id = data.id;
  16325. }
  16326. if (data.name !== undefined && data.name !== null) {
  16327. contents.name = data.name;
  16328. }
  16329. if (data.validateRequestBody !== undefined && data.validateRequestBody !== null) {
  16330. contents.validateRequestBody = data.validateRequestBody;
  16331. }
  16332. if (data.validateRequestParameters !== undefined && data.validateRequestParameters !== null) {
  16333. contents.validateRequestParameters = data.validateRequestParameters;
  16334. }
  16335. return Promise.resolve(contents);
  16336. };
  16337. const deserializeAws_restJson1UpdateRequestValidatorCommandError = async (
  16338. output: __HttpResponse,
  16339. context: __SerdeContext
  16340. ): Promise<UpdateRequestValidatorCommandOutput> => {
  16341. const parsedOutput: any = {
  16342. ...output,
  16343. body: await parseBody(output.body, context),
  16344. };
  16345. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16346. let errorCode: string = "UnknownError";
  16347. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16348. switch (errorCode) {
  16349. case "BadRequestException":
  16350. case "com.amazonaws.apigateway#BadRequestException":
  16351. response = {
  16352. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16353. name: errorCode,
  16354. $metadata: deserializeMetadata(output),
  16355. };
  16356. break;
  16357. case "NotFoundException":
  16358. case "com.amazonaws.apigateway#NotFoundException":
  16359. response = {
  16360. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16361. name: errorCode,
  16362. $metadata: deserializeMetadata(output),
  16363. };
  16364. break;
  16365. case "TooManyRequestsException":
  16366. case "com.amazonaws.apigateway#TooManyRequestsException":
  16367. response = {
  16368. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16369. name: errorCode,
  16370. $metadata: deserializeMetadata(output),
  16371. };
  16372. break;
  16373. case "UnauthorizedException":
  16374. case "com.amazonaws.apigateway#UnauthorizedException":
  16375. response = {
  16376. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16377. name: errorCode,
  16378. $metadata: deserializeMetadata(output),
  16379. };
  16380. break;
  16381. default:
  16382. const parsedBody = parsedOutput.body;
  16383. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16384. response = {
  16385. ...parsedBody,
  16386. name: `${errorCode}`,
  16387. message: parsedBody.message || parsedBody.Message || errorCode,
  16388. $fault: "client",
  16389. $metadata: deserializeMetadata(output),
  16390. } as any;
  16391. }
  16392. const message = response.message || response.Message || errorCode;
  16393. response.message = message;
  16394. delete response.Message;
  16395. return Promise.reject(Object.assign(new Error(message), response));
  16396. };
  16397. export const deserializeAws_restJson1UpdateResourceCommand = async (
  16398. output: __HttpResponse,
  16399. context: __SerdeContext
  16400. ): Promise<UpdateResourceCommandOutput> => {
  16401. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16402. return deserializeAws_restJson1UpdateResourceCommandError(output, context);
  16403. }
  16404. const contents: UpdateResourceCommandOutput = {
  16405. $metadata: deserializeMetadata(output),
  16406. id: undefined,
  16407. parentId: undefined,
  16408. path: undefined,
  16409. pathPart: undefined,
  16410. resourceMethods: undefined,
  16411. };
  16412. const data: any = await parseBody(output.body, context);
  16413. if (data.id !== undefined && data.id !== null) {
  16414. contents.id = data.id;
  16415. }
  16416. if (data.parentId !== undefined && data.parentId !== null) {
  16417. contents.parentId = data.parentId;
  16418. }
  16419. if (data.path !== undefined && data.path !== null) {
  16420. contents.path = data.path;
  16421. }
  16422. if (data.pathPart !== undefined && data.pathPart !== null) {
  16423. contents.pathPart = data.pathPart;
  16424. }
  16425. if (data.resourceMethods !== undefined && data.resourceMethods !== null) {
  16426. contents.resourceMethods = deserializeAws_restJson1MapOfMethod(data.resourceMethods, context);
  16427. }
  16428. return Promise.resolve(contents);
  16429. };
  16430. const deserializeAws_restJson1UpdateResourceCommandError = async (
  16431. output: __HttpResponse,
  16432. context: __SerdeContext
  16433. ): Promise<UpdateResourceCommandOutput> => {
  16434. const parsedOutput: any = {
  16435. ...output,
  16436. body: await parseBody(output.body, context),
  16437. };
  16438. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16439. let errorCode: string = "UnknownError";
  16440. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16441. switch (errorCode) {
  16442. case "BadRequestException":
  16443. case "com.amazonaws.apigateway#BadRequestException":
  16444. response = {
  16445. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16446. name: errorCode,
  16447. $metadata: deserializeMetadata(output),
  16448. };
  16449. break;
  16450. case "ConflictException":
  16451. case "com.amazonaws.apigateway#ConflictException":
  16452. response = {
  16453. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16454. name: errorCode,
  16455. $metadata: deserializeMetadata(output),
  16456. };
  16457. break;
  16458. case "NotFoundException":
  16459. case "com.amazonaws.apigateway#NotFoundException":
  16460. response = {
  16461. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16462. name: errorCode,
  16463. $metadata: deserializeMetadata(output),
  16464. };
  16465. break;
  16466. case "TooManyRequestsException":
  16467. case "com.amazonaws.apigateway#TooManyRequestsException":
  16468. response = {
  16469. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16470. name: errorCode,
  16471. $metadata: deserializeMetadata(output),
  16472. };
  16473. break;
  16474. case "UnauthorizedException":
  16475. case "com.amazonaws.apigateway#UnauthorizedException":
  16476. response = {
  16477. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16478. name: errorCode,
  16479. $metadata: deserializeMetadata(output),
  16480. };
  16481. break;
  16482. default:
  16483. const parsedBody = parsedOutput.body;
  16484. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16485. response = {
  16486. ...parsedBody,
  16487. name: `${errorCode}`,
  16488. message: parsedBody.message || parsedBody.Message || errorCode,
  16489. $fault: "client",
  16490. $metadata: deserializeMetadata(output),
  16491. } as any;
  16492. }
  16493. const message = response.message || response.Message || errorCode;
  16494. response.message = message;
  16495. delete response.Message;
  16496. return Promise.reject(Object.assign(new Error(message), response));
  16497. };
  16498. export const deserializeAws_restJson1UpdateRestApiCommand = async (
  16499. output: __HttpResponse,
  16500. context: __SerdeContext
  16501. ): Promise<UpdateRestApiCommandOutput> => {
  16502. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16503. return deserializeAws_restJson1UpdateRestApiCommandError(output, context);
  16504. }
  16505. const contents: UpdateRestApiCommandOutput = {
  16506. $metadata: deserializeMetadata(output),
  16507. apiKeySource: undefined,
  16508. binaryMediaTypes: undefined,
  16509. createdDate: undefined,
  16510. description: undefined,
  16511. endpointConfiguration: undefined,
  16512. id: undefined,
  16513. minimumCompressionSize: undefined,
  16514. name: undefined,
  16515. policy: undefined,
  16516. tags: undefined,
  16517. version: undefined,
  16518. warnings: undefined,
  16519. };
  16520. const data: any = await parseBody(output.body, context);
  16521. if (data.apiKeySource !== undefined && data.apiKeySource !== null) {
  16522. contents.apiKeySource = data.apiKeySource;
  16523. }
  16524. if (data.binaryMediaTypes !== undefined && data.binaryMediaTypes !== null) {
  16525. contents.binaryMediaTypes = deserializeAws_restJson1ListOfString(data.binaryMediaTypes, context);
  16526. }
  16527. if (data.createdDate !== undefined && data.createdDate !== null) {
  16528. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  16529. }
  16530. if (data.description !== undefined && data.description !== null) {
  16531. contents.description = data.description;
  16532. }
  16533. if (data.endpointConfiguration !== undefined && data.endpointConfiguration !== null) {
  16534. contents.endpointConfiguration = deserializeAws_restJson1EndpointConfiguration(data.endpointConfiguration, context);
  16535. }
  16536. if (data.id !== undefined && data.id !== null) {
  16537. contents.id = data.id;
  16538. }
  16539. if (data.minimumCompressionSize !== undefined && data.minimumCompressionSize !== null) {
  16540. contents.minimumCompressionSize = data.minimumCompressionSize;
  16541. }
  16542. if (data.name !== undefined && data.name !== null) {
  16543. contents.name = data.name;
  16544. }
  16545. if (data.policy !== undefined && data.policy !== null) {
  16546. contents.policy = data.policy;
  16547. }
  16548. if (data.tags !== undefined && data.tags !== null) {
  16549. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  16550. }
  16551. if (data.version !== undefined && data.version !== null) {
  16552. contents.version = data.version;
  16553. }
  16554. if (data.warnings !== undefined && data.warnings !== null) {
  16555. contents.warnings = deserializeAws_restJson1ListOfString(data.warnings, context);
  16556. }
  16557. return Promise.resolve(contents);
  16558. };
  16559. const deserializeAws_restJson1UpdateRestApiCommandError = async (
  16560. output: __HttpResponse,
  16561. context: __SerdeContext
  16562. ): Promise<UpdateRestApiCommandOutput> => {
  16563. const parsedOutput: any = {
  16564. ...output,
  16565. body: await parseBody(output.body, context),
  16566. };
  16567. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16568. let errorCode: string = "UnknownError";
  16569. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16570. switch (errorCode) {
  16571. case "BadRequestException":
  16572. case "com.amazonaws.apigateway#BadRequestException":
  16573. response = {
  16574. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16575. name: errorCode,
  16576. $metadata: deserializeMetadata(output),
  16577. };
  16578. break;
  16579. case "ConflictException":
  16580. case "com.amazonaws.apigateway#ConflictException":
  16581. response = {
  16582. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16583. name: errorCode,
  16584. $metadata: deserializeMetadata(output),
  16585. };
  16586. break;
  16587. case "NotFoundException":
  16588. case "com.amazonaws.apigateway#NotFoundException":
  16589. response = {
  16590. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16591. name: errorCode,
  16592. $metadata: deserializeMetadata(output),
  16593. };
  16594. break;
  16595. case "TooManyRequestsException":
  16596. case "com.amazonaws.apigateway#TooManyRequestsException":
  16597. response = {
  16598. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16599. name: errorCode,
  16600. $metadata: deserializeMetadata(output),
  16601. };
  16602. break;
  16603. case "UnauthorizedException":
  16604. case "com.amazonaws.apigateway#UnauthorizedException":
  16605. response = {
  16606. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16607. name: errorCode,
  16608. $metadata: deserializeMetadata(output),
  16609. };
  16610. break;
  16611. default:
  16612. const parsedBody = parsedOutput.body;
  16613. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16614. response = {
  16615. ...parsedBody,
  16616. name: `${errorCode}`,
  16617. message: parsedBody.message || parsedBody.Message || errorCode,
  16618. $fault: "client",
  16619. $metadata: deserializeMetadata(output),
  16620. } as any;
  16621. }
  16622. const message = response.message || response.Message || errorCode;
  16623. response.message = message;
  16624. delete response.Message;
  16625. return Promise.reject(Object.assign(new Error(message), response));
  16626. };
  16627. export const deserializeAws_restJson1UpdateStageCommand = async (
  16628. output: __HttpResponse,
  16629. context: __SerdeContext
  16630. ): Promise<UpdateStageCommandOutput> => {
  16631. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16632. return deserializeAws_restJson1UpdateStageCommandError(output, context);
  16633. }
  16634. const contents: UpdateStageCommandOutput = {
  16635. $metadata: deserializeMetadata(output),
  16636. accessLogSettings: undefined,
  16637. cacheClusterEnabled: undefined,
  16638. cacheClusterSize: undefined,
  16639. cacheClusterStatus: undefined,
  16640. canarySettings: undefined,
  16641. clientCertificateId: undefined,
  16642. createdDate: undefined,
  16643. deploymentId: undefined,
  16644. description: undefined,
  16645. documentationVersion: undefined,
  16646. lastUpdatedDate: undefined,
  16647. methodSettings: undefined,
  16648. stageName: undefined,
  16649. tags: undefined,
  16650. tracingEnabled: undefined,
  16651. variables: undefined,
  16652. webAclArn: undefined,
  16653. };
  16654. const data: any = await parseBody(output.body, context);
  16655. if (data.accessLogSettings !== undefined && data.accessLogSettings !== null) {
  16656. contents.accessLogSettings = deserializeAws_restJson1AccessLogSettings(data.accessLogSettings, context);
  16657. }
  16658. if (data.cacheClusterEnabled !== undefined && data.cacheClusterEnabled !== null) {
  16659. contents.cacheClusterEnabled = data.cacheClusterEnabled;
  16660. }
  16661. if (data.cacheClusterSize !== undefined && data.cacheClusterSize !== null) {
  16662. contents.cacheClusterSize = data.cacheClusterSize;
  16663. }
  16664. if (data.cacheClusterStatus !== undefined && data.cacheClusterStatus !== null) {
  16665. contents.cacheClusterStatus = data.cacheClusterStatus;
  16666. }
  16667. if (data.canarySettings !== undefined && data.canarySettings !== null) {
  16668. contents.canarySettings = deserializeAws_restJson1CanarySettings(data.canarySettings, context);
  16669. }
  16670. if (data.clientCertificateId !== undefined && data.clientCertificateId !== null) {
  16671. contents.clientCertificateId = data.clientCertificateId;
  16672. }
  16673. if (data.createdDate !== undefined && data.createdDate !== null) {
  16674. contents.createdDate = new Date(Math.round(data.createdDate * 1000));
  16675. }
  16676. if (data.deploymentId !== undefined && data.deploymentId !== null) {
  16677. contents.deploymentId = data.deploymentId;
  16678. }
  16679. if (data.description !== undefined && data.description !== null) {
  16680. contents.description = data.description;
  16681. }
  16682. if (data.documentationVersion !== undefined && data.documentationVersion !== null) {
  16683. contents.documentationVersion = data.documentationVersion;
  16684. }
  16685. if (data.lastUpdatedDate !== undefined && data.lastUpdatedDate !== null) {
  16686. contents.lastUpdatedDate = new Date(Math.round(data.lastUpdatedDate * 1000));
  16687. }
  16688. if (data.methodSettings !== undefined && data.methodSettings !== null) {
  16689. contents.methodSettings = deserializeAws_restJson1MapOfMethodSettings(data.methodSettings, context);
  16690. }
  16691. if (data.stageName !== undefined && data.stageName !== null) {
  16692. contents.stageName = data.stageName;
  16693. }
  16694. if (data.tags !== undefined && data.tags !== null) {
  16695. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  16696. }
  16697. if (data.tracingEnabled !== undefined && data.tracingEnabled !== null) {
  16698. contents.tracingEnabled = data.tracingEnabled;
  16699. }
  16700. if (data.variables !== undefined && data.variables !== null) {
  16701. contents.variables = deserializeAws_restJson1MapOfStringToString(data.variables, context);
  16702. }
  16703. if (data.webAclArn !== undefined && data.webAclArn !== null) {
  16704. contents.webAclArn = data.webAclArn;
  16705. }
  16706. return Promise.resolve(contents);
  16707. };
  16708. const deserializeAws_restJson1UpdateStageCommandError = async (
  16709. output: __HttpResponse,
  16710. context: __SerdeContext
  16711. ): Promise<UpdateStageCommandOutput> => {
  16712. const parsedOutput: any = {
  16713. ...output,
  16714. body: await parseBody(output.body, context),
  16715. };
  16716. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16717. let errorCode: string = "UnknownError";
  16718. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16719. switch (errorCode) {
  16720. case "BadRequestException":
  16721. case "com.amazonaws.apigateway#BadRequestException":
  16722. response = {
  16723. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16724. name: errorCode,
  16725. $metadata: deserializeMetadata(output),
  16726. };
  16727. break;
  16728. case "ConflictException":
  16729. case "com.amazonaws.apigateway#ConflictException":
  16730. response = {
  16731. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16732. name: errorCode,
  16733. $metadata: deserializeMetadata(output),
  16734. };
  16735. break;
  16736. case "NotFoundException":
  16737. case "com.amazonaws.apigateway#NotFoundException":
  16738. response = {
  16739. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16740. name: errorCode,
  16741. $metadata: deserializeMetadata(output),
  16742. };
  16743. break;
  16744. case "TooManyRequestsException":
  16745. case "com.amazonaws.apigateway#TooManyRequestsException":
  16746. response = {
  16747. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16748. name: errorCode,
  16749. $metadata: deserializeMetadata(output),
  16750. };
  16751. break;
  16752. case "UnauthorizedException":
  16753. case "com.amazonaws.apigateway#UnauthorizedException":
  16754. response = {
  16755. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16756. name: errorCode,
  16757. $metadata: deserializeMetadata(output),
  16758. };
  16759. break;
  16760. default:
  16761. const parsedBody = parsedOutput.body;
  16762. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16763. response = {
  16764. ...parsedBody,
  16765. name: `${errorCode}`,
  16766. message: parsedBody.message || parsedBody.Message || errorCode,
  16767. $fault: "client",
  16768. $metadata: deserializeMetadata(output),
  16769. } as any;
  16770. }
  16771. const message = response.message || response.Message || errorCode;
  16772. response.message = message;
  16773. delete response.Message;
  16774. return Promise.reject(Object.assign(new Error(message), response));
  16775. };
  16776. export const deserializeAws_restJson1UpdateUsageCommand = async (
  16777. output: __HttpResponse,
  16778. context: __SerdeContext
  16779. ): Promise<UpdateUsageCommandOutput> => {
  16780. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16781. return deserializeAws_restJson1UpdateUsageCommandError(output, context);
  16782. }
  16783. const contents: UpdateUsageCommandOutput = {
  16784. $metadata: deserializeMetadata(output),
  16785. endDate: undefined,
  16786. items: undefined,
  16787. position: undefined,
  16788. startDate: undefined,
  16789. usagePlanId: undefined,
  16790. };
  16791. const data: any = await parseBody(output.body, context);
  16792. if (data.endDate !== undefined && data.endDate !== null) {
  16793. contents.endDate = data.endDate;
  16794. }
  16795. if (data.values !== undefined && data.values !== null) {
  16796. contents.items = deserializeAws_restJson1MapOfKeyUsages(data.values, context);
  16797. }
  16798. if (data.position !== undefined && data.position !== null) {
  16799. contents.position = data.position;
  16800. }
  16801. if (data.startDate !== undefined && data.startDate !== null) {
  16802. contents.startDate = data.startDate;
  16803. }
  16804. if (data.usagePlanId !== undefined && data.usagePlanId !== null) {
  16805. contents.usagePlanId = data.usagePlanId;
  16806. }
  16807. return Promise.resolve(contents);
  16808. };
  16809. const deserializeAws_restJson1UpdateUsageCommandError = async (
  16810. output: __HttpResponse,
  16811. context: __SerdeContext
  16812. ): Promise<UpdateUsageCommandOutput> => {
  16813. const parsedOutput: any = {
  16814. ...output,
  16815. body: await parseBody(output.body, context),
  16816. };
  16817. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16818. let errorCode: string = "UnknownError";
  16819. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16820. switch (errorCode) {
  16821. case "BadRequestException":
  16822. case "com.amazonaws.apigateway#BadRequestException":
  16823. response = {
  16824. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16825. name: errorCode,
  16826. $metadata: deserializeMetadata(output),
  16827. };
  16828. break;
  16829. case "NotFoundException":
  16830. case "com.amazonaws.apigateway#NotFoundException":
  16831. response = {
  16832. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16833. name: errorCode,
  16834. $metadata: deserializeMetadata(output),
  16835. };
  16836. break;
  16837. case "TooManyRequestsException":
  16838. case "com.amazonaws.apigateway#TooManyRequestsException":
  16839. response = {
  16840. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16841. name: errorCode,
  16842. $metadata: deserializeMetadata(output),
  16843. };
  16844. break;
  16845. case "UnauthorizedException":
  16846. case "com.amazonaws.apigateway#UnauthorizedException":
  16847. response = {
  16848. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16849. name: errorCode,
  16850. $metadata: deserializeMetadata(output),
  16851. };
  16852. break;
  16853. default:
  16854. const parsedBody = parsedOutput.body;
  16855. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16856. response = {
  16857. ...parsedBody,
  16858. name: `${errorCode}`,
  16859. message: parsedBody.message || parsedBody.Message || errorCode,
  16860. $fault: "client",
  16861. $metadata: deserializeMetadata(output),
  16862. } as any;
  16863. }
  16864. const message = response.message || response.Message || errorCode;
  16865. response.message = message;
  16866. delete response.Message;
  16867. return Promise.reject(Object.assign(new Error(message), response));
  16868. };
  16869. export const deserializeAws_restJson1UpdateUsagePlanCommand = async (
  16870. output: __HttpResponse,
  16871. context: __SerdeContext
  16872. ): Promise<UpdateUsagePlanCommandOutput> => {
  16873. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16874. return deserializeAws_restJson1UpdateUsagePlanCommandError(output, context);
  16875. }
  16876. const contents: UpdateUsagePlanCommandOutput = {
  16877. $metadata: deserializeMetadata(output),
  16878. apiStages: undefined,
  16879. description: undefined,
  16880. id: undefined,
  16881. name: undefined,
  16882. productCode: undefined,
  16883. quota: undefined,
  16884. tags: undefined,
  16885. throttle: undefined,
  16886. };
  16887. const data: any = await parseBody(output.body, context);
  16888. if (data.apiStages !== undefined && data.apiStages !== null) {
  16889. contents.apiStages = deserializeAws_restJson1ListOfApiStage(data.apiStages, context);
  16890. }
  16891. if (data.description !== undefined && data.description !== null) {
  16892. contents.description = data.description;
  16893. }
  16894. if (data.id !== undefined && data.id !== null) {
  16895. contents.id = data.id;
  16896. }
  16897. if (data.name !== undefined && data.name !== null) {
  16898. contents.name = data.name;
  16899. }
  16900. if (data.productCode !== undefined && data.productCode !== null) {
  16901. contents.productCode = data.productCode;
  16902. }
  16903. if (data.quota !== undefined && data.quota !== null) {
  16904. contents.quota = deserializeAws_restJson1QuotaSettings(data.quota, context);
  16905. }
  16906. if (data.tags !== undefined && data.tags !== null) {
  16907. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  16908. }
  16909. if (data.throttle !== undefined && data.throttle !== null) {
  16910. contents.throttle = deserializeAws_restJson1ThrottleSettings(data.throttle, context);
  16911. }
  16912. return Promise.resolve(contents);
  16913. };
  16914. const deserializeAws_restJson1UpdateUsagePlanCommandError = async (
  16915. output: __HttpResponse,
  16916. context: __SerdeContext
  16917. ): Promise<UpdateUsagePlanCommandOutput> => {
  16918. const parsedOutput: any = {
  16919. ...output,
  16920. body: await parseBody(output.body, context),
  16921. };
  16922. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  16923. let errorCode: string = "UnknownError";
  16924. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  16925. switch (errorCode) {
  16926. case "BadRequestException":
  16927. case "com.amazonaws.apigateway#BadRequestException":
  16928. response = {
  16929. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  16930. name: errorCode,
  16931. $metadata: deserializeMetadata(output),
  16932. };
  16933. break;
  16934. case "ConflictException":
  16935. case "com.amazonaws.apigateway#ConflictException":
  16936. response = {
  16937. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  16938. name: errorCode,
  16939. $metadata: deserializeMetadata(output),
  16940. };
  16941. break;
  16942. case "NotFoundException":
  16943. case "com.amazonaws.apigateway#NotFoundException":
  16944. response = {
  16945. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  16946. name: errorCode,
  16947. $metadata: deserializeMetadata(output),
  16948. };
  16949. break;
  16950. case "TooManyRequestsException":
  16951. case "com.amazonaws.apigateway#TooManyRequestsException":
  16952. response = {
  16953. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  16954. name: errorCode,
  16955. $metadata: deserializeMetadata(output),
  16956. };
  16957. break;
  16958. case "UnauthorizedException":
  16959. case "com.amazonaws.apigateway#UnauthorizedException":
  16960. response = {
  16961. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  16962. name: errorCode,
  16963. $metadata: deserializeMetadata(output),
  16964. };
  16965. break;
  16966. default:
  16967. const parsedBody = parsedOutput.body;
  16968. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  16969. response = {
  16970. ...parsedBody,
  16971. name: `${errorCode}`,
  16972. message: parsedBody.message || parsedBody.Message || errorCode,
  16973. $fault: "client",
  16974. $metadata: deserializeMetadata(output),
  16975. } as any;
  16976. }
  16977. const message = response.message || response.Message || errorCode;
  16978. response.message = message;
  16979. delete response.Message;
  16980. return Promise.reject(Object.assign(new Error(message), response));
  16981. };
  16982. export const deserializeAws_restJson1UpdateVpcLinkCommand = async (
  16983. output: __HttpResponse,
  16984. context: __SerdeContext
  16985. ): Promise<UpdateVpcLinkCommandOutput> => {
  16986. if (output.statusCode !== 200 && output.statusCode >= 400) {
  16987. return deserializeAws_restJson1UpdateVpcLinkCommandError(output, context);
  16988. }
  16989. const contents: UpdateVpcLinkCommandOutput = {
  16990. $metadata: deserializeMetadata(output),
  16991. description: undefined,
  16992. id: undefined,
  16993. name: undefined,
  16994. status: undefined,
  16995. statusMessage: undefined,
  16996. tags: undefined,
  16997. targetArns: undefined,
  16998. };
  16999. const data: any = await parseBody(output.body, context);
  17000. if (data.description !== undefined && data.description !== null) {
  17001. contents.description = data.description;
  17002. }
  17003. if (data.id !== undefined && data.id !== null) {
  17004. contents.id = data.id;
  17005. }
  17006. if (data.name !== undefined && data.name !== null) {
  17007. contents.name = data.name;
  17008. }
  17009. if (data.status !== undefined && data.status !== null) {
  17010. contents.status = data.status;
  17011. }
  17012. if (data.statusMessage !== undefined && data.statusMessage !== null) {
  17013. contents.statusMessage = data.statusMessage;
  17014. }
  17015. if (data.tags !== undefined && data.tags !== null) {
  17016. contents.tags = deserializeAws_restJson1MapOfStringToString(data.tags, context);
  17017. }
  17018. if (data.targetArns !== undefined && data.targetArns !== null) {
  17019. contents.targetArns = deserializeAws_restJson1ListOfString(data.targetArns, context);
  17020. }
  17021. return Promise.resolve(contents);
  17022. };
  17023. const deserializeAws_restJson1UpdateVpcLinkCommandError = async (
  17024. output: __HttpResponse,
  17025. context: __SerdeContext
  17026. ): Promise<UpdateVpcLinkCommandOutput> => {
  17027. const parsedOutput: any = {
  17028. ...output,
  17029. body: await parseBody(output.body, context),
  17030. };
  17031. let response: __SmithyException & __MetadataBearer & { [key: string]: any };
  17032. let errorCode: string = "UnknownError";
  17033. errorCode = loadRestJsonErrorCode(output, parsedOutput.body);
  17034. switch (errorCode) {
  17035. case "BadRequestException":
  17036. case "com.amazonaws.apigateway#BadRequestException":
  17037. response = {
  17038. ...(await deserializeAws_restJson1BadRequestExceptionResponse(parsedOutput, context)),
  17039. name: errorCode,
  17040. $metadata: deserializeMetadata(output),
  17041. };
  17042. break;
  17043. case "ConflictException":
  17044. case "com.amazonaws.apigateway#ConflictException":
  17045. response = {
  17046. ...(await deserializeAws_restJson1ConflictExceptionResponse(parsedOutput, context)),
  17047. name: errorCode,
  17048. $metadata: deserializeMetadata(output),
  17049. };
  17050. break;
  17051. case "NotFoundException":
  17052. case "com.amazonaws.apigateway#NotFoundException":
  17053. response = {
  17054. ...(await deserializeAws_restJson1NotFoundExceptionResponse(parsedOutput, context)),
  17055. name: errorCode,
  17056. $metadata: deserializeMetadata(output),
  17057. };
  17058. break;
  17059. case "TooManyRequestsException":
  17060. case "com.amazonaws.apigateway#TooManyRequestsException":
  17061. response = {
  17062. ...(await deserializeAws_restJson1TooManyRequestsExceptionResponse(parsedOutput, context)),
  17063. name: errorCode,
  17064. $metadata: deserializeMetadata(output),
  17065. };
  17066. break;
  17067. case "UnauthorizedException":
  17068. case "com.amazonaws.apigateway#UnauthorizedException":
  17069. response = {
  17070. ...(await deserializeAws_restJson1UnauthorizedExceptionResponse(parsedOutput, context)),
  17071. name: errorCode,
  17072. $metadata: deserializeMetadata(output),
  17073. };
  17074. break;
  17075. default:
  17076. const parsedBody = parsedOutput.body;
  17077. errorCode = parsedBody.code || parsedBody.Code || errorCode;
  17078. response = {
  17079. ...parsedBody,
  17080. name: `${errorCode}`,
  17081. message: parsedBody.message || parsedBody.Message || errorCode,
  17082. $fault: "client",
  17083. $metadata: deserializeMetadata(output),
  17084. } as any;
  17085. }
  17086. const message = response.message || response.Message || errorCode;
  17087. response.message = message;
  17088. delete response.Message;
  17089. return Promise.reject(Object.assign(new Error(message), response));
  17090. };
  17091. const deserializeAws_restJson1BadRequestExceptionResponse = async (
  17092. parsedOutput: any,
  17093. context: __SerdeContext
  17094. ): Promise<BadRequestException> => {
  17095. const contents: BadRequestException = {
  17096. name: "BadRequestException",
  17097. $fault: "client",
  17098. $metadata: deserializeMetadata(parsedOutput),
  17099. message: undefined,
  17100. };
  17101. const data: any = parsedOutput.body;
  17102. if (data.message !== undefined && data.message !== null) {
  17103. contents.message = data.message;
  17104. }
  17105. return contents;
  17106. };
  17107. const deserializeAws_restJson1ConflictExceptionResponse = async (
  17108. parsedOutput: any,
  17109. context: __SerdeContext
  17110. ): Promise<ConflictException> => {
  17111. const contents: ConflictException = {
  17112. name: "ConflictException",
  17113. $fault: "client",
  17114. $metadata: deserializeMetadata(parsedOutput),
  17115. message: undefined,
  17116. };
  17117. const data: any = parsedOutput.body;
  17118. if (data.message !== undefined && data.message !== null) {
  17119. contents.message = data.message;
  17120. }
  17121. return contents;
  17122. };
  17123. const deserializeAws_restJson1LimitExceededExceptionResponse = async (
  17124. parsedOutput: any,
  17125. context: __SerdeContext
  17126. ): Promise<LimitExceededException> => {
  17127. const contents: LimitExceededException = {
  17128. name: "LimitExceededException",
  17129. $fault: "client",
  17130. $metadata: deserializeMetadata(parsedOutput),
  17131. message: undefined,
  17132. retryAfterSeconds: undefined,
  17133. };
  17134. if (parsedOutput.headers["retry-after"] !== undefined) {
  17135. contents.retryAfterSeconds = parsedOutput.headers["retry-after"];
  17136. }
  17137. const data: any = parsedOutput.body;
  17138. if (data.message !== undefined && data.message !== null) {
  17139. contents.message = data.message;
  17140. }
  17141. return contents;
  17142. };
  17143. const deserializeAws_restJson1NotFoundExceptionResponse = async (
  17144. parsedOutput: any,
  17145. context: __SerdeContext
  17146. ): Promise<NotFoundException> => {
  17147. const contents: NotFoundException = {
  17148. name: "NotFoundException",
  17149. $fault: "client",
  17150. $metadata: deserializeMetadata(parsedOutput),
  17151. message: undefined,
  17152. };
  17153. const data: any = parsedOutput.body;
  17154. if (data.message !== undefined && data.message !== null) {
  17155. contents.message = data.message;
  17156. }
  17157. return contents;
  17158. };
  17159. const deserializeAws_restJson1ServiceUnavailableExceptionResponse = async (
  17160. parsedOutput: any,
  17161. context: __SerdeContext
  17162. ): Promise<ServiceUnavailableException> => {
  17163. const contents: ServiceUnavailableException = {
  17164. name: "ServiceUnavailableException",
  17165. $fault: "server",
  17166. $metadata: deserializeMetadata(parsedOutput),
  17167. message: undefined,
  17168. retryAfterSeconds: undefined,
  17169. };
  17170. if (parsedOutput.headers["retry-after"] !== undefined) {
  17171. contents.retryAfterSeconds = parsedOutput.headers["retry-after"];
  17172. }
  17173. const data: any = parsedOutput.body;
  17174. if (data.message !== undefined && data.message !== null) {
  17175. contents.message = data.message;
  17176. }
  17177. return contents;
  17178. };
  17179. const deserializeAws_restJson1TooManyRequestsExceptionResponse = async (
  17180. parsedOutput: any,
  17181. context: __SerdeContext
  17182. ): Promise<TooManyRequestsException> => {
  17183. const contents: TooManyRequestsException = {
  17184. name: "TooManyRequestsException",
  17185. $fault: "client",
  17186. $metadata: deserializeMetadata(parsedOutput),
  17187. message: undefined,
  17188. retryAfterSeconds: undefined,
  17189. };
  17190. if (parsedOutput.headers["retry-after"] !== undefined) {
  17191. contents.retryAfterSeconds = parsedOutput.headers["retry-after"];
  17192. }
  17193. const data: any = parsedOutput.body;
  17194. if (data.message !== undefined && data.message !== null) {
  17195. contents.message = data.message;
  17196. }
  17197. return contents;
  17198. };
  17199. const deserializeAws_restJson1UnauthorizedExceptionResponse = async (
  17200. parsedOutput: any,
  17201. context: __SerdeContext
  17202. ): Promise<UnauthorizedException> => {
  17203. const contents: UnauthorizedException = {
  17204. name: "UnauthorizedException",
  17205. $fault: "client",
  17206. $metadata: deserializeMetadata(parsedOutput),
  17207. message: undefined,
  17208. };
  17209. const data: any = parsedOutput.body;
  17210. if (data.message !== undefined && data.message !== null) {
  17211. contents.message = data.message;
  17212. }
  17213. return contents;
  17214. };
  17215. const serializeAws_restJson1ApiStage = (input: ApiStage, context: __SerdeContext): any => {
  17216. return {
  17217. ...(input.apiId !== undefined && { apiId: input.apiId }),
  17218. ...(input.stage !== undefined && { stage: input.stage }),
  17219. ...(input.throttle !== undefined && {
  17220. throttle: serializeAws_restJson1MapOfApiStageThrottleSettings(input.throttle, context),
  17221. }),
  17222. };
  17223. };
  17224. const serializeAws_restJson1CanarySettings = (input: CanarySettings, context: __SerdeContext): any => {
  17225. return {
  17226. ...(input.deploymentId !== undefined && { deploymentId: input.deploymentId }),
  17227. ...(input.percentTraffic !== undefined && { percentTraffic: input.percentTraffic }),
  17228. ...(input.stageVariableOverrides !== undefined && {
  17229. stageVariableOverrides: serializeAws_restJson1MapOfStringToString(input.stageVariableOverrides, context),
  17230. }),
  17231. ...(input.useStageCache !== undefined && { useStageCache: input.useStageCache }),
  17232. };
  17233. };
  17234. const serializeAws_restJson1DeploymentCanarySettings = (
  17235. input: DeploymentCanarySettings,
  17236. context: __SerdeContext
  17237. ): any => {
  17238. return {
  17239. ...(input.percentTraffic !== undefined && { percentTraffic: input.percentTraffic }),
  17240. ...(input.stageVariableOverrides !== undefined && {
  17241. stageVariableOverrides: serializeAws_restJson1MapOfStringToString(input.stageVariableOverrides, context),
  17242. }),
  17243. ...(input.useStageCache !== undefined && { useStageCache: input.useStageCache }),
  17244. };
  17245. };
  17246. const serializeAws_restJson1DocumentationPartLocation = (
  17247. input: DocumentationPartLocation,
  17248. context: __SerdeContext
  17249. ): any => {
  17250. return {
  17251. ...(input.method !== undefined && { method: input.method }),
  17252. ...(input.name !== undefined && { name: input.name }),
  17253. ...(input.path !== undefined && { path: input.path }),
  17254. ...(input.statusCode !== undefined && { statusCode: input.statusCode }),
  17255. ...(input.type !== undefined && { type: input.type }),
  17256. };
  17257. };
  17258. const serializeAws_restJson1EndpointConfiguration = (input: EndpointConfiguration, context: __SerdeContext): any => {
  17259. return {
  17260. ...(input.types !== undefined && { types: serializeAws_restJson1ListOfEndpointType(input.types, context) }),
  17261. ...(input.vpcEndpointIds !== undefined && {
  17262. vpcEndpointIds: serializeAws_restJson1ListOfString(input.vpcEndpointIds, context),
  17263. }),
  17264. };
  17265. };
  17266. const serializeAws_restJson1ListOfApiStage = (input: ApiStage[], context: __SerdeContext): any => {
  17267. return input.map((entry) => serializeAws_restJson1ApiStage(entry, context));
  17268. };
  17269. const serializeAws_restJson1ListOfARNs = (input: string[], context: __SerdeContext): any => {
  17270. return input.map((entry) => entry);
  17271. };
  17272. const serializeAws_restJson1ListOfEndpointType = (input: (EndpointType | string)[], context: __SerdeContext): any => {
  17273. return input.map((entry) => entry);
  17274. };
  17275. const serializeAws_restJson1ListOfPatchOperation = (input: PatchOperation[], context: __SerdeContext): any => {
  17276. return input.map((entry) => serializeAws_restJson1PatchOperation(entry, context));
  17277. };
  17278. const serializeAws_restJson1ListOfStageKeys = (input: StageKey[], context: __SerdeContext): any => {
  17279. return input.map((entry) => serializeAws_restJson1StageKey(entry, context));
  17280. };
  17281. const serializeAws_restJson1ListOfString = (input: string[], context: __SerdeContext): any => {
  17282. return input.map((entry) => entry);
  17283. };
  17284. const serializeAws_restJson1MapOfApiStageThrottleSettings = (
  17285. input: { [key: string]: ThrottleSettings },
  17286. context: __SerdeContext
  17287. ): any => {
  17288. return Object.entries(input).reduce(
  17289. (acc: { [key: string]: ThrottleSettings }, [key, value]: [string, any]) => ({
  17290. ...acc,
  17291. [key]: serializeAws_restJson1ThrottleSettings(value, context),
  17292. }),
  17293. {}
  17294. );
  17295. };
  17296. const serializeAws_restJson1MapOfStringToBoolean = (
  17297. input: { [key: string]: boolean },
  17298. context: __SerdeContext
  17299. ): any => {
  17300. return Object.entries(input).reduce(
  17301. (acc: { [key: string]: boolean }, [key, value]: [string, any]) => ({
  17302. ...acc,
  17303. [key]: value,
  17304. }),
  17305. {}
  17306. );
  17307. };
  17308. const serializeAws_restJson1MapOfStringToList = (input: { [key: string]: string[] }, context: __SerdeContext): any => {
  17309. return Object.entries(input).reduce(
  17310. (acc: { [key: string]: string[] }, [key, value]: [string, any]) => ({
  17311. ...acc,
  17312. [key]: serializeAws_restJson1ListOfString(value, context),
  17313. }),
  17314. {}
  17315. );
  17316. };
  17317. const serializeAws_restJson1MapOfStringToString = (input: { [key: string]: string }, context: __SerdeContext): any => {
  17318. return Object.entries(input).reduce(
  17319. (acc: { [key: string]: string }, [key, value]: [string, any]) => ({
  17320. ...acc,
  17321. [key]: value,
  17322. }),
  17323. {}
  17324. );
  17325. };
  17326. const serializeAws_restJson1PatchOperation = (input: PatchOperation, context: __SerdeContext): any => {
  17327. return {
  17328. ...(input.from !== undefined && { from: input.from }),
  17329. ...(input.op !== undefined && { op: input.op }),
  17330. ...(input.path !== undefined && { path: input.path }),
  17331. ...(input.value !== undefined && { value: input.value }),
  17332. };
  17333. };
  17334. const serializeAws_restJson1QuotaSettings = (input: QuotaSettings, context: __SerdeContext): any => {
  17335. return {
  17336. ...(input.limit !== undefined && { limit: input.limit }),
  17337. ...(input.offset !== undefined && { offset: input.offset }),
  17338. ...(input.period !== undefined && { period: input.period }),
  17339. };
  17340. };
  17341. const serializeAws_restJson1StageKey = (input: StageKey, context: __SerdeContext): any => {
  17342. return {
  17343. ...(input.restApiId !== undefined && { restApiId: input.restApiId }),
  17344. ...(input.stageName !== undefined && { stageName: input.stageName }),
  17345. };
  17346. };
  17347. const serializeAws_restJson1ThrottleSettings = (input: ThrottleSettings, context: __SerdeContext): any => {
  17348. return {
  17349. ...(input.burstLimit !== undefined && { burstLimit: input.burstLimit }),
  17350. ...(input.rateLimit !== undefined && { rateLimit: input.rateLimit }),
  17351. };
  17352. };
  17353. const serializeAws_restJson1TlsConfig = (input: TlsConfig, context: __SerdeContext): any => {
  17354. return {
  17355. ...(input.insecureSkipVerification !== undefined && { insecureSkipVerification: input.insecureSkipVerification }),
  17356. };
  17357. };
  17358. const deserializeAws_restJson1AccessLogSettings = (output: any, context: __SerdeContext): AccessLogSettings => {
  17359. return {
  17360. destinationArn:
  17361. output.destinationArn !== undefined && output.destinationArn !== null ? output.destinationArn : undefined,
  17362. format: output.format !== undefined && output.format !== null ? output.format : undefined,
  17363. } as any;
  17364. };
  17365. const deserializeAws_restJson1ApiKey = (output: any, context: __SerdeContext): ApiKey => {
  17366. return {
  17367. createdDate:
  17368. output.createdDate !== undefined && output.createdDate !== null
  17369. ? new Date(Math.round(output.createdDate * 1000))
  17370. : undefined,
  17371. customerId: output.customerId !== undefined && output.customerId !== null ? output.customerId : undefined,
  17372. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  17373. enabled: output.enabled !== undefined && output.enabled !== null ? output.enabled : undefined,
  17374. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17375. lastUpdatedDate:
  17376. output.lastUpdatedDate !== undefined && output.lastUpdatedDate !== null
  17377. ? new Date(Math.round(output.lastUpdatedDate * 1000))
  17378. : undefined,
  17379. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  17380. stageKeys:
  17381. output.stageKeys !== undefined && output.stageKeys !== null
  17382. ? deserializeAws_restJson1ListOfString(output.stageKeys, context)
  17383. : undefined,
  17384. tags:
  17385. output.tags !== undefined && output.tags !== null
  17386. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  17387. : undefined,
  17388. value: output.value !== undefined && output.value !== null ? output.value : undefined,
  17389. } as any;
  17390. };
  17391. const deserializeAws_restJson1ApiStage = (output: any, context: __SerdeContext): ApiStage => {
  17392. return {
  17393. apiId: output.apiId !== undefined && output.apiId !== null ? output.apiId : undefined,
  17394. stage: output.stage !== undefined && output.stage !== null ? output.stage : undefined,
  17395. throttle:
  17396. output.throttle !== undefined && output.throttle !== null
  17397. ? deserializeAws_restJson1MapOfApiStageThrottleSettings(output.throttle, context)
  17398. : undefined,
  17399. } as any;
  17400. };
  17401. const deserializeAws_restJson1Authorizer = (output: any, context: __SerdeContext): Authorizer => {
  17402. return {
  17403. authType: output.authType !== undefined && output.authType !== null ? output.authType : undefined,
  17404. authorizerCredentials:
  17405. output.authorizerCredentials !== undefined && output.authorizerCredentials !== null
  17406. ? output.authorizerCredentials
  17407. : undefined,
  17408. authorizerResultTtlInSeconds:
  17409. output.authorizerResultTtlInSeconds !== undefined && output.authorizerResultTtlInSeconds !== null
  17410. ? output.authorizerResultTtlInSeconds
  17411. : undefined,
  17412. authorizerUri:
  17413. output.authorizerUri !== undefined && output.authorizerUri !== null ? output.authorizerUri : undefined,
  17414. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17415. identitySource:
  17416. output.identitySource !== undefined && output.identitySource !== null ? output.identitySource : undefined,
  17417. identityValidationExpression:
  17418. output.identityValidationExpression !== undefined && output.identityValidationExpression !== null
  17419. ? output.identityValidationExpression
  17420. : undefined,
  17421. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  17422. providerARNs:
  17423. output.providerARNs !== undefined && output.providerARNs !== null
  17424. ? deserializeAws_restJson1ListOfARNs(output.providerARNs, context)
  17425. : undefined,
  17426. type: output.type !== undefined && output.type !== null ? output.type : undefined,
  17427. } as any;
  17428. };
  17429. const deserializeAws_restJson1BasePathMapping = (output: any, context: __SerdeContext): BasePathMapping => {
  17430. return {
  17431. basePath: output.basePath !== undefined && output.basePath !== null ? output.basePath : undefined,
  17432. restApiId: output.restApiId !== undefined && output.restApiId !== null ? output.restApiId : undefined,
  17433. stage: output.stage !== undefined && output.stage !== null ? output.stage : undefined,
  17434. } as any;
  17435. };
  17436. const deserializeAws_restJson1CanarySettings = (output: any, context: __SerdeContext): CanarySettings => {
  17437. return {
  17438. deploymentId: output.deploymentId !== undefined && output.deploymentId !== null ? output.deploymentId : undefined,
  17439. percentTraffic:
  17440. output.percentTraffic !== undefined && output.percentTraffic !== null ? output.percentTraffic : undefined,
  17441. stageVariableOverrides:
  17442. output.stageVariableOverrides !== undefined && output.stageVariableOverrides !== null
  17443. ? deserializeAws_restJson1MapOfStringToString(output.stageVariableOverrides, context)
  17444. : undefined,
  17445. useStageCache:
  17446. output.useStageCache !== undefined && output.useStageCache !== null ? output.useStageCache : undefined,
  17447. } as any;
  17448. };
  17449. const deserializeAws_restJson1ClientCertificate = (output: any, context: __SerdeContext): ClientCertificate => {
  17450. return {
  17451. clientCertificateId:
  17452. output.clientCertificateId !== undefined && output.clientCertificateId !== null
  17453. ? output.clientCertificateId
  17454. : undefined,
  17455. createdDate:
  17456. output.createdDate !== undefined && output.createdDate !== null
  17457. ? new Date(Math.round(output.createdDate * 1000))
  17458. : undefined,
  17459. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  17460. expirationDate:
  17461. output.expirationDate !== undefined && output.expirationDate !== null
  17462. ? new Date(Math.round(output.expirationDate * 1000))
  17463. : undefined,
  17464. pemEncodedCertificate:
  17465. output.pemEncodedCertificate !== undefined && output.pemEncodedCertificate !== null
  17466. ? output.pemEncodedCertificate
  17467. : undefined,
  17468. tags:
  17469. output.tags !== undefined && output.tags !== null
  17470. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  17471. : undefined,
  17472. } as any;
  17473. };
  17474. const deserializeAws_restJson1Deployment = (output: any, context: __SerdeContext): Deployment => {
  17475. return {
  17476. apiSummary:
  17477. output.apiSummary !== undefined && output.apiSummary !== null
  17478. ? deserializeAws_restJson1PathToMapOfMethodSnapshot(output.apiSummary, context)
  17479. : undefined,
  17480. createdDate:
  17481. output.createdDate !== undefined && output.createdDate !== null
  17482. ? new Date(Math.round(output.createdDate * 1000))
  17483. : undefined,
  17484. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  17485. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17486. } as any;
  17487. };
  17488. const deserializeAws_restJson1DocumentationPart = (output: any, context: __SerdeContext): DocumentationPart => {
  17489. return {
  17490. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17491. location:
  17492. output.location !== undefined && output.location !== null
  17493. ? deserializeAws_restJson1DocumentationPartLocation(output.location, context)
  17494. : undefined,
  17495. properties: output.properties !== undefined && output.properties !== null ? output.properties : undefined,
  17496. } as any;
  17497. };
  17498. const deserializeAws_restJson1DocumentationPartLocation = (
  17499. output: any,
  17500. context: __SerdeContext
  17501. ): DocumentationPartLocation => {
  17502. return {
  17503. method: output.method !== undefined && output.method !== null ? output.method : undefined,
  17504. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  17505. path: output.path !== undefined && output.path !== null ? output.path : undefined,
  17506. statusCode: output.statusCode !== undefined && output.statusCode !== null ? output.statusCode : undefined,
  17507. type: output.type !== undefined && output.type !== null ? output.type : undefined,
  17508. } as any;
  17509. };
  17510. const deserializeAws_restJson1DocumentationVersion = (output: any, context: __SerdeContext): DocumentationVersion => {
  17511. return {
  17512. createdDate:
  17513. output.createdDate !== undefined && output.createdDate !== null
  17514. ? new Date(Math.round(output.createdDate * 1000))
  17515. : undefined,
  17516. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  17517. version: output.version !== undefined && output.version !== null ? output.version : undefined,
  17518. } as any;
  17519. };
  17520. const deserializeAws_restJson1DomainName = (output: any, context: __SerdeContext): DomainName => {
  17521. return {
  17522. certificateArn:
  17523. output.certificateArn !== undefined && output.certificateArn !== null ? output.certificateArn : undefined,
  17524. certificateName:
  17525. output.certificateName !== undefined && output.certificateName !== null ? output.certificateName : undefined,
  17526. certificateUploadDate:
  17527. output.certificateUploadDate !== undefined && output.certificateUploadDate !== null
  17528. ? new Date(Math.round(output.certificateUploadDate * 1000))
  17529. : undefined,
  17530. distributionDomainName:
  17531. output.distributionDomainName !== undefined && output.distributionDomainName !== null
  17532. ? output.distributionDomainName
  17533. : undefined,
  17534. distributionHostedZoneId:
  17535. output.distributionHostedZoneId !== undefined && output.distributionHostedZoneId !== null
  17536. ? output.distributionHostedZoneId
  17537. : undefined,
  17538. domainName: output.domainName !== undefined && output.domainName !== null ? output.domainName : undefined,
  17539. domainNameStatus:
  17540. output.domainNameStatus !== undefined && output.domainNameStatus !== null ? output.domainNameStatus : undefined,
  17541. domainNameStatusMessage:
  17542. output.domainNameStatusMessage !== undefined && output.domainNameStatusMessage !== null
  17543. ? output.domainNameStatusMessage
  17544. : undefined,
  17545. endpointConfiguration:
  17546. output.endpointConfiguration !== undefined && output.endpointConfiguration !== null
  17547. ? deserializeAws_restJson1EndpointConfiguration(output.endpointConfiguration, context)
  17548. : undefined,
  17549. regionalCertificateArn:
  17550. output.regionalCertificateArn !== undefined && output.regionalCertificateArn !== null
  17551. ? output.regionalCertificateArn
  17552. : undefined,
  17553. regionalCertificateName:
  17554. output.regionalCertificateName !== undefined && output.regionalCertificateName !== null
  17555. ? output.regionalCertificateName
  17556. : undefined,
  17557. regionalDomainName:
  17558. output.regionalDomainName !== undefined && output.regionalDomainName !== null
  17559. ? output.regionalDomainName
  17560. : undefined,
  17561. regionalHostedZoneId:
  17562. output.regionalHostedZoneId !== undefined && output.regionalHostedZoneId !== null
  17563. ? output.regionalHostedZoneId
  17564. : undefined,
  17565. securityPolicy:
  17566. output.securityPolicy !== undefined && output.securityPolicy !== null ? output.securityPolicy : undefined,
  17567. tags:
  17568. output.tags !== undefined && output.tags !== null
  17569. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  17570. : undefined,
  17571. } as any;
  17572. };
  17573. const deserializeAws_restJson1EndpointConfiguration = (output: any, context: __SerdeContext): EndpointConfiguration => {
  17574. return {
  17575. types:
  17576. output.types !== undefined && output.types !== null
  17577. ? deserializeAws_restJson1ListOfEndpointType(output.types, context)
  17578. : undefined,
  17579. vpcEndpointIds:
  17580. output.vpcEndpointIds !== undefined && output.vpcEndpointIds !== null
  17581. ? deserializeAws_restJson1ListOfString(output.vpcEndpointIds, context)
  17582. : undefined,
  17583. } as any;
  17584. };
  17585. const deserializeAws_restJson1GatewayResponse = (output: any, context: __SerdeContext): GatewayResponse => {
  17586. return {
  17587. defaultResponse:
  17588. output.defaultResponse !== undefined && output.defaultResponse !== null ? output.defaultResponse : undefined,
  17589. responseParameters:
  17590. output.responseParameters !== undefined && output.responseParameters !== null
  17591. ? deserializeAws_restJson1MapOfStringToString(output.responseParameters, context)
  17592. : undefined,
  17593. responseTemplates:
  17594. output.responseTemplates !== undefined && output.responseTemplates !== null
  17595. ? deserializeAws_restJson1MapOfStringToString(output.responseTemplates, context)
  17596. : undefined,
  17597. responseType: output.responseType !== undefined && output.responseType !== null ? output.responseType : undefined,
  17598. statusCode: output.statusCode !== undefined && output.statusCode !== null ? output.statusCode : undefined,
  17599. } as any;
  17600. };
  17601. const deserializeAws_restJson1Integration = (output: any, context: __SerdeContext): Integration => {
  17602. return {
  17603. cacheKeyParameters:
  17604. output.cacheKeyParameters !== undefined && output.cacheKeyParameters !== null
  17605. ? deserializeAws_restJson1ListOfString(output.cacheKeyParameters, context)
  17606. : undefined,
  17607. cacheNamespace:
  17608. output.cacheNamespace !== undefined && output.cacheNamespace !== null ? output.cacheNamespace : undefined,
  17609. connectionId: output.connectionId !== undefined && output.connectionId !== null ? output.connectionId : undefined,
  17610. connectionType:
  17611. output.connectionType !== undefined && output.connectionType !== null ? output.connectionType : undefined,
  17612. contentHandling:
  17613. output.contentHandling !== undefined && output.contentHandling !== null ? output.contentHandling : undefined,
  17614. credentials: output.credentials !== undefined && output.credentials !== null ? output.credentials : undefined,
  17615. httpMethod: output.httpMethod !== undefined && output.httpMethod !== null ? output.httpMethod : undefined,
  17616. integrationResponses:
  17617. output.integrationResponses !== undefined && output.integrationResponses !== null
  17618. ? deserializeAws_restJson1MapOfIntegrationResponse(output.integrationResponses, context)
  17619. : undefined,
  17620. passthroughBehavior:
  17621. output.passthroughBehavior !== undefined && output.passthroughBehavior !== null
  17622. ? output.passthroughBehavior
  17623. : undefined,
  17624. requestParameters:
  17625. output.requestParameters !== undefined && output.requestParameters !== null
  17626. ? deserializeAws_restJson1MapOfStringToString(output.requestParameters, context)
  17627. : undefined,
  17628. requestTemplates:
  17629. output.requestTemplates !== undefined && output.requestTemplates !== null
  17630. ? deserializeAws_restJson1MapOfStringToString(output.requestTemplates, context)
  17631. : undefined,
  17632. timeoutInMillis:
  17633. output.timeoutInMillis !== undefined && output.timeoutInMillis !== null ? output.timeoutInMillis : undefined,
  17634. tlsConfig:
  17635. output.tlsConfig !== undefined && output.tlsConfig !== null
  17636. ? deserializeAws_restJson1TlsConfig(output.tlsConfig, context)
  17637. : undefined,
  17638. type: output.type !== undefined && output.type !== null ? output.type : undefined,
  17639. uri: output.uri !== undefined && output.uri !== null ? output.uri : undefined,
  17640. } as any;
  17641. };
  17642. const deserializeAws_restJson1IntegrationResponse = (output: any, context: __SerdeContext): IntegrationResponse => {
  17643. return {
  17644. contentHandling:
  17645. output.contentHandling !== undefined && output.contentHandling !== null ? output.contentHandling : undefined,
  17646. responseParameters:
  17647. output.responseParameters !== undefined && output.responseParameters !== null
  17648. ? deserializeAws_restJson1MapOfStringToString(output.responseParameters, context)
  17649. : undefined,
  17650. responseTemplates:
  17651. output.responseTemplates !== undefined && output.responseTemplates !== null
  17652. ? deserializeAws_restJson1MapOfStringToString(output.responseTemplates, context)
  17653. : undefined,
  17654. selectionPattern:
  17655. output.selectionPattern !== undefined && output.selectionPattern !== null ? output.selectionPattern : undefined,
  17656. statusCode: output.statusCode !== undefined && output.statusCode !== null ? output.statusCode : undefined,
  17657. } as any;
  17658. };
  17659. const deserializeAws_restJson1ListOfApiKey = (output: any, context: __SerdeContext): ApiKey[] => {
  17660. return (output || []).map((entry: any) => deserializeAws_restJson1ApiKey(entry, context));
  17661. };
  17662. const deserializeAws_restJson1ListOfApiStage = (output: any, context: __SerdeContext): ApiStage[] => {
  17663. return (output || []).map((entry: any) => deserializeAws_restJson1ApiStage(entry, context));
  17664. };
  17665. const deserializeAws_restJson1ListOfARNs = (output: any, context: __SerdeContext): string[] => {
  17666. return (output || []).map((entry: any) => entry);
  17667. };
  17668. const deserializeAws_restJson1ListOfAuthorizer = (output: any, context: __SerdeContext): Authorizer[] => {
  17669. return (output || []).map((entry: any) => deserializeAws_restJson1Authorizer(entry, context));
  17670. };
  17671. const deserializeAws_restJson1ListOfBasePathMapping = (output: any, context: __SerdeContext): BasePathMapping[] => {
  17672. return (output || []).map((entry: any) => deserializeAws_restJson1BasePathMapping(entry, context));
  17673. };
  17674. const deserializeAws_restJson1ListOfClientCertificate = (output: any, context: __SerdeContext): ClientCertificate[] => {
  17675. return (output || []).map((entry: any) => deserializeAws_restJson1ClientCertificate(entry, context));
  17676. };
  17677. const deserializeAws_restJson1ListOfDeployment = (output: any, context: __SerdeContext): Deployment[] => {
  17678. return (output || []).map((entry: any) => deserializeAws_restJson1Deployment(entry, context));
  17679. };
  17680. const deserializeAws_restJson1ListOfDocumentationPart = (output: any, context: __SerdeContext): DocumentationPart[] => {
  17681. return (output || []).map((entry: any) => deserializeAws_restJson1DocumentationPart(entry, context));
  17682. };
  17683. const deserializeAws_restJson1ListOfDocumentationVersion = (
  17684. output: any,
  17685. context: __SerdeContext
  17686. ): DocumentationVersion[] => {
  17687. return (output || []).map((entry: any) => deserializeAws_restJson1DocumentationVersion(entry, context));
  17688. };
  17689. const deserializeAws_restJson1ListOfDomainName = (output: any, context: __SerdeContext): DomainName[] => {
  17690. return (output || []).map((entry: any) => deserializeAws_restJson1DomainName(entry, context));
  17691. };
  17692. const deserializeAws_restJson1ListOfEndpointType = (
  17693. output: any,
  17694. context: __SerdeContext
  17695. ): (EndpointType | string)[] => {
  17696. return (output || []).map((entry: any) => entry);
  17697. };
  17698. const deserializeAws_restJson1ListOfGatewayResponse = (output: any, context: __SerdeContext): GatewayResponse[] => {
  17699. return (output || []).map((entry: any) => deserializeAws_restJson1GatewayResponse(entry, context));
  17700. };
  17701. const deserializeAws_restJson1ListOfLong = (output: any, context: __SerdeContext): number[] => {
  17702. return (output || []).map((entry: any) => entry);
  17703. };
  17704. const deserializeAws_restJson1ListOfModel = (output: any, context: __SerdeContext): Model[] => {
  17705. return (output || []).map((entry: any) => deserializeAws_restJson1Model(entry, context));
  17706. };
  17707. const deserializeAws_restJson1ListOfRequestValidator = (output: any, context: __SerdeContext): RequestValidator[] => {
  17708. return (output || []).map((entry: any) => deserializeAws_restJson1RequestValidator(entry, context));
  17709. };
  17710. const deserializeAws_restJson1ListOfResource = (output: any, context: __SerdeContext): Resource[] => {
  17711. return (output || []).map((entry: any) => deserializeAws_restJson1Resource(entry, context));
  17712. };
  17713. const deserializeAws_restJson1ListOfRestApi = (output: any, context: __SerdeContext): RestApi[] => {
  17714. return (output || []).map((entry: any) => deserializeAws_restJson1RestApi(entry, context));
  17715. };
  17716. const deserializeAws_restJson1ListOfSdkConfigurationProperty = (
  17717. output: any,
  17718. context: __SerdeContext
  17719. ): SdkConfigurationProperty[] => {
  17720. return (output || []).map((entry: any) => deserializeAws_restJson1SdkConfigurationProperty(entry, context));
  17721. };
  17722. const deserializeAws_restJson1ListOfSdkType = (output: any, context: __SerdeContext): SdkType[] => {
  17723. return (output || []).map((entry: any) => deserializeAws_restJson1SdkType(entry, context));
  17724. };
  17725. const deserializeAws_restJson1ListOfStage = (output: any, context: __SerdeContext): Stage[] => {
  17726. return (output || []).map((entry: any) => deserializeAws_restJson1Stage(entry, context));
  17727. };
  17728. const deserializeAws_restJson1ListOfString = (output: any, context: __SerdeContext): string[] => {
  17729. return (output || []).map((entry: any) => entry);
  17730. };
  17731. const deserializeAws_restJson1ListOfUsage = (output: any, context: __SerdeContext): number[][] => {
  17732. return (output || []).map((entry: any) => deserializeAws_restJson1ListOfLong(entry, context));
  17733. };
  17734. const deserializeAws_restJson1ListOfUsagePlan = (output: any, context: __SerdeContext): UsagePlan[] => {
  17735. return (output || []).map((entry: any) => deserializeAws_restJson1UsagePlan(entry, context));
  17736. };
  17737. const deserializeAws_restJson1ListOfUsagePlanKey = (output: any, context: __SerdeContext): UsagePlanKey[] => {
  17738. return (output || []).map((entry: any) => deserializeAws_restJson1UsagePlanKey(entry, context));
  17739. };
  17740. const deserializeAws_restJson1ListOfVpcLink = (output: any, context: __SerdeContext): VpcLink[] => {
  17741. return (output || []).map((entry: any) => deserializeAws_restJson1VpcLink(entry, context));
  17742. };
  17743. const deserializeAws_restJson1MapOfApiStageThrottleSettings = (
  17744. output: any,
  17745. context: __SerdeContext
  17746. ): { [key: string]: ThrottleSettings } => {
  17747. return Object.entries(output).reduce(
  17748. (acc: { [key: string]: ThrottleSettings }, [key, value]: [string, any]) => ({
  17749. ...acc,
  17750. [key]: deserializeAws_restJson1ThrottleSettings(value, context),
  17751. }),
  17752. {}
  17753. );
  17754. };
  17755. const deserializeAws_restJson1MapOfIntegrationResponse = (
  17756. output: any,
  17757. context: __SerdeContext
  17758. ): { [key: string]: IntegrationResponse } => {
  17759. return Object.entries(output).reduce(
  17760. (acc: { [key: string]: IntegrationResponse }, [key, value]: [string, any]) => ({
  17761. ...acc,
  17762. [key]: deserializeAws_restJson1IntegrationResponse(value, context),
  17763. }),
  17764. {}
  17765. );
  17766. };
  17767. const deserializeAws_restJson1MapOfKeyUsages = (
  17768. output: any,
  17769. context: __SerdeContext
  17770. ): { [key: string]: number[][] } => {
  17771. return Object.entries(output).reduce(
  17772. (acc: { [key: string]: number[][] }, [key, value]: [string, any]) => ({
  17773. ...acc,
  17774. [key]: deserializeAws_restJson1ListOfUsage(value, context),
  17775. }),
  17776. {}
  17777. );
  17778. };
  17779. const deserializeAws_restJson1MapOfMethod = (output: any, context: __SerdeContext): { [key: string]: Method } => {
  17780. return Object.entries(output).reduce(
  17781. (acc: { [key: string]: Method }, [key, value]: [string, any]) => ({
  17782. ...acc,
  17783. [key]: deserializeAws_restJson1Method(value, context),
  17784. }),
  17785. {}
  17786. );
  17787. };
  17788. const deserializeAws_restJson1MapOfMethodResponse = (
  17789. output: any,
  17790. context: __SerdeContext
  17791. ): { [key: string]: MethodResponse } => {
  17792. return Object.entries(output).reduce(
  17793. (acc: { [key: string]: MethodResponse }, [key, value]: [string, any]) => ({
  17794. ...acc,
  17795. [key]: deserializeAws_restJson1MethodResponse(value, context),
  17796. }),
  17797. {}
  17798. );
  17799. };
  17800. const deserializeAws_restJson1MapOfMethodSettings = (
  17801. output: any,
  17802. context: __SerdeContext
  17803. ): { [key: string]: MethodSetting } => {
  17804. return Object.entries(output).reduce(
  17805. (acc: { [key: string]: MethodSetting }, [key, value]: [string, any]) => ({
  17806. ...acc,
  17807. [key]: deserializeAws_restJson1MethodSetting(value, context),
  17808. }),
  17809. {}
  17810. );
  17811. };
  17812. const deserializeAws_restJson1MapOfMethodSnapshot = (
  17813. output: any,
  17814. context: __SerdeContext
  17815. ): { [key: string]: MethodSnapshot } => {
  17816. return Object.entries(output).reduce(
  17817. (acc: { [key: string]: MethodSnapshot }, [key, value]: [string, any]) => ({
  17818. ...acc,
  17819. [key]: deserializeAws_restJson1MethodSnapshot(value, context),
  17820. }),
  17821. {}
  17822. );
  17823. };
  17824. const deserializeAws_restJson1MapOfStringToBoolean = (
  17825. output: any,
  17826. context: __SerdeContext
  17827. ): { [key: string]: boolean } => {
  17828. return Object.entries(output).reduce(
  17829. (acc: { [key: string]: boolean }, [key, value]: [string, any]) => ({
  17830. ...acc,
  17831. [key]: value,
  17832. }),
  17833. {}
  17834. );
  17835. };
  17836. const deserializeAws_restJson1MapOfStringToList = (
  17837. output: any,
  17838. context: __SerdeContext
  17839. ): { [key: string]: string[] } => {
  17840. return Object.entries(output).reduce(
  17841. (acc: { [key: string]: string[] }, [key, value]: [string, any]) => ({
  17842. ...acc,
  17843. [key]: deserializeAws_restJson1ListOfString(value, context),
  17844. }),
  17845. {}
  17846. );
  17847. };
  17848. const deserializeAws_restJson1MapOfStringToString = (
  17849. output: any,
  17850. context: __SerdeContext
  17851. ): { [key: string]: string } => {
  17852. return Object.entries(output).reduce(
  17853. (acc: { [key: string]: string }, [key, value]: [string, any]) => ({
  17854. ...acc,
  17855. [key]: value,
  17856. }),
  17857. {}
  17858. );
  17859. };
  17860. const deserializeAws_restJson1Method = (output: any, context: __SerdeContext): Method => {
  17861. return {
  17862. apiKeyRequired:
  17863. output.apiKeyRequired !== undefined && output.apiKeyRequired !== null ? output.apiKeyRequired : undefined,
  17864. authorizationScopes:
  17865. output.authorizationScopes !== undefined && output.authorizationScopes !== null
  17866. ? deserializeAws_restJson1ListOfString(output.authorizationScopes, context)
  17867. : undefined,
  17868. authorizationType:
  17869. output.authorizationType !== undefined && output.authorizationType !== null
  17870. ? output.authorizationType
  17871. : undefined,
  17872. authorizerId: output.authorizerId !== undefined && output.authorizerId !== null ? output.authorizerId : undefined,
  17873. httpMethod: output.httpMethod !== undefined && output.httpMethod !== null ? output.httpMethod : undefined,
  17874. methodIntegration:
  17875. output.methodIntegration !== undefined && output.methodIntegration !== null
  17876. ? deserializeAws_restJson1Integration(output.methodIntegration, context)
  17877. : undefined,
  17878. methodResponses:
  17879. output.methodResponses !== undefined && output.methodResponses !== null
  17880. ? deserializeAws_restJson1MapOfMethodResponse(output.methodResponses, context)
  17881. : undefined,
  17882. operationName:
  17883. output.operationName !== undefined && output.operationName !== null ? output.operationName : undefined,
  17884. requestModels:
  17885. output.requestModels !== undefined && output.requestModels !== null
  17886. ? deserializeAws_restJson1MapOfStringToString(output.requestModels, context)
  17887. : undefined,
  17888. requestParameters:
  17889. output.requestParameters !== undefined && output.requestParameters !== null
  17890. ? deserializeAws_restJson1MapOfStringToBoolean(output.requestParameters, context)
  17891. : undefined,
  17892. requestValidatorId:
  17893. output.requestValidatorId !== undefined && output.requestValidatorId !== null
  17894. ? output.requestValidatorId
  17895. : undefined,
  17896. } as any;
  17897. };
  17898. const deserializeAws_restJson1MethodResponse = (output: any, context: __SerdeContext): MethodResponse => {
  17899. return {
  17900. responseModels:
  17901. output.responseModels !== undefined && output.responseModels !== null
  17902. ? deserializeAws_restJson1MapOfStringToString(output.responseModels, context)
  17903. : undefined,
  17904. responseParameters:
  17905. output.responseParameters !== undefined && output.responseParameters !== null
  17906. ? deserializeAws_restJson1MapOfStringToBoolean(output.responseParameters, context)
  17907. : undefined,
  17908. statusCode: output.statusCode !== undefined && output.statusCode !== null ? output.statusCode : undefined,
  17909. } as any;
  17910. };
  17911. const deserializeAws_restJson1MethodSetting = (output: any, context: __SerdeContext): MethodSetting => {
  17912. return {
  17913. cacheDataEncrypted:
  17914. output.cacheDataEncrypted !== undefined && output.cacheDataEncrypted !== null
  17915. ? output.cacheDataEncrypted
  17916. : undefined,
  17917. cacheTtlInSeconds:
  17918. output.cacheTtlInSeconds !== undefined && output.cacheTtlInSeconds !== null
  17919. ? output.cacheTtlInSeconds
  17920. : undefined,
  17921. cachingEnabled:
  17922. output.cachingEnabled !== undefined && output.cachingEnabled !== null ? output.cachingEnabled : undefined,
  17923. dataTraceEnabled:
  17924. output.dataTraceEnabled !== undefined && output.dataTraceEnabled !== null ? output.dataTraceEnabled : undefined,
  17925. loggingLevel: output.loggingLevel !== undefined && output.loggingLevel !== null ? output.loggingLevel : undefined,
  17926. metricsEnabled:
  17927. output.metricsEnabled !== undefined && output.metricsEnabled !== null ? output.metricsEnabled : undefined,
  17928. requireAuthorizationForCacheControl:
  17929. output.requireAuthorizationForCacheControl !== undefined && output.requireAuthorizationForCacheControl !== null
  17930. ? output.requireAuthorizationForCacheControl
  17931. : undefined,
  17932. throttlingBurstLimit:
  17933. output.throttlingBurstLimit !== undefined && output.throttlingBurstLimit !== null
  17934. ? output.throttlingBurstLimit
  17935. : undefined,
  17936. throttlingRateLimit:
  17937. output.throttlingRateLimit !== undefined && output.throttlingRateLimit !== null
  17938. ? output.throttlingRateLimit
  17939. : undefined,
  17940. unauthorizedCacheControlHeaderStrategy:
  17941. output.unauthorizedCacheControlHeaderStrategy !== undefined &&
  17942. output.unauthorizedCacheControlHeaderStrategy !== null
  17943. ? output.unauthorizedCacheControlHeaderStrategy
  17944. : undefined,
  17945. } as any;
  17946. };
  17947. const deserializeAws_restJson1MethodSnapshot = (output: any, context: __SerdeContext): MethodSnapshot => {
  17948. return {
  17949. apiKeyRequired:
  17950. output.apiKeyRequired !== undefined && output.apiKeyRequired !== null ? output.apiKeyRequired : undefined,
  17951. authorizationType:
  17952. output.authorizationType !== undefined && output.authorizationType !== null
  17953. ? output.authorizationType
  17954. : undefined,
  17955. } as any;
  17956. };
  17957. const deserializeAws_restJson1Model = (output: any, context: __SerdeContext): Model => {
  17958. return {
  17959. contentType: output.contentType !== undefined && output.contentType !== null ? output.contentType : undefined,
  17960. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  17961. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17962. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  17963. schema: output.schema !== undefined && output.schema !== null ? output.schema : undefined,
  17964. } as any;
  17965. };
  17966. const deserializeAws_restJson1PathToMapOfMethodSnapshot = (
  17967. output: any,
  17968. context: __SerdeContext
  17969. ): { [key: string]: { [key: string]: MethodSnapshot } } => {
  17970. return Object.entries(output).reduce(
  17971. (acc: { [key: string]: { [key: string]: MethodSnapshot } }, [key, value]: [string, any]) => ({
  17972. ...acc,
  17973. [key]: deserializeAws_restJson1MapOfMethodSnapshot(value, context),
  17974. }),
  17975. {}
  17976. );
  17977. };
  17978. const deserializeAws_restJson1QuotaSettings = (output: any, context: __SerdeContext): QuotaSettings => {
  17979. return {
  17980. limit: output.limit !== undefined && output.limit !== null ? output.limit : undefined,
  17981. offset: output.offset !== undefined && output.offset !== null ? output.offset : undefined,
  17982. period: output.period !== undefined && output.period !== null ? output.period : undefined,
  17983. } as any;
  17984. };
  17985. const deserializeAws_restJson1RequestValidator = (output: any, context: __SerdeContext): RequestValidator => {
  17986. return {
  17987. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  17988. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  17989. validateRequestBody:
  17990. output.validateRequestBody !== undefined && output.validateRequestBody !== null
  17991. ? output.validateRequestBody
  17992. : undefined,
  17993. validateRequestParameters:
  17994. output.validateRequestParameters !== undefined && output.validateRequestParameters !== null
  17995. ? output.validateRequestParameters
  17996. : undefined,
  17997. } as any;
  17998. };
  17999. const deserializeAws_restJson1Resource = (output: any, context: __SerdeContext): Resource => {
  18000. return {
  18001. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18002. parentId: output.parentId !== undefined && output.parentId !== null ? output.parentId : undefined,
  18003. path: output.path !== undefined && output.path !== null ? output.path : undefined,
  18004. pathPart: output.pathPart !== undefined && output.pathPart !== null ? output.pathPart : undefined,
  18005. resourceMethods:
  18006. output.resourceMethods !== undefined && output.resourceMethods !== null
  18007. ? deserializeAws_restJson1MapOfMethod(output.resourceMethods, context)
  18008. : undefined,
  18009. } as any;
  18010. };
  18011. const deserializeAws_restJson1RestApi = (output: any, context: __SerdeContext): RestApi => {
  18012. return {
  18013. apiKeySource: output.apiKeySource !== undefined && output.apiKeySource !== null ? output.apiKeySource : undefined,
  18014. binaryMediaTypes:
  18015. output.binaryMediaTypes !== undefined && output.binaryMediaTypes !== null
  18016. ? deserializeAws_restJson1ListOfString(output.binaryMediaTypes, context)
  18017. : undefined,
  18018. createdDate:
  18019. output.createdDate !== undefined && output.createdDate !== null
  18020. ? new Date(Math.round(output.createdDate * 1000))
  18021. : undefined,
  18022. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18023. endpointConfiguration:
  18024. output.endpointConfiguration !== undefined && output.endpointConfiguration !== null
  18025. ? deserializeAws_restJson1EndpointConfiguration(output.endpointConfiguration, context)
  18026. : undefined,
  18027. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18028. minimumCompressionSize:
  18029. output.minimumCompressionSize !== undefined && output.minimumCompressionSize !== null
  18030. ? output.minimumCompressionSize
  18031. : undefined,
  18032. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  18033. policy: output.policy !== undefined && output.policy !== null ? output.policy : undefined,
  18034. tags:
  18035. output.tags !== undefined && output.tags !== null
  18036. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  18037. : undefined,
  18038. version: output.version !== undefined && output.version !== null ? output.version : undefined,
  18039. warnings:
  18040. output.warnings !== undefined && output.warnings !== null
  18041. ? deserializeAws_restJson1ListOfString(output.warnings, context)
  18042. : undefined,
  18043. } as any;
  18044. };
  18045. const deserializeAws_restJson1SdkConfigurationProperty = (
  18046. output: any,
  18047. context: __SerdeContext
  18048. ): SdkConfigurationProperty => {
  18049. return {
  18050. defaultValue: output.defaultValue !== undefined && output.defaultValue !== null ? output.defaultValue : undefined,
  18051. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18052. friendlyName: output.friendlyName !== undefined && output.friendlyName !== null ? output.friendlyName : undefined,
  18053. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  18054. required: output.required !== undefined && output.required !== null ? output.required : undefined,
  18055. } as any;
  18056. };
  18057. const deserializeAws_restJson1SdkType = (output: any, context: __SerdeContext): SdkType => {
  18058. return {
  18059. configurationProperties:
  18060. output.configurationProperties !== undefined && output.configurationProperties !== null
  18061. ? deserializeAws_restJson1ListOfSdkConfigurationProperty(output.configurationProperties, context)
  18062. : undefined,
  18063. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18064. friendlyName: output.friendlyName !== undefined && output.friendlyName !== null ? output.friendlyName : undefined,
  18065. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18066. } as any;
  18067. };
  18068. const deserializeAws_restJson1Stage = (output: any, context: __SerdeContext): Stage => {
  18069. return {
  18070. accessLogSettings:
  18071. output.accessLogSettings !== undefined && output.accessLogSettings !== null
  18072. ? deserializeAws_restJson1AccessLogSettings(output.accessLogSettings, context)
  18073. : undefined,
  18074. cacheClusterEnabled:
  18075. output.cacheClusterEnabled !== undefined && output.cacheClusterEnabled !== null
  18076. ? output.cacheClusterEnabled
  18077. : undefined,
  18078. cacheClusterSize:
  18079. output.cacheClusterSize !== undefined && output.cacheClusterSize !== null ? output.cacheClusterSize : undefined,
  18080. cacheClusterStatus:
  18081. output.cacheClusterStatus !== undefined && output.cacheClusterStatus !== null
  18082. ? output.cacheClusterStatus
  18083. : undefined,
  18084. canarySettings:
  18085. output.canarySettings !== undefined && output.canarySettings !== null
  18086. ? deserializeAws_restJson1CanarySettings(output.canarySettings, context)
  18087. : undefined,
  18088. clientCertificateId:
  18089. output.clientCertificateId !== undefined && output.clientCertificateId !== null
  18090. ? output.clientCertificateId
  18091. : undefined,
  18092. createdDate:
  18093. output.createdDate !== undefined && output.createdDate !== null
  18094. ? new Date(Math.round(output.createdDate * 1000))
  18095. : undefined,
  18096. deploymentId: output.deploymentId !== undefined && output.deploymentId !== null ? output.deploymentId : undefined,
  18097. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18098. documentationVersion:
  18099. output.documentationVersion !== undefined && output.documentationVersion !== null
  18100. ? output.documentationVersion
  18101. : undefined,
  18102. lastUpdatedDate:
  18103. output.lastUpdatedDate !== undefined && output.lastUpdatedDate !== null
  18104. ? new Date(Math.round(output.lastUpdatedDate * 1000))
  18105. : undefined,
  18106. methodSettings:
  18107. output.methodSettings !== undefined && output.methodSettings !== null
  18108. ? deserializeAws_restJson1MapOfMethodSettings(output.methodSettings, context)
  18109. : undefined,
  18110. stageName: output.stageName !== undefined && output.stageName !== null ? output.stageName : undefined,
  18111. tags:
  18112. output.tags !== undefined && output.tags !== null
  18113. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  18114. : undefined,
  18115. tracingEnabled:
  18116. output.tracingEnabled !== undefined && output.tracingEnabled !== null ? output.tracingEnabled : undefined,
  18117. variables:
  18118. output.variables !== undefined && output.variables !== null
  18119. ? deserializeAws_restJson1MapOfStringToString(output.variables, context)
  18120. : undefined,
  18121. webAclArn: output.webAclArn !== undefined && output.webAclArn !== null ? output.webAclArn : undefined,
  18122. } as any;
  18123. };
  18124. const deserializeAws_restJson1ThrottleSettings = (output: any, context: __SerdeContext): ThrottleSettings => {
  18125. return {
  18126. burstLimit: output.burstLimit !== undefined && output.burstLimit !== null ? output.burstLimit : undefined,
  18127. rateLimit: output.rateLimit !== undefined && output.rateLimit !== null ? output.rateLimit : undefined,
  18128. } as any;
  18129. };
  18130. const deserializeAws_restJson1TlsConfig = (output: any, context: __SerdeContext): TlsConfig => {
  18131. return {
  18132. insecureSkipVerification:
  18133. output.insecureSkipVerification !== undefined && output.insecureSkipVerification !== null
  18134. ? output.insecureSkipVerification
  18135. : undefined,
  18136. } as any;
  18137. };
  18138. const deserializeAws_restJson1UsagePlan = (output: any, context: __SerdeContext): UsagePlan => {
  18139. return {
  18140. apiStages:
  18141. output.apiStages !== undefined && output.apiStages !== null
  18142. ? deserializeAws_restJson1ListOfApiStage(output.apiStages, context)
  18143. : undefined,
  18144. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18145. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18146. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  18147. productCode: output.productCode !== undefined && output.productCode !== null ? output.productCode : undefined,
  18148. quota:
  18149. output.quota !== undefined && output.quota !== null
  18150. ? deserializeAws_restJson1QuotaSettings(output.quota, context)
  18151. : undefined,
  18152. tags:
  18153. output.tags !== undefined && output.tags !== null
  18154. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  18155. : undefined,
  18156. throttle:
  18157. output.throttle !== undefined && output.throttle !== null
  18158. ? deserializeAws_restJson1ThrottleSettings(output.throttle, context)
  18159. : undefined,
  18160. } as any;
  18161. };
  18162. const deserializeAws_restJson1UsagePlanKey = (output: any, context: __SerdeContext): UsagePlanKey => {
  18163. return {
  18164. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18165. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  18166. type: output.type !== undefined && output.type !== null ? output.type : undefined,
  18167. value: output.value !== undefined && output.value !== null ? output.value : undefined,
  18168. } as any;
  18169. };
  18170. const deserializeAws_restJson1VpcLink = (output: any, context: __SerdeContext): VpcLink => {
  18171. return {
  18172. description: output.description !== undefined && output.description !== null ? output.description : undefined,
  18173. id: output.id !== undefined && output.id !== null ? output.id : undefined,
  18174. name: output.name !== undefined && output.name !== null ? output.name : undefined,
  18175. status: output.status !== undefined && output.status !== null ? output.status : undefined,
  18176. statusMessage:
  18177. output.statusMessage !== undefined && output.statusMessage !== null ? output.statusMessage : undefined,
  18178. tags:
  18179. output.tags !== undefined && output.tags !== null
  18180. ? deserializeAws_restJson1MapOfStringToString(output.tags, context)
  18181. : undefined,
  18182. targetArns:
  18183. output.targetArns !== undefined && output.targetArns !== null
  18184. ? deserializeAws_restJson1ListOfString(output.targetArns, context)
  18185. : undefined,
  18186. } as any;
  18187. };
  18188. const deserializeMetadata = (output: __HttpResponse): __ResponseMetadata => ({
  18189. httpStatusCode: output.statusCode,
  18190. httpHeaders: output.headers,
  18191. requestId: output.headers["x-amzn-requestid"],
  18192. });
  18193. // Collect low-level response body stream to Uint8Array.
  18194. const collectBody = (streamBody: any = new Uint8Array(), context: __SerdeContext): Promise<Uint8Array> => {
  18195. if (streamBody instanceof Uint8Array) {
  18196. return Promise.resolve(streamBody);
  18197. }
  18198. return context.streamCollector(streamBody) || Promise.resolve(new Uint8Array());
  18199. };
  18200. // Encode Uint8Array data into string with utf-8.
  18201. const collectBodyString = (streamBody: any, context: __SerdeContext): Promise<string> =>
  18202. collectBody(streamBody, context).then((body) => context.utf8Encoder(body));
  18203. const isSerializableHeaderValue = (value: any): boolean =>
  18204. value !== undefined &&
  18205. value !== "" &&
  18206. (!Object.getOwnPropertyNames(value).includes("length") || value.length != 0) &&
  18207. (!Object.getOwnPropertyNames(value).includes("size") || value.size != 0);
  18208. const parseBody = (streamBody: any, context: __SerdeContext): any =>
  18209. collectBodyString(streamBody, context).then((encoded) => {
  18210. if (encoded.length) {
  18211. return JSON.parse(encoded);
  18212. }
  18213. return {};
  18214. });
  18215. /**
  18216. * Load an error code for the aws.rest-json-1.1 protocol.
  18217. */
  18218. const loadRestJsonErrorCode = (output: __HttpResponse, data: any): string => {
  18219. const findKey = (object: any, key: string) => Object.keys(object).find((k) => k.toLowerCase() === key.toLowerCase());
  18220. const sanitizeErrorCode = (rawValue: string): string => {
  18221. let cleanValue = rawValue;
  18222. if (cleanValue.indexOf(":") >= 0) {
  18223. cleanValue = cleanValue.split(":")[0];
  18224. }
  18225. if (cleanValue.indexOf("#") >= 0) {
  18226. cleanValue = cleanValue.split("#")[1];
  18227. }
  18228. return cleanValue;
  18229. };
  18230. const headerKey = findKey(output.headers, "x-amzn-errortype");
  18231. if (headerKey !== undefined) {
  18232. return sanitizeErrorCode(output.headers[headerKey]);
  18233. }
  18234. if (data.code !== undefined) {
  18235. return sanitizeErrorCode(data.code);
  18236. }
  18237. if (data["__type"] !== undefined) {
  18238. return sanitizeErrorCode(data["__type"]);
  18239. }
  18240. return "";
  18241. };