import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , parseEpochTimestamp as __parseEpochTimestamp , } 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 { CloseTunnelCommandInput , CloseTunnelCommandOutput } from "../commands/CloseTunnelCommand" ; import { DescribeTunnelCommandInput , DescribeTunnelCommandOutput } from "../commands/DescribeTunnelCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { ListTunnelsCommandInput , ListTunnelsCommandOutput } from "../commands/ListTunnelsCommand" ; import { OpenTunnelCommandInput , OpenTunnelCommandOutput } from "../commands/OpenTunnelCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { CloseTunnelRequest , CloseTunnelResponse , ConnectionState , DescribeTunnelRequest , DescribeTunnelResponse , DestinationConfig , LimitExceededException , ListTagsForResourceRequest , ListTagsForResourceResponse , ListTunnelsRequest , ListTunnelsResponse , OpenTunnelRequest , OpenTunnelResponse , ResourceNotFoundException , Tag , TagResourceRequest , TagResourceResponse , TimeoutConfig , Tunnel , TunnelSummary , UntagResourceRequest , UntagResourceResponse , } from "../models/models_0" ; export const serializeAws_json1_1CloseTunnelCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.CloseTunnel" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CloseTunnelRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeTunnelCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.DescribeTunnel" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeTunnelRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.ListTagsForResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListTagsForResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListTunnelsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.ListTunnels" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListTunnelsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1OpenTunnelCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.OpenTunnel" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1OpenTunnelRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1TagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.TagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1TagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UntagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "IoTSecuredTunneling.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1CloseTunnelCommand = async ( output , context ) : Promise < CloseTunnelCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CloseTunnelCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CloseTunnelResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CloseTunnelCommandError = async ( output , context ) : Promise < CloseTunnelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1DescribeTunnelCommand = async ( output , context ) : Promise < DescribeTunnelCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeTunnelCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeTunnelResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeTunnelCommandError = async ( output , context ) : Promise < DescribeTunnelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListTagsForResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListTagsForResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1ListTunnelsCommand = async ( output , context ) : Promise < ListTunnelsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListTunnelsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListTunnelsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListTunnelsCommandError = async ( output , context ) : Promise < ListTunnelsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1OpenTunnelCommand = async ( output , context ) : Promise < OpenTunnelCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1OpenTunnelCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1OpenTunnelResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1OpenTunnelCommandError = async ( output , context ) : Promise < OpenTunnelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "LimitExceededException" : case "com.amazonaws.iotsecuretunneling#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1TagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1TagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UntagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UntagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.iotsecuretunneling#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . 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_json1_1LimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < LimitExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1LimitExceededException ( body , context ) ; const contents = { name : "LimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceNotFoundException ( body , context ) ; const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_1CloseTunnelRequest = ( input , context ) : any => { return { ... ( input . delete !== undefined && input . delete !== null && { delete : input . delete } ) , ... ( input . tunnelId !== undefined && input . tunnelId !== null && { tunnelId : input . tunnelId } ) , } ; } ; const serializeAws_json1_1DescribeTunnelRequest = ( input , context ) : any => { return { ... ( input . tunnelId !== undefined && input . tunnelId !== null && { tunnelId : input . tunnelId } ) , } ; } ; const serializeAws_json1_1DestinationConfig = ( input , context ) : any => { return { ... ( input . services !== undefined && input . services !== null && { services : serializeAws_json1_1ServiceList ( input . services , context ) } ) , ... ( input . thingName !== undefined && input . thingName !== null && { thingName : input . thingName } ) , } ; } ; const serializeAws_json1_1ListTagsForResourceRequest = ( input , context ) : any => { return { ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , } ; } ; const serializeAws_json1_1ListTunnelsRequest = ( input , context ) : any => { return { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . thingName !== undefined && input . thingName !== null && { thingName : input . thingName } ) , } ; } ; const serializeAws_json1_1OpenTunnelRequest = ( input , context ) : any => { return { ... ( input . description !== undefined && input . description !== null && { description : input . description } ) , ... ( input . destinationConfig !== undefined && input . destinationConfig !== null && { destinationConfig : serializeAws_json1_1DestinationConfig ( input . destinationConfig , context ) , } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_json1_1TagList ( input . tags , context ) } ) , ... ( input . timeoutConfig !== undefined && input . timeoutConfig !== null && { timeoutConfig : serializeAws_json1_1TimeoutConfig ( input . timeoutConfig , context ) , } ) , } ; } ; const serializeAws_json1_1ServiceList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1Tag = ( input , context ) : any => { return { ... ( input . key !== undefined && input . key !== null && { key : input . key } ) , ... ( input . value !== undefined && input . value !== null && { value : input . value } ) , } ; } ; const serializeAws_json1_1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const serializeAws_json1_1TagResourceRequest = ( input , context ) : any => { return { ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_json1_1TagList ( input . tags , context ) } ) , } ; } ; const serializeAws_json1_1TimeoutConfig = ( input , context ) : any => { return { ... ( input . maxLifetimeTimeoutMinutes !== undefined && input . maxLifetimeTimeoutMinutes !== null && { maxLifetimeTimeoutMinutes : input . maxLifetimeTimeoutMinutes } ) , } ; } ; const serializeAws_json1_1UntagResourceRequest = ( input , context ) : any => { return { ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , ... ( input . tagKeys !== undefined && input . tagKeys !== null && { tagKeys : serializeAws_json1_1TagKeyList ( input . tagKeys , context ) } ) , } ; } ; const deserializeAws_json1_1CloseTunnelResponse = ( output , context ) : CloseTunnelResponse => { return { } as any ; } ; const deserializeAws_json1_1ConnectionState = ( output , context ) : ConnectionState => { return { lastUpdatedAt : output . lastUpdatedAt !== undefined && output . lastUpdatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedAt ) ) ) : undefined , status : __expectString ( output . status ) , } as any ; } ; const deserializeAws_json1_1DescribeTunnelResponse = ( output , context ) : DescribeTunnelResponse => { return { tunnel : output . tunnel !== undefined && output . tunnel !== null ? deserializeAws_json1_1Tunnel ( output . tunnel , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DestinationConfig = ( output , context ) : DestinationConfig => { return { services : output . services !== undefined && output . services !== null ? deserializeAws_json1_1ServiceList ( output . services , context ) : undefined , thingName : __expectString ( output . thingName ) , } as any ; } ; const deserializeAws_json1_1LimitExceededException = ( output , context ) : LimitExceededException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1ListTagsForResourceResponse = ( output , context ) : ListTagsForResourceResponse => { return { tags : output . tags !== undefined && output . tags !== null ? deserializeAws_json1_1TagList ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ListTunnelsResponse = ( output , context ) : ListTunnelsResponse => { return { nextToken : __expectString ( output . nextToken ) , tunnelSummaries : output . tunnelSummaries !== undefined && output . tunnelSummaries !== null ? deserializeAws_json1_1TunnelSummaryList ( output . tunnelSummaries , context ) : undefined , } as any ; } ; const deserializeAws_json1_1OpenTunnelResponse = ( output , context ) : OpenTunnelResponse => { return { destinationAccessToken : __expectString ( output . destinationAccessToken ) , sourceAccessToken : __expectString ( output . sourceAccessToken ) , tunnelArn : __expectString ( output . tunnelArn ) , tunnelId : __expectString ( output . tunnelId ) , } as any ; } ; const deserializeAws_json1_1ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1ServiceList = ( 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_json1_1Tag = ( output , context ) : Tag => { return { key : __expectString ( output . key ) , value : __expectString ( output . value ) , } as any ; } ; const deserializeAws_json1_1TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1TagResourceResponse = ( output , context ) : TagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_1TimeoutConfig = ( output , context ) : TimeoutConfig => { return { maxLifetimeTimeoutMinutes : __expectInt32 ( output . maxLifetimeTimeoutMinutes ) , } as any ; } ; const deserializeAws_json1_1Tunnel = ( output , context ) : Tunnel => { return { createdAt : output . createdAt !== undefined && output . createdAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . createdAt ) ) ) : undefined , description : __expectString ( output . description ) , destinationConfig : output . destinationConfig !== undefined && output . destinationConfig !== null ? deserializeAws_json1_1DestinationConfig ( output . destinationConfig , context ) : undefined , destinationConnectionState : output . destinationConnectionState !== undefined && output . destinationConnectionState !== null ? deserializeAws_json1_1ConnectionState ( output . destinationConnectionState , context ) : undefined , lastUpdatedAt : output . lastUpdatedAt !== undefined && output . lastUpdatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedAt ) ) ) : undefined , sourceConnectionState : output . sourceConnectionState !== undefined && output . sourceConnectionState !== null ? deserializeAws_json1_1ConnectionState ( output . sourceConnectionState , context ) : undefined , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_json1_1TagList ( output . tags , context ) : undefined , timeoutConfig : output . timeoutConfig !== undefined && output . timeoutConfig !== null ? deserializeAws_json1_1TimeoutConfig ( output . timeoutConfig , context ) : undefined , tunnelArn : __expectString ( output . tunnelArn ) , tunnelId : __expectString ( output . tunnelId ) , } as any ; } ; const deserializeAws_json1_1TunnelSummary = ( output , context ) : TunnelSummary => { return { createdAt : output . createdAt !== undefined && output . createdAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . createdAt ) ) ) : undefined , description : __expectString ( output . description ) , lastUpdatedAt : output . lastUpdatedAt !== undefined && output . lastUpdatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedAt ) ) ) : undefined , status : __expectString ( output . status ) , tunnelArn : __expectString ( output . tunnelArn ) , tunnelId : __expectString ( output . tunnelId ) , } as any ; } ; const deserializeAws_json1_1TunnelSummaryList = ( output , context ) : TunnelSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1TunnelSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1UntagResourceResponse = ( output , context ) : UntagResourceResponse => { return { } as any ; } ; 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 ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;