import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectLong as __expectLong , expectNonNull as __expectNonNull , expectObject as __expectObject , expectString as __expectString , extendedEncodeURIComponent as __extendedEncodeURIComponent , parseRfc3339DateTime as __parseRfc3339DateTime , } 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 { BatchGetChannelCommandInput , BatchGetChannelCommandOutput } from "../commands/BatchGetChannelCommand" ; import { BatchGetStreamKeyCommandInput , BatchGetStreamKeyCommandOutput } from "../commands/BatchGetStreamKeyCommand" ; import { CreateChannelCommandInput , CreateChannelCommandOutput } from "../commands/CreateChannelCommand" ; import { CreateRecordingConfigurationCommandInput , CreateRecordingConfigurationCommandOutput , } from "../commands/CreateRecordingConfigurationCommand" ; import { CreateStreamKeyCommandInput , CreateStreamKeyCommandOutput } from "../commands/CreateStreamKeyCommand" ; import { DeleteChannelCommandInput , DeleteChannelCommandOutput } from "../commands/DeleteChannelCommand" ; import { DeletePlaybackKeyPairCommandInput , DeletePlaybackKeyPairCommandOutput , } from "../commands/DeletePlaybackKeyPairCommand" ; import { DeleteRecordingConfigurationCommandInput , DeleteRecordingConfigurationCommandOutput , } from "../commands/DeleteRecordingConfigurationCommand" ; import { DeleteStreamKeyCommandInput , DeleteStreamKeyCommandOutput } from "../commands/DeleteStreamKeyCommand" ; import { GetChannelCommandInput , GetChannelCommandOutput } from "../commands/GetChannelCommand" ; import { GetPlaybackKeyPairCommandInput , GetPlaybackKeyPairCommandOutput } from "../commands/GetPlaybackKeyPairCommand" ; import { GetRecordingConfigurationCommandInput , GetRecordingConfigurationCommandOutput , } from "../commands/GetRecordingConfigurationCommand" ; import { GetStreamCommandInput , GetStreamCommandOutput } from "../commands/GetStreamCommand" ; import { GetStreamKeyCommandInput , GetStreamKeyCommandOutput } from "../commands/GetStreamKeyCommand" ; import { GetStreamSessionCommandInput , GetStreamSessionCommandOutput } from "../commands/GetStreamSessionCommand" ; import { ImportPlaybackKeyPairCommandInput , ImportPlaybackKeyPairCommandOutput , } from "../commands/ImportPlaybackKeyPairCommand" ; import { ListChannelsCommandInput , ListChannelsCommandOutput } from "../commands/ListChannelsCommand" ; import { ListPlaybackKeyPairsCommandInput , ListPlaybackKeyPairsCommandOutput , } from "../commands/ListPlaybackKeyPairsCommand" ; import { ListRecordingConfigurationsCommandInput , ListRecordingConfigurationsCommandOutput , } from "../commands/ListRecordingConfigurationsCommand" ; import { ListStreamKeysCommandInput , ListStreamKeysCommandOutput } from "../commands/ListStreamKeysCommand" ; import { ListStreamsCommandInput , ListStreamsCommandOutput } from "../commands/ListStreamsCommand" ; import { ListStreamSessionsCommandInput , ListStreamSessionsCommandOutput } from "../commands/ListStreamSessionsCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { PutMetadataCommandInput , PutMetadataCommandOutput } from "../commands/PutMetadataCommand" ; import { StopStreamCommandInput , StopStreamCommandOutput } from "../commands/StopStreamCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateChannelCommandInput , UpdateChannelCommandOutput } from "../commands/UpdateChannelCommand" ; import { _Stream , AccessDeniedException , AudioConfiguration , BatchError , Channel , ChannelNotBroadcasting , ChannelSummary , ConflictException , DestinationConfiguration , IngestConfiguration , InternalServerException , PendingVerification , PlaybackKeyPair , PlaybackKeyPairSummary , RecordingConfiguration , RecordingConfigurationSummary , ResourceNotFoundException , S3DestinationConfiguration , ServiceQuotaExceededException , StreamEvent , StreamFilters , StreamKey , StreamKeySummary , StreamSession , StreamSessionSummary , StreamSummary , StreamUnavailable , ThrottlingException , ValidationException , VideoConfiguration , } from "../models/models_0" ; export const serializeAws_restJson1BatchGetChannelCommand = 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 || "" }` + "/BatchGetChannel" ; let body ; body = JSON . stringify ( { ... ( input . arns !== undefined && input . arns !== null && { arns : serializeAws_restJson1ChannelArnList ( input . arns , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1BatchGetStreamKeyCommand = 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 || "" }` + "/BatchGetStreamKey" ; let body ; body = JSON . stringify ( { ... ( input . arns !== undefined && input . arns !== null && { arns : serializeAws_restJson1StreamKeyArnList ( input . arns , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateChannelCommand = 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 || "" }` + "/CreateChannel" ; let body ; body = JSON . stringify ( { ... ( input . authorized !== undefined && input . authorized !== null && { authorized : input . authorized } ) , ... ( input . latencyMode !== undefined && input . latencyMode !== null && { latencyMode : input . latencyMode } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . recordingConfigurationArn !== undefined && input . recordingConfigurationArn !== null && { recordingConfigurationArn : input . recordingConfigurationArn } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateRecordingConfigurationCommand = 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 || "" }` + "/CreateRecordingConfiguration" ; let body ; body = JSON . stringify ( { ... ( input . destinationConfiguration !== undefined && input . destinationConfiguration !== null && { destinationConfiguration : serializeAws_restJson1DestinationConfiguration ( input . destinationConfiguration , context ) , } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateStreamKeyCommand = 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 || "" }` + "/CreateStreamKey" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteChannelCommand = 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 || "" }` + "/DeleteChannel" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeletePlaybackKeyPairCommand = 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 || "" }` + "/DeletePlaybackKeyPair" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteRecordingConfigurationCommand = 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 || "" }` + "/DeleteRecordingConfiguration" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteStreamKeyCommand = 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 || "" }` + "/DeleteStreamKey" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetChannelCommand = 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 || "" }` + "/GetChannel" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetPlaybackKeyPairCommand = 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 || "" }` + "/GetPlaybackKeyPair" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetRecordingConfigurationCommand = 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 || "" }` + "/GetRecordingConfiguration" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetStreamCommand = 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 || "" }` + "/GetStream" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetStreamKeyCommand = 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 || "" }` + "/GetStreamKey" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetStreamSessionCommand = 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 || "" }` + "/GetStreamSession" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , ... ( input . streamId !== undefined && input . streamId !== null && { streamId : input . streamId } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ImportPlaybackKeyPairCommand = 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 || "" }` + "/ImportPlaybackKeyPair" ; let body ; body = JSON . stringify ( { ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . publicKeyMaterial !== undefined && input . publicKeyMaterial !== null && { publicKeyMaterial : input . publicKeyMaterial } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListChannelsCommand = 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 || "" }` + "/ListChannels" ; let body ; body = JSON . stringify ( { ... ( input . filterByName !== undefined && input . filterByName !== null && { filterByName : input . filterByName } ) , ... ( input . filterByRecordingConfigurationArn !== undefined && input . filterByRecordingConfigurationArn !== null && { filterByRecordingConfigurationArn : input . filterByRecordingConfigurationArn , } ) , ... ( 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_restJson1ListPlaybackKeyPairsCommand = 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 || "" }` + "/ListPlaybackKeyPairs" ; let body ; body = JSON . stringify ( { ... ( 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_restJson1ListRecordingConfigurationsCommand = 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 || "" }` + "/ListRecordingConfigurations" ; let body ; body = JSON . stringify ( { ... ( 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_restJson1ListStreamKeysCommand = 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 || "" }` + "/ListStreamKeys" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , ... ( 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 . filterBy !== undefined && input . filterBy !== null && { filterBy : serializeAws_restJson1StreamFilters ( input . filterBy , 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_restJson1ListStreamSessionsCommand = 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 || "" }` + "/ListStreamSessions" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , ... ( 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_restJson1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1PutMetadataCommand = 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 || "" }` + "/PutMetadata" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , ... ( input . metadata !== undefined && input . metadata !== null && { metadata : input . metadata } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1StopStreamCommand = 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 || "" }` + "/StopStream" ; let body ; body = JSON . stringify ( { ... ( input . channelArn !== undefined && input . channelArn !== null && { channelArn : input . channelArn } ) , } ) ; 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" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } let body ; body = JSON . stringify ( { ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( 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 = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } const query = { ... ( input . tagKeys !== undefined && { tagKeys : ( input . tagKeys || [ ] ) . map ( ( _entry ) => _entry as any ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1UpdateChannelCommand = 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 || "" }` + "/UpdateChannel" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , ... ( input . authorized !== undefined && input . authorized !== null && { authorized : input . authorized } ) , ... ( input . latencyMode !== undefined && input . latencyMode !== null && { latencyMode : input . latencyMode } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . recordingConfigurationArn !== undefined && input . recordingConfigurationArn !== null && { recordingConfigurationArn : input . recordingConfigurationArn } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1BatchGetChannelCommand = async ( output , context ) : Promise < BatchGetChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1BatchGetChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , channels : undefined , errors : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . channels !== undefined && data . channels !== null ) { contents . channels = deserializeAws_restJson1Channels ( data . channels , context ) ; } if ( data . errors !== undefined && data . errors !== null ) { contents . errors = deserializeAws_restJson1BatchErrors ( data . errors , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1BatchGetChannelCommandError = async ( output , context ) : Promise < BatchGetChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_restJson1BatchGetStreamKeyCommand = async ( output , context ) : Promise < BatchGetStreamKeyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1BatchGetStreamKeyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , errors : undefined , streamKeys : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . errors !== undefined && data . errors !== null ) { contents . errors = deserializeAws_restJson1BatchErrors ( data . errors , context ) ; } if ( data . streamKeys !== undefined && data . streamKeys !== null ) { contents . streamKeys = deserializeAws_restJson1StreamKeys ( data . streamKeys , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1BatchGetStreamKeyCommandError = async ( output , context ) : Promise < BatchGetStreamKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_restJson1CreateChannelCommand = async ( output , context ) : Promise < CreateChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , channel : undefined , streamKey : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . channel !== undefined && data . channel !== null ) { contents . channel = deserializeAws_restJson1Channel ( data . channel , context ) ; } if ( data . streamKey !== undefined && data . streamKey !== null ) { contents . streamKey = deserializeAws_restJson1StreamKey ( data . streamKey , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateChannelCommandError = async ( output , context ) : Promise < CreateChannelCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ivs#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateRecordingConfigurationCommand = async ( output , context ) : Promise < CreateRecordingConfigurationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateRecordingConfigurationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , recordingConfiguration : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . recordingConfiguration !== undefined && data . recordingConfiguration !== null ) { contents . recordingConfiguration = deserializeAws_restJson1RecordingConfiguration ( data . recordingConfiguration , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateRecordingConfigurationCommandError = async ( output , context ) : Promise < CreateRecordingConfigurationCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ivs#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateStreamKeyCommand = async ( output , context ) : Promise < CreateStreamKeyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateStreamKeyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , streamKey : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . streamKey !== undefined && data . streamKey !== null ) { contents . streamKey = deserializeAws_restJson1StreamKey ( data . streamKey , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateStreamKeyCommandError = async ( output , context ) : Promise < CreateStreamKeyCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ivs#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteChannelCommand = async ( output , context ) : Promise < DeleteChannelCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteChannelCommandError = async ( output , context ) : Promise < DeleteChannelCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeletePlaybackKeyPairCommand = async ( output , context ) : Promise < DeletePlaybackKeyPairCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeletePlaybackKeyPairCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeletePlaybackKeyPairCommandError = async ( output , context ) : Promise < DeletePlaybackKeyPairCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteRecordingConfigurationCommand = async ( output , context ) : Promise < DeleteRecordingConfigurationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteRecordingConfigurationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteRecordingConfigurationCommandError = async ( output , context ) : Promise < DeleteRecordingConfigurationCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteStreamKeyCommand = async ( output , context ) : Promise < DeleteStreamKeyCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteStreamKeyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteStreamKeyCommandError = async ( output , context ) : Promise < DeleteStreamKeyCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetChannelCommand = async ( output , context ) : Promise < GetChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , channel : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . channel !== undefined && data . channel !== null ) { contents . channel = deserializeAws_restJson1Channel ( data . channel , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetChannelCommandError = async ( output , context ) : Promise < GetChannelCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetPlaybackKeyPairCommand = async ( output , context ) : Promise < GetPlaybackKeyPairCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetPlaybackKeyPairCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , keyPair : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . keyPair !== undefined && data . keyPair !== null ) { contents . keyPair = deserializeAws_restJson1PlaybackKeyPair ( data . keyPair , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetPlaybackKeyPairCommandError = async ( output , context ) : Promise < GetPlaybackKeyPairCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetRecordingConfigurationCommand = async ( output , context ) : Promise < GetRecordingConfigurationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetRecordingConfigurationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , recordingConfiguration : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . recordingConfiguration !== undefined && data . recordingConfiguration !== null ) { contents . recordingConfiguration = deserializeAws_restJson1RecordingConfiguration ( data . recordingConfiguration , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetRecordingConfigurationCommandError = async ( output , context ) : Promise < GetRecordingConfigurationCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetStreamCommand = async ( output , context ) : Promise < GetStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , stream : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . stream !== undefined && data . stream !== null ) { contents . stream = deserializeAws_restJson1_Stream ( data . stream , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetStreamCommandError = async ( output , context ) : Promise < GetStreamCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ChannelNotBroadcasting" : case "com.amazonaws.ivs#ChannelNotBroadcasting" : response = { ... ( await deserializeAws_restJson1ChannelNotBroadcastingResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetStreamKeyCommand = async ( output , context ) : Promise < GetStreamKeyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetStreamKeyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , streamKey : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . streamKey !== undefined && data . streamKey !== null ) { contents . streamKey = deserializeAws_restJson1StreamKey ( data . streamKey , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetStreamKeyCommandError = async ( output , context ) : Promise < GetStreamKeyCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetStreamSessionCommand = async ( output , context ) : Promise < GetStreamSessionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetStreamSessionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , streamSession : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . streamSession !== undefined && data . streamSession !== null ) { contents . streamSession = deserializeAws_restJson1StreamSession ( data . streamSession , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetStreamSessionCommandError = async ( output , context ) : Promise < GetStreamSessionCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ImportPlaybackKeyPairCommand = async ( output , context ) : Promise < ImportPlaybackKeyPairCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ImportPlaybackKeyPairCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , keyPair : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . keyPair !== undefined && data . keyPair !== null ) { contents . keyPair = deserializeAws_restJson1PlaybackKeyPair ( data . keyPair , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ImportPlaybackKeyPairCommandError = async ( output , context ) : Promise < ImportPlaybackKeyPairCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ivs#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListChannelsCommand = async ( output , context ) : Promise < ListChannelsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListChannelsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , channels : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . channels !== undefined && data . channels !== null ) { contents . channels = deserializeAws_restJson1ChannelList ( data . channels , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListChannelsCommandError = async ( output , context ) : Promise < ListChannelsCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListPlaybackKeyPairsCommand = async ( output , context ) : Promise < ListPlaybackKeyPairsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListPlaybackKeyPairsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , keyPairs : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . keyPairs !== undefined && data . keyPairs !== null ) { contents . keyPairs = deserializeAws_restJson1PlaybackKeyPairList ( data . keyPairs , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListPlaybackKeyPairsCommandError = async ( output , context ) : Promise < ListPlaybackKeyPairsCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListRecordingConfigurationsCommand = async ( output , context ) : Promise < ListRecordingConfigurationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListRecordingConfigurationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , recordingConfigurations : 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 . recordingConfigurations !== undefined && data . recordingConfigurations !== null ) { contents . recordingConfigurations = deserializeAws_restJson1RecordingConfigurationList ( data . recordingConfigurations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListRecordingConfigurationsCommandError = async ( output , context ) : Promise < ListRecordingConfigurationsCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListStreamKeysCommand = async ( output , context ) : Promise < ListStreamKeysCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListStreamKeysCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , streamKeys : 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 . streamKeys !== undefined && data . streamKeys !== null ) { contents . streamKeys = deserializeAws_restJson1StreamKeyList ( data . streamKeys , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListStreamKeysCommandError = async ( output , context ) : Promise < ListStreamKeysCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 , streams : 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 . streams !== undefined && data . streams !== null ) { contents . streams = deserializeAws_restJson1StreamList ( data . streams , 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 "AccessDeniedException" : case "com.amazonaws.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( 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_restJson1ListStreamSessionsCommand = async ( output , context ) : Promise < ListStreamSessionsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListStreamSessionsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , streamSessions : 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 . streamSessions !== undefined && data . streamSessions !== null ) { contents . streamSessions = deserializeAws_restJson1StreamSessionList ( data . streamSessions , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListStreamSessionsCommandError = async ( output , context ) : Promise < ListStreamSessionsCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 ) , tags : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . tags !== undefined && data . tags !== null ) { contents . tags = deserializeAws_restJson1Tags ( 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 "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1PutMetadataCommand = async ( output , context ) : Promise < PutMetadataCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1PutMetadataCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1PutMetadataCommandError = async ( output , context ) : Promise < PutMetadataCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ChannelNotBroadcasting" : case "com.amazonaws.ivs#ChannelNotBroadcasting" : response = { ... ( await deserializeAws_restJson1ChannelNotBroadcastingResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ivs#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1StopStreamCommand = async ( output , context ) : Promise < StopStreamCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1StopStreamCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1StopStreamCommandError = async ( output , context ) : Promise < StopStreamCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ChannelNotBroadcasting" : case "com.amazonaws.ivs#ChannelNotBroadcasting" : response = { ... ( await deserializeAws_restJson1ChannelNotBroadcastingResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "StreamUnavailable" : case "com.amazonaws.ivs#StreamUnavailable" : response = { ... ( await deserializeAws_restJson1StreamUnavailableResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 "InternalServerException" : case "com.amazonaws.ivs#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1UpdateChannelCommand = async ( output , context ) : Promise < UpdateChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , channel : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . channel !== undefined && data . channel !== null ) { contents . channel = deserializeAws_restJson1Channel ( data . channel , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateChannelCommandError = async ( output , context ) : Promise < UpdateChannelCommandOutput > => { 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.ivs#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ivs#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PendingVerification" : case "com.amazonaws.ivs#PendingVerification" : response = { ... ( await deserializeAws_restJson1PendingVerificationResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ivs#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ivs#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ChannelNotBroadcastingResponse = async ( parsedOutput , context ) : Promise < ChannelNotBroadcasting > => { const contents = { name : "ChannelNotBroadcasting" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ConflictException > => { const contents = { name : "ConflictException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1InternalServerExceptionResponse = async ( parsedOutput , context ) : Promise < InternalServerException > => { const contents = { name : "InternalServerException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1PendingVerificationResponse = async ( parsedOutput , context ) : Promise < PendingVerification > => { const contents = { name : "PendingVerification" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceQuotaExceededException > => { const contents = { name : "ServiceQuotaExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1StreamUnavailableResponse = async ( parsedOutput , context ) : Promise < StreamUnavailable > => { const contents = { name : "StreamUnavailable" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const contents = { name : "ThrottlingException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const deserializeAws_restJson1ValidationExceptionResponse = async ( parsedOutput , context ) : Promise < ValidationException > => { const contents = { name : "ValidationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , exceptionMessage : undefined , } ; const data = parsedOutput . body ; if ( data . exceptionMessage !== undefined && data . exceptionMessage !== null ) { contents . exceptionMessage = __expectString ( data . exceptionMessage ) ; } return contents ; } ; const serializeAws_restJson1ChannelArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1DestinationConfiguration = ( input , context ) : any => { return { ... ( input . s3 !== undefined && input . s3 !== null && { s3 : serializeAws_restJson1S3DestinationConfiguration ( input . s3 , context ) } ) , } ; } ; const serializeAws_restJson1S3DestinationConfiguration = ( input , context ) : any => { return { ... ( input . bucketName !== undefined && input . bucketName !== null && { bucketName : input . bucketName } ) , } ; } ; const serializeAws_restJson1StreamFilters = ( input , context ) : any => { return { ... ( input . health !== undefined && input . health !== null && { health : input . health } ) , } ; } ; const serializeAws_restJson1StreamKeyArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1Tags = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const deserializeAws_restJson1AudioConfiguration = ( output , context ) : AudioConfiguration => { return { channels : __expectLong ( output . channels ) , codec : __expectString ( output . codec ) , sampleRate : __expectLong ( output . sampleRate ) , targetBitrate : __expectLong ( output . targetBitrate ) , } as any ; } ; const deserializeAws_restJson1BatchError = ( output , context ) : BatchError => { return { arn : __expectString ( output . arn ) , code : __expectString ( output . code ) , message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_restJson1BatchErrors = ( output , context ) : BatchError [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1BatchError ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Channel = ( output , context ) : Channel => { return { arn : __expectString ( output . arn ) , authorized : __expectBoolean ( output . authorized ) , ingestEndpoint : __expectString ( output . ingestEndpoint ) , latencyMode : __expectString ( output . latencyMode ) , name : __expectString ( output . name ) , playbackUrl : __expectString ( output . playbackUrl ) , recordingConfigurationArn : __expectString ( output . recordingConfigurationArn ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1ChannelList = ( output , context ) : ChannelSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ChannelSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Channels = ( output , context ) : Channel [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Channel ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ChannelSummary = ( output , context ) : ChannelSummary => { return { arn : __expectString ( output . arn ) , authorized : __expectBoolean ( output . authorized ) , latencyMode : __expectString ( output . latencyMode ) , name : __expectString ( output . name ) , recordingConfigurationArn : __expectString ( output . recordingConfigurationArn ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1DestinationConfiguration = ( output , context ) : DestinationConfiguration => { return { s3 : output . s3 !== undefined && output . s3 !== null ? deserializeAws_restJson1S3DestinationConfiguration ( output . s3 , context ) : undefined , } as any ; } ; const deserializeAws_restJson1IngestConfiguration = ( output , context ) : IngestConfiguration => { return { audio : output . audio !== undefined && output . audio !== null ? deserializeAws_restJson1AudioConfiguration ( output . audio , context ) : undefined , video : output . video !== undefined && output . video !== null ? deserializeAws_restJson1VideoConfiguration ( output . video , context ) : undefined , } as any ; } ; const deserializeAws_restJson1PlaybackKeyPair = ( output , context ) : PlaybackKeyPair => { return { arn : __expectString ( output . arn ) , fingerprint : __expectString ( output . fingerprint ) , name : __expectString ( output . name ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1PlaybackKeyPairList = ( output , context ) : PlaybackKeyPairSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1PlaybackKeyPairSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1PlaybackKeyPairSummary = ( output , context ) : PlaybackKeyPairSummary => { return { arn : __expectString ( output . arn ) , name : __expectString ( output . name ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1RecordingConfiguration = ( output , context ) : RecordingConfiguration => { return { arn : __expectString ( output . arn ) , destinationConfiguration : output . destinationConfiguration !== undefined && output . destinationConfiguration !== null ? deserializeAws_restJson1DestinationConfiguration ( output . destinationConfiguration , context ) : undefined , name : __expectString ( output . name ) , state : __expectString ( output . state ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1RecordingConfigurationList = ( output , context ) : RecordingConfigurationSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1RecordingConfigurationSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1RecordingConfigurationSummary = ( output , context ) : RecordingConfigurationSummary => { return { arn : __expectString ( output . arn ) , destinationConfiguration : output . destinationConfiguration !== undefined && output . destinationConfiguration !== null ? deserializeAws_restJson1DestinationConfiguration ( output . destinationConfiguration , context ) : undefined , name : __expectString ( output . name ) , state : __expectString ( output . state ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1S3DestinationConfiguration = ( output , context ) : S3DestinationConfiguration => { return { bucketName : __expectString ( output . bucketName ) , } as any ; } ; const deserializeAws_restJson1_Stream = ( output , context ) : _Stream => { return { channelArn : __expectString ( output . channelArn ) , health : __expectString ( output . health ) , playbackUrl : __expectString ( output . playbackUrl ) , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , state : __expectString ( output . state ) , streamId : __expectString ( output . streamId ) , viewerCount : __expectLong ( output . viewerCount ) , } as any ; } ; const deserializeAws_restJson1StreamEvent = ( output , context ) : StreamEvent => { return { eventTime : output . eventTime !== undefined && output . eventTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . eventTime ) ) : undefined , name : __expectString ( output . name ) , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1StreamEvents = ( output , context ) : StreamEvent [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamEvent ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1StreamKey = ( output , context ) : StreamKey => { return { arn : __expectString ( output . arn ) , channelArn : __expectString ( output . channelArn ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , value : __expectString ( output . value ) , } as any ; } ; const deserializeAws_restJson1StreamKeyList = ( output , context ) : StreamKeySummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamKeySummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1StreamKeys = ( output , context ) : StreamKey [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamKey ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1StreamKeySummary = ( output , context ) : StreamKeySummary => { return { arn : __expectString ( output . arn ) , channelArn : __expectString ( output . channelArn ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1StreamList = ( output , context ) : StreamSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1StreamSession = ( output , context ) : StreamSession => { return { channel : output . channel !== undefined && output . channel !== null ? deserializeAws_restJson1Channel ( output . channel , context ) : undefined , endTime : output . endTime !== undefined && output . endTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . endTime ) ) : undefined , ingestConfiguration : output . ingestConfiguration !== undefined && output . ingestConfiguration !== null ? deserializeAws_restJson1IngestConfiguration ( output . ingestConfiguration , context ) : undefined , recordingConfiguration : output . recordingConfiguration !== undefined && output . recordingConfiguration !== null ? deserializeAws_restJson1RecordingConfiguration ( output . recordingConfiguration , context ) : undefined , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , streamId : __expectString ( output . streamId ) , truncatedEvents : output . truncatedEvents !== undefined && output . truncatedEvents !== null ? deserializeAws_restJson1StreamEvents ( output . truncatedEvents , context ) : undefined , } as any ; } ; const deserializeAws_restJson1StreamSessionList = ( output , context ) : StreamSessionSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1StreamSessionSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1StreamSessionSummary = ( output , context ) : StreamSessionSummary => { return { endTime : output . endTime !== undefined && output . endTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . endTime ) ) : undefined , hasErrorEvent : __expectBoolean ( output . hasErrorEvent ) , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , streamId : __expectString ( output . streamId ) , } as any ; } ; const deserializeAws_restJson1StreamSummary = ( output , context ) : StreamSummary => { return { channelArn : __expectString ( output . channelArn ) , health : __expectString ( output . health ) , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , state : __expectString ( output . state ) , streamId : __expectString ( output . streamId ) , viewerCount : __expectLong ( output . viewerCount ) , } as any ; } ; const deserializeAws_restJson1Tags = ( 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_restJson1VideoConfiguration = ( output , context ) : VideoConfiguration => { return { avcLevel : __expectString ( output . avcLevel ) , avcProfile : __expectString ( output . avcProfile ) , codec : __expectString ( output . codec ) , encoder : __expectString ( output . encoder ) , targetBitrate : __expectLong ( output . targetBitrate ) , targetFramerate : __expectLong ( output . targetFramerate ) , videoHeight : __expectLong ( output . videoHeight ) , videoWidth : __expectLong ( output . videoWidth ) , } as any ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const 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 "" ; } ;