import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectObject as __expectObject , expectString as __expectString , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { CreateSignalingChannelCommandInput , CreateSignalingChannelCommandOutput , } from "../commands/CreateSignalingChannelCommand" ; import { CreateStreamCommandInput , CreateStreamCommandOutput } from "../commands/CreateStreamCommand" ; import { DeleteSignalingChannelCommandInput , DeleteSignalingChannelCommandOutput , } from "../commands/DeleteSignalingChannelCommand" ; import { DeleteStreamCommandInput , DeleteStreamCommandOutput } from "../commands/DeleteStreamCommand" ; import { DescribeSignalingChannelCommandInput , DescribeSignalingChannelCommandOutput , } from "../commands/DescribeSignalingChannelCommand" ; import { DescribeStreamCommandInput , DescribeStreamCommandOutput } from "../commands/DescribeStreamCommand" ; import { GetDataEndpointCommandInput , GetDataEndpointCommandOutput } from "../commands/GetDataEndpointCommand" ; import { GetSignalingChannelEndpointCommandInput , GetSignalingChannelEndpointCommandOutput , } from "../commands/GetSignalingChannelEndpointCommand" ; import { ListSignalingChannelsCommandInput , ListSignalingChannelsCommandOutput , } from "../commands/ListSignalingChannelsCommand" ; import { ListStreamsCommandInput , ListStreamsCommandOutput } from "../commands/ListStreamsCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { ListTagsForStreamCommandInput , ListTagsForStreamCommandOutput } from "../commands/ListTagsForStreamCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { TagStreamCommandInput , TagStreamCommandOutput } from "../commands/TagStreamCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UntagStreamCommandInput , UntagStreamCommandOutput } from "../commands/UntagStreamCommand" ; import { UpdateDataRetentionCommandInput , UpdateDataRetentionCommandOutput , } from "../commands/UpdateDataRetentionCommand" ; import { UpdateSignalingChannelCommandInput , UpdateSignalingChannelCommandOutput , } from "../commands/UpdateSignalingChannelCommand" ; import { UpdateStreamCommandInput , UpdateStreamCommandOutput } from "../commands/UpdateStreamCommand" ; import { AccessDeniedException , AccountChannelLimitExceededException , AccountStreamLimitExceededException , ChannelInfo , ChannelNameCondition , ChannelProtocol , ClientLimitExceededException , DeviceStreamLimitExceededException , InvalidArgumentException , InvalidDeviceException , InvalidResourceFormatException , NotAuthorizedException , ResourceEndpointListItem , ResourceInUseException , ResourceNotFoundException , SingleMasterChannelEndpointConfiguration , SingleMasterConfiguration , StreamInfo , StreamNameCondition , Tag , TagsPerResourceExceededLimitException , VersionMismatchException , } from "../models/models_0" ; export const serializeAws_restJson1CreateSignalingChannelCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/createSignalingChannel" ; let body ; body = JSON . stringify ( { ... ( input . ChannelName !== undefined && input . ChannelName !== null && { ChannelName : input . ChannelName } ) , ... ( input . ChannelType !== undefined && input . ChannelType !== null && { ChannelType : input . ChannelType } ) , ... ( input . SingleMasterConfiguration !== undefined && input . SingleMasterConfiguration !== null && { SingleMasterConfiguration : serializeAws_restJson1SingleMasterConfiguration ( input . SingleMasterConfiguration , context ) , } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_restJson1TagOnCreateList ( input . Tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/createStream" ; let body ; body = JSON . stringify ( { ... ( input . DataRetentionInHours !== undefined && input . DataRetentionInHours !== null && { DataRetentionInHours : input . DataRetentionInHours } ) , ... ( input . DeviceName !== undefined && input . DeviceName !== null && { DeviceName : input . DeviceName } ) , ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , ... ( input . MediaType !== undefined && input . MediaType !== null && { MediaType : input . MediaType } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_restJson1ResourceTags ( input . Tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteSignalingChannelCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/deleteSignalingChannel" ; let body ; body = JSON . stringify ( { ... ( input . ChannelARN !== undefined && input . ChannelARN !== null && { ChannelARN : input . ChannelARN } ) , ... ( input . CurrentVersion !== undefined && input . CurrentVersion !== null && { CurrentVersion : input . CurrentVersion } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/deleteStream" ; let body ; body = JSON . stringify ( { ... ( input . CurrentVersion !== undefined && input . CurrentVersion !== null && { CurrentVersion : input . CurrentVersion } ) , ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DescribeSignalingChannelCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/describeSignalingChannel" ; let body ; body = JSON . stringify ( { ... ( input . ChannelARN !== undefined && input . ChannelARN !== null && { ChannelARN : input . ChannelARN } ) , ... ( input . ChannelName !== undefined && input . ChannelName !== null && { ChannelName : input . ChannelName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DescribeStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/describeStream" ; let body ; body = JSON . stringify ( { ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetDataEndpointCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getDataEndpoint" ; let body ; body = JSON . stringify ( { ... ( input . APIName !== undefined && input . APIName !== null && { APIName : input . APIName } ) , ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetSignalingChannelEndpointCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getSignalingChannelEndpoint" ; let body ; body = JSON . stringify ( { ... ( input . ChannelARN !== undefined && input . ChannelARN !== null && { ChannelARN : input . ChannelARN } ) , ... ( input . SingleMasterChannelEndpointConfiguration !== undefined && input . SingleMasterChannelEndpointConfiguration !== null && { SingleMasterChannelEndpointConfiguration : serializeAws_restJson1SingleMasterChannelEndpointConfiguration ( input . SingleMasterChannelEndpointConfiguration , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListSignalingChannelsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listSignalingChannels" ; let body ; body = JSON . stringify ( { ... ( input . ChannelNameCondition !== undefined && input . ChannelNameCondition !== null && { ChannelNameCondition : serializeAws_restJson1ChannelNameCondition ( input . ChannelNameCondition , context ) , } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListStreamsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listStreams" ; let body ; body = JSON . stringify ( { ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . StreamNameCondition !== undefined && input . StreamNameCondition !== null && { StreamNameCondition : serializeAws_restJson1StreamNameCondition ( input . StreamNameCondition , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/ListTagsForResource" ; let body ; body = JSON . stringify ( { ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListTagsForStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listTagsForStream" ; let body ; body = JSON . stringify ( { ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1TagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/TagResource" ; let body ; body = JSON . stringify ( { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_restJson1TagList ( input . Tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1TagStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tagStream" ; let body ; body = JSON . stringify ( { ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_restJson1ResourceTags ( input . Tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UntagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/UntagResource" ; let body ; body = JSON . stringify ( { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . TagKeyList !== undefined && input . TagKeyList !== null && { TagKeyList : serializeAws_restJson1TagKeyList ( input . TagKeyList , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UntagStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/untagStream" ; let body ; body = JSON . stringify ( { ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , ... ( input . TagKeyList !== undefined && input . TagKeyList !== null && { TagKeyList : serializeAws_restJson1TagKeyList ( input . TagKeyList , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateDataRetentionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/updateDataRetention" ; let body ; body = JSON . stringify ( { ... ( input . CurrentVersion !== undefined && input . CurrentVersion !== null && { CurrentVersion : input . CurrentVersion } ) , ... ( input . DataRetentionChangeInHours !== undefined && input . DataRetentionChangeInHours !== null && { DataRetentionChangeInHours : input . DataRetentionChangeInHours } ) , ... ( input . Operation !== undefined && input . Operation !== null && { Operation : input . Operation } ) , ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateSignalingChannelCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/updateSignalingChannel" ; let body ; body = JSON . stringify ( { ... ( input . ChannelARN !== undefined && input . ChannelARN !== null && { ChannelARN : input . ChannelARN } ) , ... ( input . CurrentVersion !== undefined && input . CurrentVersion !== null && { CurrentVersion : input . CurrentVersion } ) , ... ( input . SingleMasterConfiguration !== undefined && input . SingleMasterConfiguration !== null && { SingleMasterConfiguration : serializeAws_restJson1SingleMasterConfiguration ( input . SingleMasterConfiguration , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateStreamCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/updateStream" ; let body ; body = JSON . stringify ( { ... ( input . CurrentVersion !== undefined && input . CurrentVersion !== null && { CurrentVersion : input . CurrentVersion } ) , ... ( input . DeviceName !== undefined && input . DeviceName !== null && { DeviceName : input . DeviceName } ) , ... ( input . MediaType !== undefined && input . MediaType !== null && { MediaType : input . MediaType } ) , ... ( input . StreamARN !== undefined && input . StreamARN !== null && { StreamARN : input . StreamARN } ) , ... ( input . StreamName !== undefined && input . StreamName !== null && { StreamName : input . StreamName } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1CreateSignalingChannelCommand = async ( output , context ) : Promise < CreateSignalingChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateSignalingChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , ChannelARN : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . ChannelARN !== undefined && data . ChannelARN !== null ) { contents . ChannelARN = __expectString ( data . ChannelARN ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateSignalingChannelCommandError = async ( output , context ) : Promise < CreateSignalingChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "AccountChannelLimitExceededException" : case "com.amazonaws.kinesisvideo#AccountChannelLimitExceededException" : response = { ... ( await deserializeAws_restJson1AccountChannelLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagsPerResourceExceededLimitException" : case "com.amazonaws.kinesisvideo#TagsPerResourceExceededLimitException" : response = { ... ( await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse ( 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_restJson1CreateStreamCommand = async ( output , context ) : Promise < CreateStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , StreamARN : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . StreamARN !== undefined && data . StreamARN !== null ) { contents . StreamARN = __expectString ( data . StreamARN ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateStreamCommandError = async ( output , context ) : Promise < CreateStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccountStreamLimitExceededException" : case "com.amazonaws.kinesisvideo#AccountStreamLimitExceededException" : response = { ... ( await deserializeAws_restJson1AccountStreamLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DeviceStreamLimitExceededException" : case "com.amazonaws.kinesisvideo#DeviceStreamLimitExceededException" : response = { ... ( await deserializeAws_restJson1DeviceStreamLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidDeviceException" : case "com.amazonaws.kinesisvideo#InvalidDeviceException" : response = { ... ( await deserializeAws_restJson1InvalidDeviceExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagsPerResourceExceededLimitException" : case "com.amazonaws.kinesisvideo#TagsPerResourceExceededLimitException" : response = { ... ( await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse ( 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_restJson1DeleteSignalingChannelCommand = async ( output , context ) : Promise < DeleteSignalingChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteSignalingChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteSignalingChannelCommandError = async ( output , context ) : Promise < DeleteSignalingChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "VersionMismatchException" : case "com.amazonaws.kinesisvideo#VersionMismatchException" : response = { ... ( await deserializeAws_restJson1VersionMismatchExceptionResponse ( 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_restJson1DeleteStreamCommand = async ( output , context ) : Promise < DeleteStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteStreamCommandError = async ( output , context ) : Promise < DeleteStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "VersionMismatchException" : case "com.amazonaws.kinesisvideo#VersionMismatchException" : response = { ... ( await deserializeAws_restJson1VersionMismatchExceptionResponse ( 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_restJson1DescribeSignalingChannelCommand = async ( output , context ) : Promise < DescribeSignalingChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DescribeSignalingChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , ChannelInfo : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . ChannelInfo !== undefined && data . ChannelInfo !== null ) { contents . ChannelInfo = deserializeAws_restJson1ChannelInfo ( data . ChannelInfo , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DescribeSignalingChannelCommandError = async ( output , context ) : Promise < DescribeSignalingChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1DescribeStreamCommand = async ( output , context ) : Promise < DescribeStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DescribeStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , StreamInfo : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . StreamInfo !== undefined && data . StreamInfo !== null ) { contents . StreamInfo = deserializeAws_restJson1StreamInfo ( data . StreamInfo , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DescribeStreamCommandError = async ( output , context ) : Promise < DescribeStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1GetDataEndpointCommand = async ( output , context ) : Promise < GetDataEndpointCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetDataEndpointCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , DataEndpoint : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . DataEndpoint !== undefined && data . DataEndpoint !== null ) { contents . DataEndpoint = __expectString ( data . DataEndpoint ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetDataEndpointCommandError = async ( output , context ) : Promise < GetDataEndpointCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1GetSignalingChannelEndpointCommand = async ( output , context ) : Promise < GetSignalingChannelEndpointCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetSignalingChannelEndpointCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , ResourceEndpointList : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . ResourceEndpointList !== undefined && data . ResourceEndpointList !== null ) { contents . ResourceEndpointList = deserializeAws_restJson1ResourceEndpointList ( data . ResourceEndpointList , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetSignalingChannelEndpointCommandError = async ( output , context ) : Promise < GetSignalingChannelEndpointCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1ListSignalingChannelsCommand = async ( output , context ) : Promise < ListSignalingChannelsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListSignalingChannelsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , ChannelInfoList : undefined , NextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . ChannelInfoList !== undefined && data . ChannelInfoList !== null ) { contents . ChannelInfoList = deserializeAws_restJson1ChannelInfoList ( data . ChannelInfoList , context ) ; } if ( data . NextToken !== undefined && data . NextToken !== null ) { contents . NextToken = __expectString ( data . NextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListSignalingChannelsCommandError = async ( output , context ) : Promise < ListSignalingChannelsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( 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_restJson1ListStreamsCommand = async ( output , context ) : Promise < ListStreamsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListStreamsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , NextToken : undefined , StreamInfoList : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . NextToken !== undefined && data . NextToken !== null ) { contents . NextToken = __expectString ( data . NextToken ) ; } if ( data . StreamInfoList !== undefined && data . StreamInfoList !== null ) { contents . StreamInfoList = deserializeAws_restJson1StreamInfoList ( data . StreamInfoList , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListStreamsCommandError = async ( output , context ) : Promise < ListStreamsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( 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_restJson1ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListTagsForResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , NextToken : undefined , Tags : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . NextToken !== undefined && data . NextToken !== null ) { contents . NextToken = __expectString ( data . NextToken ) ; } if ( data . Tags !== undefined && data . Tags !== null ) { contents . Tags = deserializeAws_restJson1ResourceTags ( data . Tags , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTagsForResourceCommandError = 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 "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1ListTagsForStreamCommand = async ( output , context ) : Promise < ListTagsForStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListTagsForStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , NextToken : undefined , Tags : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . NextToken !== undefined && data . NextToken !== null ) { contents . NextToken = __expectString ( data . NextToken ) ; } if ( data . Tags !== undefined && data . Tags !== null ) { contents . Tags = deserializeAws_restJson1ResourceTags ( data . Tags , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTagsForStreamCommandError = async ( output , context ) : Promise < ListTagsForStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidResourceFormatException" : case "com.amazonaws.kinesisvideo#InvalidResourceFormatException" : response = { ... ( await deserializeAws_restJson1InvalidResourceFormatExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1TagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1TagResourceCommandError = 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 "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagsPerResourceExceededLimitException" : case "com.amazonaws.kinesisvideo#TagsPerResourceExceededLimitException" : response = { ... ( await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse ( 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_restJson1TagStreamCommand = async ( output , context ) : Promise < TagStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1TagStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1TagStreamCommandError = async ( output , context ) : Promise < TagStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidResourceFormatException" : case "com.amazonaws.kinesisvideo#InvalidResourceFormatException" : response = { ... ( await deserializeAws_restJson1InvalidResourceFormatExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagsPerResourceExceededLimitException" : case "com.amazonaws.kinesisvideo#TagsPerResourceExceededLimitException" : response = { ... ( await deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse ( 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_restJson1UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UntagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UntagResourceCommandError = 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 "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1UntagStreamCommand = async ( output , context ) : Promise < UntagStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UntagStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UntagStreamCommandError = async ( output , context ) : Promise < UntagStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidResourceFormatException" : case "com.amazonaws.kinesisvideo#InvalidResourceFormatException" : response = { ... ( await deserializeAws_restJson1InvalidResourceFormatExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1UpdateDataRetentionCommand = async ( output , context ) : Promise < UpdateDataRetentionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateDataRetentionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateDataRetentionCommandError = async ( output , context ) : Promise < UpdateDataRetentionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "VersionMismatchException" : case "com.amazonaws.kinesisvideo#VersionMismatchException" : response = { ... ( await deserializeAws_restJson1VersionMismatchExceptionResponse ( 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_restJson1UpdateSignalingChannelCommand = async ( output , context ) : Promise < UpdateSignalingChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateSignalingChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateSignalingChannelCommandError = async ( output , context ) : Promise < UpdateSignalingChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.kinesisvideo#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "VersionMismatchException" : case "com.amazonaws.kinesisvideo#VersionMismatchException" : response = { ... ( await deserializeAws_restJson1VersionMismatchExceptionResponse ( 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_restJson1UpdateStreamCommand = async ( output , context ) : Promise < UpdateStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateStreamCommandError = async ( output , context ) : Promise < UpdateStreamCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ClientLimitExceededException" : case "com.amazonaws.kinesisvideo#ClientLimitExceededException" : response = { ... ( await deserializeAws_restJson1ClientLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArgumentException" : case "com.amazonaws.kinesisvideo#InvalidArgumentException" : response = { ... ( await deserializeAws_restJson1InvalidArgumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotAuthorizedException" : case "com.amazonaws.kinesisvideo#NotAuthorizedException" : response = { ... ( await deserializeAws_restJson1NotAuthorizedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUseException" : case "com.amazonaws.kinesisvideo#ResourceInUseException" : response = { ... ( await deserializeAws_restJson1ResourceInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.kinesisvideo#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "VersionMismatchException" : case "com.amazonaws.kinesisvideo#VersionMismatchException" : response = { ... ( await deserializeAws_restJson1VersionMismatchExceptionResponse ( 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_restJson1AccessDeniedExceptionResponse = async ( parsedOutput , context ) : Promise < AccessDeniedException > => { const contents = { name : "AccessDeniedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1AccountChannelLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < AccountChannelLimitExceededException > => { const contents = { name : "AccountChannelLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1AccountStreamLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < AccountStreamLimitExceededException > => { const contents = { name : "AccountStreamLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1ClientLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ClientLimitExceededException > => { const contents = { name : "ClientLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1DeviceStreamLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < DeviceStreamLimitExceededException > => { const contents = { name : "DeviceStreamLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidArgumentExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidArgumentException > => { const contents = { name : "InvalidArgumentException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidDeviceExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidDeviceException > => { const contents = { name : "InvalidDeviceException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidResourceFormatExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidResourceFormatException > => { const contents = { name : "InvalidResourceFormatException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1NotAuthorizedExceptionResponse = async ( parsedOutput , context ) : Promise < NotAuthorizedException > => { const contents = { name : "NotAuthorizedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceInUseExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceInUseException > => { const contents = { name : "ResourceInUseException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1TagsPerResourceExceededLimitExceptionResponse = async ( parsedOutput , context ) : Promise < TagsPerResourceExceededLimitException > => { const contents = { name : "TagsPerResourceExceededLimitException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const deserializeAws_restJson1VersionMismatchExceptionResponse = async ( parsedOutput , context ) : Promise < VersionMismatchException > => { const contents = { name : "VersionMismatchException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , Message : undefined , } ; const data = parsedOutput . body ; if ( data . Message !== undefined && data . Message !== null ) { contents . Message = __expectString ( data . Message ) ; } return contents ; } ; const serializeAws_restJson1ChannelNameCondition = ( input , context ) : any => { return { ... ( input . ComparisonOperator !== undefined && input . ComparisonOperator !== null && { ComparisonOperator : input . ComparisonOperator } ) , ... ( input . ComparisonValue !== undefined && input . ComparisonValue !== null && { ComparisonValue : input . ComparisonValue } ) , } ; } ; const serializeAws_restJson1ListOfProtocols = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ResourceTags = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1SingleMasterChannelEndpointConfiguration = ( input , context ) : any => { return { ... ( input . Protocols !== undefined && input . Protocols !== null && { Protocols : serializeAws_restJson1ListOfProtocols ( input . Protocols , context ) } ) , ... ( input . Role !== undefined && input . Role !== null && { Role : input . Role } ) , } ; } ; const serializeAws_restJson1SingleMasterConfiguration = ( input , context ) : any => { return { ... ( input . MessageTtlSeconds !== undefined && input . MessageTtlSeconds !== null && { MessageTtlSeconds : input . MessageTtlSeconds } ) , } ; } ; const serializeAws_restJson1StreamNameCondition = ( input , context ) : any => { return { ... ( input . ComparisonOperator !== undefined && input . ComparisonOperator !== null && { ComparisonOperator : input . ComparisonOperator } ) , ... ( input . ComparisonValue !== undefined && input . ComparisonValue !== null && { ComparisonValue : input . ComparisonValue } ) , } ; } ; const serializeAws_restJson1Tag = ( input , context ) : any => { return { ... ( input . Key !== undefined && input . Key !== null && { Key : input . Key } ) , ... ( input . Value !== undefined && input . Value !== null && { Value : input . Value } ) , } ; } ; const serializeAws_restJson1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Tag ( entry , context ) ; } ) ; } ; const serializeAws_restJson1TagOnCreateList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Tag ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ChannelInfo = ( output , context ) : ChannelInfo => { return { ChannelARN : __expectString ( output . ChannelARN ) , ChannelName : __expectString ( output . ChannelName ) , ChannelStatus : __expectString ( output . ChannelStatus ) , ChannelType : __expectString ( output . ChannelType ) , CreationTime : output . CreationTime !== undefined && output . CreationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationTime ) ) ) : undefined , SingleMasterConfiguration : output . SingleMasterConfiguration !== undefined && output . SingleMasterConfiguration !== null ? deserializeAws_restJson1SingleMasterConfiguration ( output . SingleMasterConfiguration , context ) : undefined , Version : __expectString ( output . Version ) , } as any ; } ; const deserializeAws_restJson1ChannelInfoList = ( output , context ) : ChannelInfo [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ChannelInfo ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceEndpointList = ( output , context ) : ResourceEndpointListItem [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourceEndpointListItem ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceEndpointListItem = ( output , context ) : ResourceEndpointListItem => { return { Protocol : __expectString ( output . Protocol ) , ResourceEndpoint : __expectString ( output . ResourceEndpoint ) , } as any ; } ; const deserializeAws_restJson1ResourceTags = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1SingleMasterConfiguration = ( output , context ) : SingleMasterConfiguration => { return { MessageTtlSeconds : __expectInt32 ( output . MessageTtlSeconds ) , } as any ; } ; const deserializeAws_restJson1StreamInfo = ( output , context ) : StreamInfo => { return { CreationTime : output . CreationTime !== undefined && output . CreationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationTime ) ) ) : undefined , DataRetentionInHours : __expectInt32 ( output . DataRetentionInHours ) , DeviceName : __expectString ( output . DeviceName ) , KmsKeyId : __expectString ( output . KmsKeyId ) , MediaType : __expectString ( output . MediaType ) , Status : __expectString ( output . Status ) , StreamARN : __expectString ( output . StreamARN ) , StreamName : __expectString ( output . StreamName ) , Version : __expectString ( output . Version ) , } as any ; } ; const deserializeAws_restJson1StreamInfoList = ( output , context ) : StreamInfo [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamInfo ( entry , context ) ; } ) ; } ; 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 isSerializableHeaderValue = ( value ) : boolean => value !== undefined && value !== null && value !== "" && ( ! Object . getOwnPropertyNames ( value ) . includes ( "length" ) || value . length != 0 ) && ( ! Object . getOwnPropertyNames ( value ) . includes ( "size" ) || value . size != 0 ) ; 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 "" ; } ;