import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse , isValidHostname as __isValidHostname , } from "@aws-sdk/protocol-http" ; import { expectNonNull as __expectNonNull , expectString as __expectString , extendedEncodeURIComponent as __extendedEncodeURIComponent , getArrayIfSingleItem as __getArrayIfSingleItem , getValueFromTextNode as __getValueFromTextNode , parseBoolean as __parseBoolean , parseEpochTimestamp as __parseEpochTimestamp , parseRfc3339DateTime as __parseRfc3339DateTime , parseRfc7231DateTime as __parseRfc7231DateTime , serializeFloat as __serializeFloat , strictParseByte as __strictParseByte , strictParseFloat as __strictParseFloat , strictParseInt32 as __strictParseInt32 , strictParseLong as __strictParseLong , strictParseShort as __strictParseShort , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { decodeHTML } from "entities" ; import { parse as xmlParse } from "fast-xml-parser" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { EmptyInputAndEmptyOutputCommandInput , EmptyInputAndEmptyOutputCommandOutput , } from "../commands/EmptyInputAndEmptyOutputCommand" ; import { EndpointOperationCommandInput , EndpointOperationCommandOutput } from "../commands/EndpointOperationCommand" ; import { EndpointWithHostLabelOperationCommandInput , EndpointWithHostLabelOperationCommandOutput , } from "../commands/EndpointWithHostLabelOperationCommand" ; import { GreetingWithErrorsCommandInput , GreetingWithErrorsCommandOutput } from "../commands/GreetingWithErrorsCommand" ; import { HostWithPathOperationCommandInput , HostWithPathOperationCommandOutput , } from "../commands/HostWithPathOperationCommand" ; import { IgnoresWrappingXmlNameCommandInput , IgnoresWrappingXmlNameCommandOutput , } from "../commands/IgnoresWrappingXmlNameCommand" ; import { NestedStructuresCommandInput , NestedStructuresCommandOutput } from "../commands/NestedStructuresCommand" ; import { NoInputAndOutputCommandInput , NoInputAndOutputCommandOutput } from "../commands/NoInputAndOutputCommand" ; import { QueryIdempotencyTokenAutoFillCommandInput , QueryIdempotencyTokenAutoFillCommandOutput , } from "../commands/QueryIdempotencyTokenAutoFillCommand" ; import { QueryListsCommandInput , QueryListsCommandOutput } from "../commands/QueryListsCommand" ; import { QueryTimestampsCommandInput , QueryTimestampsCommandOutput } from "../commands/QueryTimestampsCommand" ; import { RecursiveXmlShapesCommandInput , RecursiveXmlShapesCommandOutput } from "../commands/RecursiveXmlShapesCommand" ; import { SimpleInputParamsCommandInput , SimpleInputParamsCommandOutput } from "../commands/SimpleInputParamsCommand" ; import { SimpleScalarXmlPropertiesCommandInput , SimpleScalarXmlPropertiesCommandOutput , } from "../commands/SimpleScalarXmlPropertiesCommand" ; import { XmlBlobsCommandInput , XmlBlobsCommandOutput } from "../commands/XmlBlobsCommand" ; import { XmlEmptyBlobsCommandInput , XmlEmptyBlobsCommandOutput } from "../commands/XmlEmptyBlobsCommand" ; import { XmlEmptyListsCommandInput , XmlEmptyListsCommandOutput } from "../commands/XmlEmptyListsCommand" ; import { XmlEnumsCommandInput , XmlEnumsCommandOutput } from "../commands/XmlEnumsCommand" ; import { XmlListsCommandInput , XmlListsCommandOutput } from "../commands/XmlListsCommand" ; import { XmlNamespacesCommandInput , XmlNamespacesCommandOutput } from "../commands/XmlNamespacesCommand" ; import { XmlTimestampsCommandInput , XmlTimestampsCommandOutput } from "../commands/XmlTimestampsCommand" ; import { ComplexError , ComplexNestedErrorData , EmptyInputAndEmptyOutputInput , EmptyInputAndEmptyOutputOutput , FooEnum , GreetingStruct , GreetingWithErrorsOutput , HostLabelInput , IgnoresWrappingXmlNameOutput , InvalidGreeting , NestedStructuresInput , NestedStructWithList , NoInputAndOutputOutput , QueryIdempotencyTokenAutoFillInput , QueryListsInput , QueryTimestampsInput , RecursiveXmlShapesOutput , RecursiveXmlShapesOutputNested1 , RecursiveXmlShapesOutputNested2 , SimpleInputParamsInput , SimpleScalarXmlPropertiesOutput , StructArg , StructureListMember , XmlBlobsOutput , XmlEnumsOutput , XmlListsOutput , XmlNamespaceNested , XmlNamespacesOutput , XmlTimestampsOutput , } from "../models/models_0" ; export const serializeAws_ec2EmptyInputAndEmptyOutputCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2EmptyInputAndEmptyOutputInput ( input , context ) , Action : "EmptyInputAndEmptyOutput" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2EndpointOperationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "EndpointOperation" , Version : "2020-01-08" , } ) ; let { hostname : resolvedHostname } = await context . endpoint ( ) ; if ( context . disableHostPrefix !== true ) { resolvedHostname = "foo." + resolvedHostname ; if ( ! __isValidHostname ( resolvedHostname ) ) { throw new Error ( "ValidationError: prefixed hostname must be hostname compatible." ) ; } } return buildHttpRpcRequest ( context , headers , "/" , resolvedHostname , body ) ; } ; export const serializeAws_ec2EndpointWithHostLabelOperationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2HostLabelInput ( input , context ) , Action : "EndpointWithHostLabelOperation" , Version : "2020-01-08" , } ) ; let { hostname : resolvedHostname } = await context . endpoint ( ) ; if ( context . disableHostPrefix !== true ) { resolvedHostname = "foo.{label}." + resolvedHostname ; if ( input . label === undefined ) { throw new Error ( "Empty value provided for input host prefix: label." ) ; } resolvedHostname = resolvedHostname . replace ( "{label}" , input . label ! ) ; if ( ! __isValidHostname ( resolvedHostname ) ) { throw new Error ( "ValidationError: prefixed hostname must be hostname compatible." ) ; } } return buildHttpRpcRequest ( context , headers , "/" , resolvedHostname , body ) ; } ; export const serializeAws_ec2GreetingWithErrorsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "GreetingWithErrors" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2HostWithPathOperationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "HostWithPathOperation" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2IgnoresWrappingXmlNameCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "IgnoresWrappingXmlName" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2NestedStructuresCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2NestedStructuresInput ( input , context ) , Action : "NestedStructures" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2NoInputAndOutputCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "NoInputAndOutput" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2QueryIdempotencyTokenAutoFillCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2QueryIdempotencyTokenAutoFillInput ( input , context ) , Action : "QueryIdempotencyTokenAutoFill" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2QueryListsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2QueryListsInput ( input , context ) , Action : "QueryLists" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2QueryTimestampsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2QueryTimestampsInput ( input , context ) , Action : "QueryTimestamps" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2RecursiveXmlShapesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "RecursiveXmlShapes" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2SimpleInputParamsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; let body ; body = buildFormUrlencodedString ( { ... serializeAws_ec2SimpleInputParamsInput ( input , context ) , Action : "SimpleInputParams" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2SimpleScalarXmlPropertiesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "SimpleScalarXmlProperties" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlBlobsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlBlobs" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlEmptyBlobsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlEmptyBlobs" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlEmptyListsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlEmptyLists" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlEnumsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlEnums" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlListsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlLists" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlNamespacesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlNamespaces" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_ec2XmlTimestampsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-www-form-urlencoded" , } ; const body = buildFormUrlencodedString ( { Action : "XmlTimestamps" , Version : "2020-01-08" , } ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_ec2EmptyInputAndEmptyOutputCommand = async ( output , context ) : Promise < EmptyInputAndEmptyOutputCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2EmptyInputAndEmptyOutputCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2EmptyInputAndEmptyOutputOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2EmptyInputAndEmptyOutputCommandError = async ( output , context ) : Promise < EmptyInputAndEmptyOutputCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2EndpointOperationCommand = async ( output , context ) : Promise < EndpointOperationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2EndpointOperationCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2EndpointOperationCommandError = async ( output , context ) : Promise < EndpointOperationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2EndpointWithHostLabelOperationCommand = async ( output , context ) : Promise < EndpointWithHostLabelOperationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2EndpointWithHostLabelOperationCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2EndpointWithHostLabelOperationCommandError = async ( output , context ) : Promise < EndpointWithHostLabelOperationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2GreetingWithErrorsCommand = async ( output , context ) : Promise < GreetingWithErrorsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2GreetingWithErrorsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2GreetingWithErrorsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2GreetingWithErrorsCommandError = async ( output , context ) : Promise < GreetingWithErrorsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ComplexError" : case "aws.protocoltests.ec2#ComplexError" : response = { ... ( await deserializeAws_ec2ComplexErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGreeting" : case "aws.protocoltests.ec2#InvalidGreeting" : response = { ... ( await deserializeAws_ec2InvalidGreetingResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2HostWithPathOperationCommand = async ( output , context ) : Promise < HostWithPathOperationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2HostWithPathOperationCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2HostWithPathOperationCommandError = async ( output , context ) : Promise < HostWithPathOperationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2IgnoresWrappingXmlNameCommand = async ( output , context ) : Promise < IgnoresWrappingXmlNameCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2IgnoresWrappingXmlNameCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2IgnoresWrappingXmlNameOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2IgnoresWrappingXmlNameCommandError = async ( output , context ) : Promise < IgnoresWrappingXmlNameCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2NestedStructuresCommand = async ( output , context ) : Promise < NestedStructuresCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2NestedStructuresCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2NestedStructuresCommandError = async ( output , context ) : Promise < NestedStructuresCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2NoInputAndOutputCommand = async ( output , context ) : Promise < NoInputAndOutputCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2NoInputAndOutputCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2NoInputAndOutputOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2NoInputAndOutputCommandError = async ( output , context ) : Promise < NoInputAndOutputCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2QueryIdempotencyTokenAutoFillCommand = async ( output , context ) : Promise < QueryIdempotencyTokenAutoFillCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2QueryIdempotencyTokenAutoFillCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2QueryIdempotencyTokenAutoFillCommandError = async ( output , context ) : Promise < QueryIdempotencyTokenAutoFillCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2QueryListsCommand = async ( output , context ) : Promise < QueryListsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2QueryListsCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2QueryListsCommandError = async ( output , context ) : Promise < QueryListsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2QueryTimestampsCommand = async ( output , context ) : Promise < QueryTimestampsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2QueryTimestampsCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2QueryTimestampsCommandError = async ( output , context ) : Promise < QueryTimestampsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2RecursiveXmlShapesCommand = async ( output , context ) : Promise < RecursiveXmlShapesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2RecursiveXmlShapesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2RecursiveXmlShapesOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2RecursiveXmlShapesCommandError = async ( output , context ) : Promise < RecursiveXmlShapesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2SimpleInputParamsCommand = async ( output , context ) : Promise < SimpleInputParamsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2SimpleInputParamsCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2SimpleInputParamsCommandError = async ( output , context ) : Promise < SimpleInputParamsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2SimpleScalarXmlPropertiesCommand = async ( output , context ) : Promise < SimpleScalarXmlPropertiesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2SimpleScalarXmlPropertiesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2SimpleScalarXmlPropertiesOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2SimpleScalarXmlPropertiesCommandError = async ( output , context ) : Promise < SimpleScalarXmlPropertiesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlBlobsCommand = async ( output , context ) : Promise < XmlBlobsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlBlobsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlBlobsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlBlobsCommandError = async ( output , context ) : Promise < XmlBlobsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlEmptyBlobsCommand = async ( output , context ) : Promise < XmlEmptyBlobsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlEmptyBlobsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlBlobsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlEmptyBlobsCommandError = async ( output , context ) : Promise < XmlEmptyBlobsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlEmptyListsCommand = async ( output , context ) : Promise < XmlEmptyListsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlEmptyListsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlListsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlEmptyListsCommandError = async ( output , context ) : Promise < XmlEmptyListsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlEnumsCommand = async ( output , context ) : Promise < XmlEnumsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlEnumsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlEnumsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlEnumsCommandError = async ( output , context ) : Promise < XmlEnumsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlListsCommand = async ( output , context ) : Promise < XmlListsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlListsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlListsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlListsCommandError = async ( output , context ) : Promise < XmlListsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlNamespacesCommand = async ( output , context ) : Promise < XmlNamespacesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlNamespacesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlNamespacesOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlNamespacesCommandError = async ( output , context ) : Promise < XmlNamespacesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_ec2XmlTimestampsCommand = async ( output , context ) : Promise < XmlTimestampsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_ec2XmlTimestampsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_ec2XmlTimestampsOutput ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_ec2XmlTimestampsCommandError = async ( output , context ) : Promise < XmlTimestampsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadEc2ErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . Errors . Error . code || parsedBody . Errors . Error . Code || errorCode ; response = { ... parsedBody . Errors . Error , name : `${ errorCode }` , message : parsedBody . Errors . Error . message || parsedBody . Errors . Error . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; const deserializeAws_ec2ComplexErrorResponse = async ( parsedOutput , context ) : Promise < ComplexError > => { const body = parsedOutput . body ; const deserialized = deserializeAws_ec2ComplexError ( body . Errors . Error , context ) ; const contents = { name : "ComplexError" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_ec2InvalidGreetingResponse = async ( parsedOutput , context ) : Promise < InvalidGreeting > => { const body = parsedOutput . body ; const deserialized = deserializeAws_ec2InvalidGreeting ( body . Errors . Error , context ) ; const contents = { name : "InvalidGreeting" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_ec2EmptyInputAndEmptyOutputInput = ( input , context ) : any => { const entries = { } ; return entries ; } ; const serializeAws_ec2HostLabelInput = ( input , context ) : any => { const entries = { } ; if ( input . label !== undefined && input . label !== null ) { entries [ "Label" ] = input . label ; } return entries ; } ; const serializeAws_ec2ListWithXmlName = ( input , context ) : any => { const entries = { } ; let counter = 1 ; for ( const entry of input ) { if ( entry === null ) { continue ; } entries [ `Item.${ counter }` ] = entry ; counter ++ ; } return entries ; } ; const serializeAws_ec2NestedStructuresInput = ( input , context ) : any => { const entries = { } ; if ( input . Nested !== undefined && input . Nested !== null ) { const memberEntries = serializeAws_ec2StructArg ( input . Nested , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `Nested.${ key }` ; entries [ loc ] = value ; } ) ; } return entries ; } ; const serializeAws_ec2NestedStructWithList = ( input , context ) : any => { const entries = { } ; if ( input . ListArg !== undefined && input . ListArg !== null ) { const memberEntries = serializeAws_ec2StringList ( input . ListArg , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `ListArg.${ key . substring ( key . indexOf ( "." ) + 1 ) }` ; entries [ loc ] = value ; } ) ; } return entries ; } ; const serializeAws_ec2QueryIdempotencyTokenAutoFillInput = ( input , context ) : any => { const entries = { } ; if ( input . token === undefined ) { input . token = generateIdempotencyToken ( ) ; } if ( input . token !== undefined && input . token !== null ) { entries [ "Token" ] = input . token ; } return entries ; } ; const serializeAws_ec2QueryListsInput = ( input , context ) : any => { const entries = { } ; if ( input . ListArg !== undefined && input . ListArg !== null ) { const memberEntries = serializeAws_ec2StringList ( input . ListArg , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `ListArg.${ key . substring ( key . indexOf ( "." ) + 1 ) }` ; entries [ loc ] = value ; } ) ; } if ( input . ComplexListArg !== undefined && input . ComplexListArg !== null ) { const memberEntries = serializeAws_ec2GreetingList ( input . ComplexListArg , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `ComplexListArg.${ key . substring ( key . indexOf ( "." ) + 1 ) }` ; entries [ loc ] = value ; } ) ; } if ( input . ListArgWithXmlNameMember !== undefined && input . ListArgWithXmlNameMember !== null ) { const memberEntries = serializeAws_ec2ListWithXmlName ( input . ListArgWithXmlNameMember , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `ListArgWithXmlNameMember.${ key . substring ( key . indexOf ( "." ) + 1 ) }` ; entries [ loc ] = value ; } ) ; } if ( input . ListArgWithXmlName !== undefined && input . ListArgWithXmlName !== null ) { const memberEntries = serializeAws_ec2ListWithXmlName ( input . ListArgWithXmlName , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `Hi.${ key . substring ( key . indexOf ( "." ) + 1 ) }` ; entries [ loc ] = value ; } ) ; } if ( input . NestedWithList !== undefined && input . NestedWithList !== null ) { const memberEntries = serializeAws_ec2NestedStructWithList ( input . NestedWithList , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `NestedWithList.${ key }` ; entries [ loc ] = value ; } ) ; } return entries ; } ; const serializeAws_ec2QueryTimestampsInput = ( input , context ) : any => { const entries = { } ; if ( input . normalFormat !== undefined && input . normalFormat !== null ) { entries [ "NormalFormat" ] = input . normalFormat . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ; } if ( input . epochMember !== undefined && input . epochMember !== null ) { entries [ "EpochMember" ] = Math . round ( input . epochMember . getTime ( ) / 1000 ) ; } if ( input . epochTarget !== undefined && input . epochTarget !== null ) { entries [ "EpochTarget" ] = Math . round ( input . epochTarget . getTime ( ) / 1000 ) ; } return entries ; } ; const serializeAws_ec2SimpleInputParamsInput = ( input , context ) : any => { const entries = { } ; if ( input . Foo !== undefined && input . Foo !== null ) { entries [ "Foo" ] = input . Foo ; } if ( input . Bar !== undefined && input . Bar !== null ) { entries [ "Bar" ] = input . Bar ; } if ( input . Baz !== undefined && input . Baz !== null ) { entries [ "Baz" ] = input . Baz ; } if ( input . Bam !== undefined && input . Bam !== null ) { entries [ "Bam" ] = input . Bam ; } if ( input . FloatValue !== undefined && input . FloatValue !== null ) { entries [ "FloatValue" ] = __serializeFloat ( input . FloatValue ) ; } if ( input . Boo !== undefined && input . Boo !== null ) { entries [ "Boo" ] = __serializeFloat ( input . Boo ) ; } if ( input . Qux !== undefined && input . Qux !== null ) { entries [ "Qux" ] = context . base64Encoder ( input . Qux ) ; } if ( input . FooEnum !== undefined && input . FooEnum !== null ) { entries [ "FooEnum" ] = input . FooEnum ; } if ( input . HasQueryName !== undefined && input . HasQueryName !== null ) { entries [ "A" ] = input . HasQueryName ; } if ( input . HasQueryAndXmlName !== undefined && input . HasQueryAndXmlName !== null ) { entries [ "B" ] = input . HasQueryAndXmlName ; } if ( input . UsesXmlName !== undefined && input . UsesXmlName !== null ) { entries [ "C" ] = input . UsesXmlName ; } return entries ; } ; const serializeAws_ec2StructArg = ( input , context ) : any => { const entries = { } ; if ( input . StringArg !== undefined && input . StringArg !== null ) { entries [ "StringArg" ] = input . StringArg ; } if ( input . OtherArg !== undefined && input . OtherArg !== null ) { entries [ "OtherArg" ] = input . OtherArg ; } if ( input . RecursiveArg !== undefined && input . RecursiveArg !== null ) { const memberEntries = serializeAws_ec2StructArg ( input . RecursiveArg , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { const loc = `RecursiveArg.${ key }` ; entries [ loc ] = value ; } ) ; } return entries ; } ; const serializeAws_ec2GreetingList = ( input , context ) : any => { const entries = { } ; let counter = 1 ; for ( const entry of input ) { if ( entry === null ) { continue ; } const memberEntries = serializeAws_ec2GreetingStruct ( entry , context ) ; Object . entries ( memberEntries ) . forEach ( ( [ key , value ] ) => { entries [ `Member.${ counter }.${ key }` ] = value ; } ) ; counter ++ ; } return entries ; } ; const serializeAws_ec2GreetingStruct = ( input , context ) : any => { const entries = { } ; if ( input . hi !== undefined && input . hi !== null ) { entries [ "Hi" ] = input . hi ; } return entries ; } ; const serializeAws_ec2StringList = ( input , context ) : any => { const entries = { } ; let counter = 1 ; for ( const entry of input ) { if ( entry === null ) { continue ; } entries [ `Member.${ counter }` ] = entry ; counter ++ ; } return entries ; } ; const deserializeAws_ec2ComplexError = ( output , context ) : ComplexError => { const contents = { TopLevel : undefined , Nested : undefined , } ; if ( output [ "TopLevel" ] !== undefined ) { contents . TopLevel = __expectString ( output [ "TopLevel" ] ) ; } if ( output [ "Nested" ] !== undefined ) { contents . Nested = deserializeAws_ec2ComplexNestedErrorData ( output [ "Nested" ] , context ) ; } return contents ; } ; const deserializeAws_ec2ComplexNestedErrorData = ( output , context ) : ComplexNestedErrorData => { const contents = { Foo : undefined , } ; if ( output [ "Foo" ] !== undefined ) { contents . Foo = __expectString ( output [ "Foo" ] ) ; } return contents ; } ; const deserializeAws_ec2EmptyInputAndEmptyOutputOutput = ( output , context ) : EmptyInputAndEmptyOutputOutput => { const contents = { } ; return contents ; } ; const deserializeAws_ec2GreetingWithErrorsOutput = ( output , context ) : GreetingWithErrorsOutput => { const contents = { greeting : undefined , } ; if ( output [ "greeting" ] !== undefined ) { contents . greeting = __expectString ( output [ "greeting" ] ) ; } return contents ; } ; const deserializeAws_ec2IgnoresWrappingXmlNameOutput = ( output , context ) : IgnoresWrappingXmlNameOutput => { const contents = { foo : undefined , } ; if ( output [ "foo" ] !== undefined ) { contents . foo = __expectString ( output [ "foo" ] ) ; } return contents ; } ; const deserializeAws_ec2InvalidGreeting = ( output , context ) : InvalidGreeting => { const contents = { Message : undefined , } ; if ( output [ "Message" ] !== undefined ) { contents . Message = __expectString ( output [ "Message" ] ) ; } return contents ; } ; const deserializeAws_ec2ListWithMemberNamespace = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2ListWithNamespace = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2NoInputAndOutputOutput = ( output , context ) : NoInputAndOutputOutput => { const contents = { } ; return contents ; } ; const deserializeAws_ec2RecursiveXmlShapesOutput = ( output , context ) : RecursiveXmlShapesOutput => { const contents = { nested : undefined , } ; if ( output [ "nested" ] !== undefined ) { contents . nested = deserializeAws_ec2RecursiveXmlShapesOutputNested1 ( output [ "nested" ] , context ) ; } return contents ; } ; const deserializeAws_ec2RecursiveXmlShapesOutputNested1 = ( output , context ) : RecursiveXmlShapesOutputNested1 => { const contents = { foo : undefined , nested : undefined , } ; if ( output [ "foo" ] !== undefined ) { contents . foo = __expectString ( output [ "foo" ] ) ; } if ( output [ "nested" ] !== undefined ) { contents . nested = deserializeAws_ec2RecursiveXmlShapesOutputNested2 ( output [ "nested" ] , context ) ; } return contents ; } ; const deserializeAws_ec2RecursiveXmlShapesOutputNested2 = ( output , context ) : RecursiveXmlShapesOutputNested2 => { const contents = { bar : undefined , recursiveMember : undefined , } ; if ( output [ "bar" ] !== undefined ) { contents . bar = __expectString ( output [ "bar" ] ) ; } if ( output [ "recursiveMember" ] !== undefined ) { contents . recursiveMember = deserializeAws_ec2RecursiveXmlShapesOutputNested1 ( output [ "recursiveMember" ] , context ) ; } return contents ; } ; const deserializeAws_ec2RenamedListMembers = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2SimpleScalarXmlPropertiesOutput = ( output , context ) : SimpleScalarXmlPropertiesOutput => { const contents = { stringValue : undefined , emptyStringValue : undefined , trueBooleanValue : undefined , falseBooleanValue : undefined , byteValue : undefined , shortValue : undefined , integerValue : undefined , longValue : undefined , floatValue : undefined , doubleValue : undefined , } ; if ( output [ "stringValue" ] !== undefined ) { contents . stringValue = __expectString ( output [ "stringValue" ] ) ; } if ( output [ "emptyStringValue" ] !== undefined ) { contents . emptyStringValue = __expectString ( output [ "emptyStringValue" ] ) ; } if ( output [ "trueBooleanValue" ] !== undefined ) { contents . trueBooleanValue = __parseBoolean ( output [ "trueBooleanValue" ] ) ; } if ( output [ "falseBooleanValue" ] !== undefined ) { contents . falseBooleanValue = __parseBoolean ( output [ "falseBooleanValue" ] ) ; } if ( output [ "byteValue" ] !== undefined ) { contents . byteValue = __strictParseByte ( output [ "byteValue" ] ) as number ; } if ( output [ "shortValue" ] !== undefined ) { contents . shortValue = __strictParseShort ( output [ "shortValue" ] ) as number ; } if ( output [ "integerValue" ] !== undefined ) { contents . integerValue = __strictParseInt32 ( output [ "integerValue" ] ) as number ; } if ( output [ "longValue" ] !== undefined ) { contents . longValue = __strictParseLong ( output [ "longValue" ] ) as number ; } if ( output [ "floatValue" ] !== undefined ) { contents . floatValue = __strictParseFloat ( output [ "floatValue" ] ) as number ; } if ( output [ "DoubleDribble" ] !== undefined ) { contents . doubleValue = __strictParseFloat ( output [ "DoubleDribble" ] ) as number ; } return contents ; } ; const deserializeAws_ec2StructureList = ( output , context ) : StructureListMember [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_ec2StructureListMember ( entry , context ) ; } ) ; } ; const deserializeAws_ec2StructureListMember = ( output , context ) : StructureListMember => { const contents = { a : undefined , b : undefined , } ; if ( output [ "value" ] !== undefined ) { contents . a = __expectString ( output [ "value" ] ) ; } if ( output [ "other" ] !== undefined ) { contents . b = __expectString ( output [ "other" ] ) ; } return contents ; } ; const deserializeAws_ec2XmlBlobsOutput = ( output , context ) : XmlBlobsOutput => { const contents = { data : undefined , } ; if ( output [ "data" ] !== undefined ) { contents . data = context . base64Decoder ( output [ "data" ] ) ; } return contents ; } ; const deserializeAws_ec2XmlEnumsOutput = ( output , context ) : XmlEnumsOutput => { const contents = { fooEnum1 : undefined , fooEnum2 : undefined , fooEnum3 : undefined , fooEnumList : undefined , fooEnumSet : undefined , fooEnumMap : undefined , } ; if ( output [ "fooEnum1" ] !== undefined ) { contents . fooEnum1 = __expectString ( output [ "fooEnum1" ] ) ; } if ( output [ "fooEnum2" ] !== undefined ) { contents . fooEnum2 = __expectString ( output [ "fooEnum2" ] ) ; } if ( output [ "fooEnum3" ] !== undefined ) { contents . fooEnum3 = __expectString ( output [ "fooEnum3" ] ) ; } if ( output . fooEnumList === "" ) { contents . fooEnumList = [ ] ; } if ( output [ "fooEnumList" ] !== undefined && output [ "fooEnumList" ] [ "member" ] !== undefined ) { contents . fooEnumList = deserializeAws_ec2FooEnumList ( __getArrayIfSingleItem ( output [ "fooEnumList" ] [ "member" ] ) , context ) ; } if ( output . fooEnumSet === "" ) { contents . fooEnumSet = [ ] ; } if ( output [ "fooEnumSet" ] !== undefined && output [ "fooEnumSet" ] [ "member" ] !== undefined ) { contents . fooEnumSet = deserializeAws_ec2FooEnumSet ( __getArrayIfSingleItem ( output [ "fooEnumSet" ] [ "member" ] ) , context ) ; } if ( output . fooEnumMap === "" ) { contents . fooEnumMap = { } ; } if ( output [ "fooEnumMap" ] !== undefined && output [ "fooEnumMap" ] [ "entry" ] !== undefined ) { contents . fooEnumMap = deserializeAws_ec2FooEnumMap ( __getArrayIfSingleItem ( output [ "fooEnumMap" ] [ "entry" ] ) , context ) ; } return contents ; } ; const deserializeAws_ec2XmlListsOutput = ( output , context ) : XmlListsOutput => { const contents = { stringList : undefined , stringSet : undefined , integerList : undefined , booleanList : undefined , timestampList : undefined , enumList : undefined , nestedStringList : undefined , renamedListMembers : undefined , flattenedList : undefined , flattenedList2 : undefined , flattenedListWithMemberNamespace : undefined , flattenedListWithNamespace : undefined , structureList : undefined , } ; if ( output . stringList === "" ) { contents . stringList = [ ] ; } if ( output [ "stringList" ] !== undefined && output [ "stringList" ] [ "member" ] !== undefined ) { contents . stringList = deserializeAws_ec2StringList ( __getArrayIfSingleItem ( output [ "stringList" ] [ "member" ] ) , context ) ; } if ( output . stringSet === "" ) { contents . stringSet = [ ] ; } if ( output [ "stringSet" ] !== undefined && output [ "stringSet" ] [ "member" ] !== undefined ) { contents . stringSet = deserializeAws_ec2StringSet ( __getArrayIfSingleItem ( output [ "stringSet" ] [ "member" ] ) , context ) ; } if ( output . integerList === "" ) { contents . integerList = [ ] ; } if ( output [ "integerList" ] !== undefined && output [ "integerList" ] [ "member" ] !== undefined ) { contents . integerList = deserializeAws_ec2IntegerList ( __getArrayIfSingleItem ( output [ "integerList" ] [ "member" ] ) , context ) ; } if ( output . booleanList === "" ) { contents . booleanList = [ ] ; } if ( output [ "booleanList" ] !== undefined && output [ "booleanList" ] [ "member" ] !== undefined ) { contents . booleanList = deserializeAws_ec2BooleanList ( __getArrayIfSingleItem ( output [ "booleanList" ] [ "member" ] ) , context ) ; } if ( output . timestampList === "" ) { contents . timestampList = [ ] ; } if ( output [ "timestampList" ] !== undefined && output [ "timestampList" ] [ "member" ] !== undefined ) { contents . timestampList = deserializeAws_ec2TimestampList ( __getArrayIfSingleItem ( output [ "timestampList" ] [ "member" ] ) , context ) ; } if ( output . enumList === "" ) { contents . enumList = [ ] ; } if ( output [ "enumList" ] !== undefined && output [ "enumList" ] [ "member" ] !== undefined ) { contents . enumList = deserializeAws_ec2FooEnumList ( __getArrayIfSingleItem ( output [ "enumList" ] [ "member" ] ) , context ) ; } if ( output . nestedStringList === "" ) { contents . nestedStringList = [ ] ; } if ( output [ "nestedStringList" ] !== undefined && output [ "nestedStringList" ] [ "member" ] !== undefined ) { contents . nestedStringList = deserializeAws_ec2NestedStringList ( __getArrayIfSingleItem ( output [ "nestedStringList" ] [ "member" ] ) , context ) ; } if ( output . renamed === "" ) { contents . renamedListMembers = [ ] ; } if ( output [ "renamed" ] !== undefined && output [ "renamed" ] [ "item" ] !== undefined ) { contents . renamedListMembers = deserializeAws_ec2RenamedListMembers ( __getArrayIfSingleItem ( output [ "renamed" ] [ "item" ] ) , context ) ; } if ( output . flattenedList === "" ) { contents . flattenedList = [ ] ; } if ( output [ "flattenedList" ] !== undefined ) { contents . flattenedList = deserializeAws_ec2RenamedListMembers ( __getArrayIfSingleItem ( output [ "flattenedList" ] ) , context ) ; } if ( output . customName === "" ) { contents . flattenedList2 = [ ] ; } if ( output [ "customName" ] !== undefined ) { contents . flattenedList2 = deserializeAws_ec2RenamedListMembers ( __getArrayIfSingleItem ( output [ "customName" ] ) , context ) ; } if ( output . flattenedListWithMemberNamespace === "" ) { contents . flattenedListWithMemberNamespace = [ ] ; } if ( output [ "flattenedListWithMemberNamespace" ] !== undefined ) { contents . flattenedListWithMemberNamespace = deserializeAws_ec2ListWithMemberNamespace ( __getArrayIfSingleItem ( output [ "flattenedListWithMemberNamespace" ] ) , context ) ; } if ( output . flattenedListWithNamespace === "" ) { contents . flattenedListWithNamespace = [ ] ; } if ( output [ "flattenedListWithNamespace" ] !== undefined ) { contents . flattenedListWithNamespace = deserializeAws_ec2ListWithNamespace ( __getArrayIfSingleItem ( output [ "flattenedListWithNamespace" ] ) , context ) ; } if ( output . myStructureList === "" ) { contents . structureList = [ ] ; } if ( output [ "myStructureList" ] !== undefined && output [ "myStructureList" ] [ "item" ] !== undefined ) { contents . structureList = deserializeAws_ec2StructureList ( __getArrayIfSingleItem ( output [ "myStructureList" ] [ "item" ] ) , context ) ; } return contents ; } ; const deserializeAws_ec2XmlNamespacedList = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2XmlNamespaceNested = ( output , context ) : XmlNamespaceNested => { const contents = { foo : undefined , values : undefined , } ; if ( output [ "foo" ] !== undefined ) { contents . foo = __expectString ( output [ "foo" ] ) ; } if ( output . values === "" ) { contents . values = [ ] ; } if ( output [ "values" ] !== undefined && output [ "values" ] [ "member" ] !== undefined ) { contents . values = deserializeAws_ec2XmlNamespacedList ( __getArrayIfSingleItem ( output [ "values" ] [ "member" ] ) , context ) ; } return contents ; } ; const deserializeAws_ec2XmlNamespacesOutput = ( output , context ) : XmlNamespacesOutput => { const contents = { nested : undefined , } ; if ( output [ "nested" ] !== undefined ) { contents . nested = deserializeAws_ec2XmlNamespaceNested ( output [ "nested" ] , context ) ; } return contents ; } ; const deserializeAws_ec2XmlTimestampsOutput = ( output , context ) : XmlTimestampsOutput => { const contents = { normal : undefined , dateTime : undefined , epochSeconds : undefined , httpDate : undefined , } ; if ( output [ "normal" ] !== undefined ) { contents . normal = __expectNonNull ( __parseRfc3339DateTime ( output [ "normal" ] ) ) ; } if ( output [ "dateTime" ] !== undefined ) { contents . dateTime = __expectNonNull ( __parseRfc3339DateTime ( output [ "dateTime" ] ) ) ; } if ( output [ "epochSeconds" ] !== undefined ) { contents . epochSeconds = __expectNonNull ( __parseEpochTimestamp ( output [ "epochSeconds" ] ) ) ; } if ( output [ "httpDate" ] !== undefined ) { contents . httpDate = __expectNonNull ( __parseRfc7231DateTime ( output [ "httpDate" ] ) ) ; } return contents ; } ; const deserializeAws_ec2BooleanList = ( output , context ) : boolean [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __parseBoolean ( entry ) ; } ) ; } ; const deserializeAws_ec2FooEnumList = ( output , context ) : ( FooEnum | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2FooEnumMap = ( output , context ) : { [ key ] : FooEnum | string ; } => { return output . reduce ( ( acc , pair ) => { if ( pair [ "value" ] === null ) { return acc ; } return { ... acc , [ pair [ "key" ] ] : __expectString ( pair [ "value" ] ) as any , } ; } , { } ) ; } ; const deserializeAws_ec2FooEnumSet = ( output , context ) : ( FooEnum | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2IntegerList = ( output , context ) : number [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __strictParseInt32 ( entry ) as number ; } ) ; } ; const deserializeAws_ec2NestedStringList = ( output , context ) : string [ ] [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_ec2StringList ( __getArrayIfSingleItem ( entry [ "member" ] ) , context ) ; } ) ; } ; const deserializeAws_ec2StringList = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2StringSet = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_ec2TimestampList = ( output , context ) : Date [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectNonNull ( __parseRfc3339DateTime ( entry ) ) ; } ) ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { const parsedObj = xmlParse ( encoded , { attributeNamePrefix : "" , ignoreAttributes : false , parseNodeValue : false , trimValues : false , tagValueProcessor : ( val ) => ( val . trim ( ) === "" && val . includes ( "\n" ) ? "" : decodeHTML ( val ) ) , } ) ; const textNodeName = "#text" ; const key = Object . keys ( parsedObj ) [ 0 ] ; const parsedObjToReturn = parsedObj [ key ] ; if ( parsedObjToReturn [ textNodeName ] ) { parsedObjToReturn [ key ] = parsedObjToReturn [ textNodeName ] ; delete parsedObjToReturn [ textNodeName ] ; } return __getValueFromTextNode ( parsedObjToReturn ) ; } return { } ; } ) ; const buildFormUrlencodedString = ( formEntries ) : string => Object . entries ( formEntries ) . map ( ( [ key , value ] ) => __extendedEncodeURIComponent ( key ) + "=" + __extendedEncodeURIComponent ( value ) ) . join ( "&" ) ; const loadEc2ErrorCode = ( output , data ) : string => { if ( data . Errors . Error . Code !== undefined ) { return data . Errors . Error . Code ; } if ( output . statusCode == 404 ) { return "NotFound" ; } return "" ; } ;