import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectObject as __expectObject , expectString as __expectString , expectUnion as __expectUnion , extendedEncodeURIComponent as __extendedEncodeURIComponent , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { CreateReplicationSetCommandInput , CreateReplicationSetCommandOutput , } from "../commands/CreateReplicationSetCommand" ; import { CreateResponsePlanCommandInput , CreateResponsePlanCommandOutput } from "../commands/CreateResponsePlanCommand" ; import { CreateTimelineEventCommandInput , CreateTimelineEventCommandOutput , } from "../commands/CreateTimelineEventCommand" ; import { DeleteIncidentRecordCommandInput , DeleteIncidentRecordCommandOutput , } from "../commands/DeleteIncidentRecordCommand" ; import { DeleteReplicationSetCommandInput , DeleteReplicationSetCommandOutput , } from "../commands/DeleteReplicationSetCommand" ; import { DeleteResourcePolicyCommandInput , DeleteResourcePolicyCommandOutput , } from "../commands/DeleteResourcePolicyCommand" ; import { DeleteResponsePlanCommandInput , DeleteResponsePlanCommandOutput } from "../commands/DeleteResponsePlanCommand" ; import { DeleteTimelineEventCommandInput , DeleteTimelineEventCommandOutput , } from "../commands/DeleteTimelineEventCommand" ; import { GetIncidentRecordCommandInput , GetIncidentRecordCommandOutput } from "../commands/GetIncidentRecordCommand" ; import { GetReplicationSetCommandInput , GetReplicationSetCommandOutput } from "../commands/GetReplicationSetCommand" ; import { GetResourcePoliciesCommandInput , GetResourcePoliciesCommandOutput , } from "../commands/GetResourcePoliciesCommand" ; import { GetResponsePlanCommandInput , GetResponsePlanCommandOutput } from "../commands/GetResponsePlanCommand" ; import { GetTimelineEventCommandInput , GetTimelineEventCommandOutput } from "../commands/GetTimelineEventCommand" ; import { ListIncidentRecordsCommandInput , ListIncidentRecordsCommandOutput , } from "../commands/ListIncidentRecordsCommand" ; import { ListRelatedItemsCommandInput , ListRelatedItemsCommandOutput } from "../commands/ListRelatedItemsCommand" ; import { ListReplicationSetsCommandInput , ListReplicationSetsCommandOutput , } from "../commands/ListReplicationSetsCommand" ; import { ListResponsePlansCommandInput , ListResponsePlansCommandOutput } from "../commands/ListResponsePlansCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { ListTimelineEventsCommandInput , ListTimelineEventsCommandOutput } from "../commands/ListTimelineEventsCommand" ; import { PutResourcePolicyCommandInput , PutResourcePolicyCommandOutput } from "../commands/PutResourcePolicyCommand" ; import { StartIncidentCommandInput , StartIncidentCommandOutput } from "../commands/StartIncidentCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateDeletionProtectionCommandInput , UpdateDeletionProtectionCommandOutput , } from "../commands/UpdateDeletionProtectionCommand" ; import { UpdateIncidentRecordCommandInput , UpdateIncidentRecordCommandOutput , } from "../commands/UpdateIncidentRecordCommand" ; import { UpdateRelatedItemsCommandInput , UpdateRelatedItemsCommandOutput } from "../commands/UpdateRelatedItemsCommand" ; import { UpdateReplicationSetCommandInput , UpdateReplicationSetCommandOutput , } from "../commands/UpdateReplicationSetCommand" ; import { UpdateResponsePlanCommandInput , UpdateResponsePlanCommandOutput } from "../commands/UpdateResponsePlanCommand" ; import { UpdateTimelineEventCommandInput , UpdateTimelineEventCommandOutput , } from "../commands/UpdateTimelineEventCommand" ; import { AccessDeniedException , Action , AddRegionAction , AttributeValueList , AutomationExecution , ChatChannel , Condition , ConflictException , DeleteRegionAction , EmptyChatChannel , EventSummary , Filter , IncidentRecord , IncidentRecordSource , IncidentRecordSummary , IncidentTemplate , InternalServerException , ItemIdentifier , ItemValue , NotificationTargetItem , RegionInfo , RegionMapInputValue , RelatedItem , RelatedItemsUpdate , ReplicationSet , ResourceNotFoundException , ResourcePolicy , ResponsePlanSummary , ServiceQuotaExceededException , SsmAutomation , ThrottlingException , TimelineEvent , TriggerDetails , UpdateReplicationSetAction , ValidationException , } from "../models/models_0" ; export const serializeAws_restJson1CreateReplicationSetCommand = 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 || "" }` + "/createReplicationSet" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . regions !== undefined && input . regions !== null && { regions : serializeAws_restJson1RegionMapInput ( input . regions , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateResponsePlanCommand = 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 || "" }` + "/createResponsePlan" ; let body ; body = JSON . stringify ( { ... ( input . actions !== undefined && input . actions !== null && { actions : serializeAws_restJson1ActionsList ( input . actions , context ) } ) , ... ( input . chatChannel !== undefined && input . chatChannel !== null && { chatChannel : serializeAws_restJson1ChatChannel ( input . chatChannel , context ) } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . displayName !== undefined && input . displayName !== null && { displayName : input . displayName } ) , ... ( input . engagements !== undefined && input . engagements !== null && { engagements : serializeAws_restJson1EngagementSet ( input . engagements , context ) } ) , ... ( input . incidentTemplate !== undefined && input . incidentTemplate !== null && { incidentTemplate : serializeAws_restJson1IncidentTemplate ( input . incidentTemplate , context ) , } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1TagMap ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateTimelineEventCommand = 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 || "" }` + "/createTimelineEvent" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . eventData !== undefined && input . eventData !== null && { eventData : input . eventData } ) , ... ( input . eventTime !== undefined && input . eventTime !== null && { eventTime : Math . round ( input . eventTime . getTime ( ) / 1000 ) } ) , ... ( input . eventType !== undefined && input . eventType !== null && { eventType : input . eventType } ) , ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteIncidentRecordCommand = 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 || "" }` + "/deleteIncidentRecord" ; 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_restJson1DeleteReplicationSetCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/deleteReplicationSet" ; const query = { ... ( input . arn !== undefined && { arn : input . arn } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1DeleteResourcePolicyCommand = 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 || "" }` + "/deleteResourcePolicy" ; let body ; body = JSON . stringify ( { ... ( input . policyId !== undefined && input . policyId !== null && { policyId : input . policyId } ) , ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteResponsePlanCommand = 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 || "" }` + "/deleteResponsePlan" ; 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_restJson1DeleteTimelineEventCommand = 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 || "" }` + "/deleteTimelineEvent" ; let body ; body = JSON . stringify ( { ... ( input . eventId !== undefined && input . eventId !== null && { eventId : input . eventId } ) , ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetIncidentRecordCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getIncidentRecord" ; const query = { ... ( input . arn !== undefined && { arn : input . arn } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetReplicationSetCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getReplicationSet" ; const query = { ... ( input . arn !== undefined && { arn : input . arn } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetResourcePoliciesCommand = 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 || "" }` + "/getResourcePolicies" ; const query = { ... ( input . resourceArn !== undefined && { resourceArn : input . resourceArn } ) , } ; 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 , query , body , } ) ; } ; export const serializeAws_restJson1GetResponsePlanCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getResponsePlan" ; const query = { ... ( input . arn !== undefined && { arn : input . arn } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetTimelineEventCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getTimelineEvent" ; const query = { ... ( input . incidentRecordArn !== undefined && { incidentRecordArn : input . incidentRecordArn } ) , ... ( input . eventId !== undefined && { eventId : input . eventId } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListIncidentRecordsCommand = 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 || "" }` + "/listIncidentRecords" ; let body ; body = JSON . stringify ( { ... ( input . filters !== undefined && input . filters !== null && { filters : serializeAws_restJson1FilterList ( input . filters , 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_restJson1ListRelatedItemsCommand = 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 || "" }` + "/listRelatedItems" ; let body ; body = JSON . stringify ( { ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , ... ( 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_restJson1ListReplicationSetsCommand = 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 || "" }` + "/listReplicationSets" ; 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_restJson1ListResponsePlansCommand = 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 || "" }` + "/listResponsePlans" ; 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_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_restJson1ListTimelineEventsCommand = 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 || "" }` + "/listTimelineEvents" ; let body ; body = JSON . stringify ( { ... ( input . filters !== undefined && input . filters !== null && { filters : serializeAws_restJson1FilterList ( input . filters , context ) } ) , ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . sortBy !== undefined && input . sortBy !== null && { sortBy : input . sortBy } ) , ... ( input . sortOrder !== undefined && input . sortOrder !== null && { sortOrder : input . sortOrder } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1PutResourcePolicyCommand = 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 || "" }` + "/putResourcePolicy" ; let body ; body = JSON . stringify ( { ... ( input . policy !== undefined && input . policy !== null && { policy : input . policy } ) , ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1StartIncidentCommand = 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 || "" }` + "/startIncident" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . impact !== undefined && input . impact !== null && { impact : input . impact } ) , ... ( input . relatedItems !== undefined && input . relatedItems !== null && { relatedItems : serializeAws_restJson1RelatedItemList ( input . relatedItems , context ) , } ) , ... ( input . responsePlanArn !== undefined && input . responsePlanArn !== null && { responsePlanArn : input . responsePlanArn } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , ... ( input . triggerDetails !== undefined && input . triggerDetails !== null && { triggerDetails : serializeAws_restJson1TriggerDetails ( input . triggerDetails , context ) , } ) , } ) ; 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_restJson1TagMap ( 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_restJson1UpdateDeletionProtectionCommand = 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 || "" }` + "/updateDeletionProtection" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . deletionProtected !== undefined && input . deletionProtected !== null && { deletionProtected : input . deletionProtected } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateIncidentRecordCommand = 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 || "" }` + "/updateIncidentRecord" ; let body ; body = JSON . stringify ( { ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , ... ( input . chatChannel !== undefined && input . chatChannel !== null && { chatChannel : serializeAws_restJson1ChatChannel ( input . chatChannel , context ) } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . impact !== undefined && input . impact !== null && { impact : input . impact } ) , ... ( input . notificationTargets !== undefined && input . notificationTargets !== null && { notificationTargets : serializeAws_restJson1NotificationTargetSet ( input . notificationTargets , context ) , } ) , ... ( input . status !== undefined && input . status !== null && { status : input . status } ) , ... ( input . summary !== undefined && input . summary !== null && { summary : input . summary } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateRelatedItemsCommand = 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 || "" }` + "/updateRelatedItems" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , ... ( input . relatedItemsUpdate !== undefined && input . relatedItemsUpdate !== null && { relatedItemsUpdate : serializeAws_restJson1RelatedItemsUpdate ( input . relatedItemsUpdate , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateReplicationSetCommand = 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 || "" }` + "/updateReplicationSet" ; let body ; body = JSON . stringify ( { ... ( input . actions !== undefined && input . actions !== null && { actions : serializeAws_restJson1UpdateActionList ( input . actions , context ) } ) , ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateResponsePlanCommand = 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 || "" }` + "/updateResponsePlan" ; let body ; body = JSON . stringify ( { ... ( input . actions !== undefined && input . actions !== null && { actions : serializeAws_restJson1ActionsList ( input . actions , context ) } ) , ... ( input . arn !== undefined && input . arn !== null && { arn : input . arn } ) , ... ( input . chatChannel !== undefined && input . chatChannel !== null && { chatChannel : serializeAws_restJson1ChatChannel ( input . chatChannel , context ) } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . displayName !== undefined && input . displayName !== null && { displayName : input . displayName } ) , ... ( input . engagements !== undefined && input . engagements !== null && { engagements : serializeAws_restJson1EngagementSet ( input . engagements , context ) } ) , ... ( input . incidentTemplateDedupeString !== undefined && input . incidentTemplateDedupeString !== null && { incidentTemplateDedupeString : input . incidentTemplateDedupeString , } ) , ... ( input . incidentTemplateImpact !== undefined && input . incidentTemplateImpact !== null && { incidentTemplateImpact : input . incidentTemplateImpact } ) , ... ( input . incidentTemplateNotificationTargets !== undefined && input . incidentTemplateNotificationTargets !== null && { incidentTemplateNotificationTargets : serializeAws_restJson1NotificationTargetSet ( input . incidentTemplateNotificationTargets , context ) , } ) , ... ( input . incidentTemplateSummary !== undefined && input . incidentTemplateSummary !== null && { incidentTemplateSummary : input . incidentTemplateSummary } ) , ... ( input . incidentTemplateTitle !== undefined && input . incidentTemplateTitle !== null && { incidentTemplateTitle : input . incidentTemplateTitle } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateTimelineEventCommand = 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 || "" }` + "/updateTimelineEvent" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . eventData !== undefined && input . eventData !== null && { eventData : input . eventData } ) , ... ( input . eventId !== undefined && input . eventId !== null && { eventId : input . eventId } ) , ... ( input . eventTime !== undefined && input . eventTime !== null && { eventTime : Math . round ( input . eventTime . getTime ( ) / 1000 ) } ) , ... ( input . eventType !== undefined && input . eventType !== null && { eventType : input . eventType } ) , ... ( input . incidentRecordArn !== undefined && input . incidentRecordArn !== null && { incidentRecordArn : input . incidentRecordArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1CreateReplicationSetCommand = async ( output , context ) : Promise < CreateReplicationSetCommandOutput > => { if ( output . statusCode !== 201 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateReplicationSetCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , arn : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . arn !== undefined && data . arn !== null ) { contents . arn = __expectString ( data . arn ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateReplicationSetCommandError = async ( output , context ) : Promise < CreateReplicationSetCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ssmincidents#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1CreateResponsePlanCommand = async ( output , context ) : Promise < CreateResponsePlanCommandOutput > => { if ( output . statusCode !== 201 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateResponsePlanCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , arn : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . arn !== undefined && data . arn !== null ) { contents . arn = __expectString ( data . arn ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateResponsePlanCommandError = async ( output , context ) : Promise < CreateResponsePlanCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1CreateTimelineEventCommand = async ( output , context ) : Promise < CreateTimelineEventCommandOutput > => { if ( output . statusCode !== 201 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateTimelineEventCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , eventId : undefined , incidentRecordArn : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . eventId !== undefined && data . eventId !== null ) { contents . eventId = __expectString ( data . eventId ) ; } if ( data . incidentRecordArn !== undefined && data . incidentRecordArn !== null ) { contents . incidentRecordArn = __expectString ( data . incidentRecordArn ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateTimelineEventCommandError = async ( output , context ) : Promise < CreateTimelineEventCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1DeleteIncidentRecordCommand = async ( output , context ) : Promise < DeleteIncidentRecordCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteIncidentRecordCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteIncidentRecordCommandError = async ( output , context ) : Promise < DeleteIncidentRecordCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1DeleteReplicationSetCommand = async ( output , context ) : Promise < DeleteReplicationSetCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteReplicationSetCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteReplicationSetCommandError = async ( output , context ) : Promise < DeleteReplicationSetCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1DeleteResourcePolicyCommand = async ( output , context ) : Promise < DeleteResourcePolicyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteResourcePolicyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteResourcePolicyCommandError = async ( output , context ) : Promise < DeleteResourcePolicyCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1DeleteResponsePlanCommand = async ( output , context ) : Promise < DeleteResponsePlanCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteResponsePlanCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteResponsePlanCommandError = async ( output , context ) : Promise < DeleteResponsePlanCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1DeleteTimelineEventCommand = async ( output , context ) : Promise < DeleteTimelineEventCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteTimelineEventCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteTimelineEventCommandError = async ( output , context ) : Promise < DeleteTimelineEventCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1GetIncidentRecordCommand = async ( output , context ) : Promise < GetIncidentRecordCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetIncidentRecordCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , incidentRecord : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . incidentRecord !== undefined && data . incidentRecord !== null ) { contents . incidentRecord = deserializeAws_restJson1IncidentRecord ( data . incidentRecord , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetIncidentRecordCommandError = async ( output , context ) : Promise < GetIncidentRecordCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1GetReplicationSetCommand = async ( output , context ) : Promise < GetReplicationSetCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetReplicationSetCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , replicationSet : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . replicationSet !== undefined && data . replicationSet !== null ) { contents . replicationSet = deserializeAws_restJson1ReplicationSet ( data . replicationSet , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetReplicationSetCommandError = async ( output , context ) : Promise < GetReplicationSetCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1GetResourcePoliciesCommand = async ( output , context ) : Promise < GetResourcePoliciesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResourcePoliciesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resourcePolicies : 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 . resourcePolicies !== undefined && data . resourcePolicies !== null ) { contents . resourcePolicies = deserializeAws_restJson1ResourcePolicyList ( data . resourcePolicies , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( output , context ) : Promise < GetResourcePoliciesCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1GetResponsePlanCommand = async ( output , context ) : Promise < GetResponsePlanCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResponsePlanCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , actions : undefined , arn : undefined , chatChannel : undefined , displayName : undefined , engagements : undefined , incidentTemplate : undefined , name : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . actions !== undefined && data . actions !== null ) { contents . actions = deserializeAws_restJson1ActionsList ( data . actions , context ) ; } if ( data . arn !== undefined && data . arn !== null ) { contents . arn = __expectString ( data . arn ) ; } if ( data . chatChannel !== undefined && data . chatChannel !== null ) { contents . chatChannel = deserializeAws_restJson1ChatChannel ( __expectUnion ( data . chatChannel ) , context ) ; } if ( data . displayName !== undefined && data . displayName !== null ) { contents . displayName = __expectString ( data . displayName ) ; } if ( data . engagements !== undefined && data . engagements !== null ) { contents . engagements = deserializeAws_restJson1EngagementSet ( data . engagements , context ) ; } if ( data . incidentTemplate !== undefined && data . incidentTemplate !== null ) { contents . incidentTemplate = deserializeAws_restJson1IncidentTemplate ( data . incidentTemplate , context ) ; } if ( data . name !== undefined && data . name !== null ) { contents . name = __expectString ( data . name ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResponsePlanCommandError = async ( output , context ) : Promise < GetResponsePlanCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1GetTimelineEventCommand = async ( output , context ) : Promise < GetTimelineEventCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetTimelineEventCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , event : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . event !== undefined && data . event !== null ) { contents . event = deserializeAws_restJson1TimelineEvent ( data . event , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetTimelineEventCommandError = async ( output , context ) : Promise < GetTimelineEventCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1ListIncidentRecordsCommand = async ( output , context ) : Promise < ListIncidentRecordsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListIncidentRecordsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , incidentRecordSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . incidentRecordSummaries !== undefined && data . incidentRecordSummaries !== null ) { contents . incidentRecordSummaries = deserializeAws_restJson1IncidentRecordSummaryList ( data . incidentRecordSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListIncidentRecordsCommandError = async ( output , context ) : Promise < ListIncidentRecordsCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1ListRelatedItemsCommand = async ( output , context ) : Promise < ListRelatedItemsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListRelatedItemsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , relatedItems : 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 . relatedItems !== undefined && data . relatedItems !== null ) { contents . relatedItems = deserializeAws_restJson1RelatedItemList ( data . relatedItems , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListRelatedItemsCommandError = async ( output , context ) : Promise < ListRelatedItemsCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1ListReplicationSetsCommand = async ( output , context ) : Promise < ListReplicationSetsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListReplicationSetsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , replicationSetArns : 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 . replicationSetArns !== undefined && data . replicationSetArns !== null ) { contents . replicationSetArns = deserializeAws_restJson1ReplicationSetArnList ( data . replicationSetArns , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListReplicationSetsCommandError = async ( output , context ) : Promise < ListReplicationSetsCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1ListResponsePlansCommand = async ( output , context ) : Promise < ListResponsePlansCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListResponsePlansCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , responsePlanSummaries : 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 . responsePlanSummaries !== undefined && data . responsePlanSummaries !== null ) { contents . responsePlanSummaries = deserializeAws_restJson1ResponsePlanSummaryList ( data . responsePlanSummaries , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListResponsePlansCommandError = async ( output , context ) : Promise < ListResponsePlansCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1TagMap ( data . tags , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1ListTimelineEventsCommand = async ( output , context ) : Promise < ListTimelineEventsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListTimelineEventsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , eventSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . eventSummaries !== undefined && data . eventSummaries !== null ) { contents . eventSummaries = deserializeAws_restJson1EventSummaryList ( data . eventSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTimelineEventsCommandError = async ( output , context ) : Promise < ListTimelineEventsCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1PutResourcePolicyCommand = async ( output , context ) : Promise < PutResourcePolicyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1PutResourcePolicyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , policyId : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . policyId !== undefined && data . policyId !== null ) { contents . policyId = __expectString ( data . policyId ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1PutResourcePolicyCommandError = async ( output , context ) : Promise < PutResourcePolicyCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1StartIncidentCommand = async ( output , context ) : Promise < StartIncidentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1StartIncidentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , incidentRecordArn : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . incidentRecordArn !== undefined && data . incidentRecordArn !== null ) { contents . incidentRecordArn = __expectString ( data . incidentRecordArn ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1StartIncidentCommandError = async ( output , context ) : Promise < StartIncidentCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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 !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1TagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.ssmincidents#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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 !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UntagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateDeletionProtectionCommand = async ( output , context ) : Promise < UpdateDeletionProtectionCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateDeletionProtectionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateDeletionProtectionCommandError = async ( output , context ) : Promise < UpdateDeletionProtectionCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateIncidentRecordCommand = async ( output , context ) : Promise < UpdateIncidentRecordCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateIncidentRecordCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateIncidentRecordCommandError = async ( output , context ) : Promise < UpdateIncidentRecordCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateRelatedItemsCommand = async ( output , context ) : Promise < UpdateRelatedItemsCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateRelatedItemsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateRelatedItemsCommandError = async ( output , context ) : Promise < UpdateRelatedItemsCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateReplicationSetCommand = async ( output , context ) : Promise < UpdateReplicationSetCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateReplicationSetCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateReplicationSetCommandError = async ( output , context ) : Promise < UpdateReplicationSetCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateResponsePlanCommand = async ( output , context ) : Promise < UpdateResponsePlanCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateResponsePlanCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateResponsePlanCommandError = async ( output , context ) : Promise < UpdateResponsePlanCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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_restJson1UpdateTimelineEventCommand = async ( output , context ) : Promise < UpdateTimelineEventCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateTimelineEventCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateTimelineEventCommandError = async ( output , context ) : Promise < UpdateTimelineEventCommandOutput > => { 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.ssmincidents#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.ssmincidents#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.ssmincidents#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.ssmincidents#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ssmincidents#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.ssmincidents#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 ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ConflictException > => { const contents = { name : "ConflictException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , resourceIdentifier : undefined , resourceType : undefined , retryAfter : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . resourceIdentifier !== undefined && data . resourceIdentifier !== null ) { contents . resourceIdentifier = __expectString ( data . resourceIdentifier ) ; } if ( data . resourceType !== undefined && data . resourceType !== null ) { contents . resourceType = __expectString ( data . resourceType ) ; } if ( data . retryAfter !== undefined && data . retryAfter !== null ) { contents . retryAfter = __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( data . retryAfter ) ) ) ; } return contents ; } ; const deserializeAws_restJson1InternalServerExceptionResponse = async ( parsedOutput , context ) : Promise < InternalServerException > => { const contents = { name : "InternalServerException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , resourceIdentifier : undefined , resourceType : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . resourceIdentifier !== undefined && data . resourceIdentifier !== null ) { contents . resourceIdentifier = __expectString ( data . resourceIdentifier ) ; } if ( data . resourceType !== undefined && data . resourceType !== null ) { contents . resourceType = __expectString ( data . resourceType ) ; } return contents ; } ; const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceQuotaExceededException > => { const contents = { name : "ServiceQuotaExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , quotaCode : undefined , resourceIdentifier : undefined , resourceType : undefined , serviceCode : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . quotaCode !== undefined && data . quotaCode !== null ) { contents . quotaCode = __expectString ( data . quotaCode ) ; } if ( data . resourceIdentifier !== undefined && data . resourceIdentifier !== null ) { contents . resourceIdentifier = __expectString ( data . resourceIdentifier ) ; } if ( data . resourceType !== undefined && data . resourceType !== null ) { contents . resourceType = __expectString ( data . resourceType ) ; } if ( data . serviceCode !== undefined && data . serviceCode !== null ) { contents . serviceCode = __expectString ( data . serviceCode ) ; } return contents ; } ; const deserializeAws_restJson1ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const contents = { name : "ThrottlingException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , quotaCode : undefined , serviceCode : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . quotaCode !== undefined && data . quotaCode !== null ) { contents . quotaCode = __expectString ( data . quotaCode ) ; } if ( data . serviceCode !== undefined && data . serviceCode !== null ) { contents . serviceCode = __expectString ( data . serviceCode ) ; } return contents ; } ; const deserializeAws_restJson1ValidationExceptionResponse = async ( parsedOutput , context ) : Promise < ValidationException > => { const contents = { name : "ValidationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const serializeAws_restJson1Action = ( input , context ) : any => { return Action . visit ( input , { ssmAutomation : ( value ) => ( { ssmAutomation : serializeAws_restJson1SsmAutomation ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1ActionsList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Action ( entry , context ) ; } ) ; } ; const serializeAws_restJson1AddRegionAction = ( input , context ) : any => { return { ... ( input . regionName !== undefined && input . regionName !== null && { regionName : input . regionName } ) , ... ( input . sseKmsKeyId !== undefined && input . sseKmsKeyId !== null && { sseKmsKeyId : input . sseKmsKeyId } ) , } ; } ; const serializeAws_restJson1AttributeValueList = ( input , context ) : any => { return AttributeValueList . visit ( input , { integerValues : ( value ) => ( { integerValues : serializeAws_restJson1IntegerList ( value , context ) } ) , stringValues : ( value ) => ( { stringValues : serializeAws_restJson1StringList ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1ChatbotSnsConfigurationSet = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ChatChannel = ( input , context ) : any => { return ChatChannel . visit ( input , { chatbotSns : ( value ) => ( { chatbotSns : serializeAws_restJson1ChatbotSnsConfigurationSet ( value , context ) } ) , empty : ( value ) => ( { empty : serializeAws_restJson1EmptyChatChannel ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1Condition = ( input , context ) : any => { return Condition . visit ( input , { after : ( value ) => ( { after : Math . round ( value . getTime ( ) / 1000 ) } ) , before : ( value ) => ( { before : Math . round ( value . getTime ( ) / 1000 ) } ) , equals : ( value ) => ( { equals : serializeAws_restJson1AttributeValueList ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1DeleteRegionAction = ( input , context ) : any => { return { ... ( input . regionName !== undefined && input . regionName !== null && { regionName : input . regionName } ) , } ; } ; const serializeAws_restJson1EmptyChatChannel = ( input , context ) : any => { return { } ; } ; const serializeAws_restJson1EngagementSet = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1Filter = ( input , context ) : any => { return { ... ( input . condition !== undefined && input . condition !== null && { condition : serializeAws_restJson1Condition ( input . condition , context ) } ) , ... ( input . key !== undefined && input . key !== null && { key : input . key } ) , } ; } ; const serializeAws_restJson1FilterList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Filter ( entry , context ) ; } ) ; } ; const serializeAws_restJson1IncidentTemplate = ( input , context ) : any => { return { ... ( input . dedupeString !== undefined && input . dedupeString !== null && { dedupeString : input . dedupeString } ) , ... ( input . impact !== undefined && input . impact !== null && { impact : input . impact } ) , ... ( input . notificationTargets !== undefined && input . notificationTargets !== null && { notificationTargets : serializeAws_restJson1NotificationTargetSet ( input . notificationTargets , context ) , } ) , ... ( input . summary !== undefined && input . summary !== null && { summary : input . summary } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , } ; } ; const serializeAws_restJson1IntegerList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ItemIdentifier = ( input , context ) : any => { return { ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , ... ( input . value !== undefined && input . value !== null && { value : serializeAws_restJson1ItemValue ( input . value , context ) } ) , } ; } ; const serializeAws_restJson1ItemValue = ( input , context ) : any => { return ItemValue . visit ( input , { arn : ( value ) => ( { arn : value } ) , metricDefinition : ( value ) => ( { metricDefinition : value } ) , url : ( value ) => ( { url : value } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1NotificationTargetItem = ( input , context ) : any => { return NotificationTargetItem . visit ( input , { snsTopicArn : ( value ) => ( { snsTopicArn : value } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1NotificationTargetSet = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1NotificationTargetItem ( entry , context ) ; } ) ; } ; const serializeAws_restJson1RegionMapInput = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1RegionMapInputValue ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1RegionMapInputValue = ( input , context ) : any => { return { ... ( input . sseKmsKeyId !== undefined && input . sseKmsKeyId !== null && { sseKmsKeyId : input . sseKmsKeyId } ) , } ; } ; const serializeAws_restJson1RelatedItem = ( input , context ) : any => { return { ... ( input . identifier !== undefined && input . identifier !== null && { identifier : serializeAws_restJson1ItemIdentifier ( input . identifier , context ) } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , } ; } ; const serializeAws_restJson1RelatedItemList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1RelatedItem ( entry , context ) ; } ) ; } ; const serializeAws_restJson1RelatedItemsUpdate = ( input , context ) : any => { return RelatedItemsUpdate . visit ( input , { itemToAdd : ( value ) => ( { itemToAdd : serializeAws_restJson1RelatedItem ( value , context ) } ) , itemToRemove : ( value ) => ( { itemToRemove : serializeAws_restJson1ItemIdentifier ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1SsmAutomation = ( input , context ) : any => { return { ... ( input . documentName !== undefined && input . documentName !== null && { documentName : input . documentName } ) , ... ( input . documentVersion !== undefined && input . documentVersion !== null && { documentVersion : input . documentVersion } ) , ... ( input . parameters !== undefined && input . parameters !== null && { parameters : serializeAws_restJson1SsmParameters ( input . parameters , context ) } ) , ... ( input . roleArn !== undefined && input . roleArn !== null && { roleArn : input . roleArn } ) , ... ( input . targetAccount !== undefined && input . targetAccount !== null && { targetAccount : input . targetAccount } ) , } ; } ; const serializeAws_restJson1SsmParameters = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : serializeAws_restJson1SsmParameterValues ( value , context ) , } ; } , { } ) ; } ; const serializeAws_restJson1SsmParameterValues = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1StringList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1TagMap = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1TriggerDetails = ( input , context ) : any => { return { ... ( input . rawData !== undefined && input . rawData !== null && { rawData : input . rawData } ) , ... ( input . source !== undefined && input . source !== null && { source : input . source } ) , ... ( input . timestamp !== undefined && input . timestamp !== null && { timestamp : Math . round ( input . timestamp . getTime ( ) / 1000 ) } ) , ... ( input . triggerArn !== undefined && input . triggerArn !== null && { triggerArn : input . triggerArn } ) , } ; } ; const serializeAws_restJson1UpdateActionList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1UpdateReplicationSetAction ( entry , context ) ; } ) ; } ; const serializeAws_restJson1UpdateReplicationSetAction = ( input , context ) : any => { return UpdateReplicationSetAction . visit ( input , { addRegionAction : ( value ) => ( { addRegionAction : serializeAws_restJson1AddRegionAction ( value , context ) } ) , deleteRegionAction : ( value ) => ( { deleteRegionAction : serializeAws_restJson1DeleteRegionAction ( value , context ) } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const deserializeAws_restJson1Action = ( output , context ) : Action => { if ( output . ssmAutomation !== undefined && output . ssmAutomation !== null ) { return { ssmAutomation : deserializeAws_restJson1SsmAutomation ( output . ssmAutomation , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1ActionsList = ( output , context ) : Action [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Action ( __expectUnion ( entry ) , context ) ; } ) ; } ; const deserializeAws_restJson1AutomationExecution = ( output , context ) : AutomationExecution => { if ( __expectString ( output . ssmExecutionArn ) !== undefined ) { return { ssmExecutionArn : __expectString ( output . ssmExecutionArn ) as any } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1AutomationExecutionSet = ( output , context ) : AutomationExecution [ ] => { const uniqueValues = new Set < any > ( ) ; return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } const parsedEntry = deserializeAws_restJson1AutomationExecution ( __expectUnion ( entry ) , context ) ; if ( uniqueValues . has ( parsedEntry ) ) { throw new TypeError ( 'All elements of the set "com.amazonaws.ssmincidents#AutomationExecutionSet" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1ChatbotSnsConfigurationSet = ( output , context ) : string [ ] => { const uniqueValues = new Set < any > ( ) ; return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } const parsedEntry = __expectString ( entry ) as any ; if ( uniqueValues . has ( parsedEntry ) ) { throw new TypeError ( 'All elements of the set "com.amazonaws.ssmincidents#ChatbotSnsConfigurationSet" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1ChatChannel = ( output , context ) : ChatChannel => { if ( output . chatbotSns !== undefined && output . chatbotSns !== null ) { return { chatbotSns : deserializeAws_restJson1ChatbotSnsConfigurationSet ( output . chatbotSns , context ) , } ; } if ( output . empty !== undefined && output . empty !== null ) { return { empty : deserializeAws_restJson1EmptyChatChannel ( output . empty , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1EmptyChatChannel = ( output , context ) : EmptyChatChannel => { return { } as any ; } ; const deserializeAws_restJson1EngagementSet = ( output , context ) : string [ ] => { const uniqueValues = new Set < any > ( ) ; return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } const parsedEntry = __expectString ( entry ) as any ; if ( uniqueValues . has ( parsedEntry ) ) { throw new TypeError ( 'All elements of the set "com.amazonaws.ssmincidents#EngagementSet" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1EventSummary = ( output , context ) : EventSummary => { return { eventId : __expectString ( output . eventId ) , eventTime : output . eventTime !== undefined && output . eventTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . eventTime ) ) ) : undefined , eventType : __expectString ( output . eventType ) , eventUpdatedTime : output . eventUpdatedTime !== undefined && output . eventUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . eventUpdatedTime ) ) ) : undefined , incidentRecordArn : __expectString ( output . incidentRecordArn ) , } as any ; } ; const deserializeAws_restJson1EventSummaryList = ( output , context ) : EventSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1EventSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1IncidentRecord = ( output , context ) : IncidentRecord => { return { arn : __expectString ( output . arn ) , automationExecutions : output . automationExecutions !== undefined && output . automationExecutions !== null ? deserializeAws_restJson1AutomationExecutionSet ( output . automationExecutions , context ) : undefined , chatChannel : output . chatChannel !== undefined && output . chatChannel !== null ? deserializeAws_restJson1ChatChannel ( __expectUnion ( output . chatChannel ) , context ) : undefined , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , dedupeString : __expectString ( output . dedupeString ) , impact : __expectInt32 ( output . impact ) , incidentRecordSource : output . incidentRecordSource !== undefined && output . incidentRecordSource !== null ? deserializeAws_restJson1IncidentRecordSource ( output . incidentRecordSource , context ) : undefined , lastModifiedBy : __expectString ( output . lastModifiedBy ) , lastModifiedTime : output . lastModifiedTime !== undefined && output . lastModifiedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastModifiedTime ) ) ) : undefined , notificationTargets : output . notificationTargets !== undefined && output . notificationTargets !== null ? deserializeAws_restJson1NotificationTargetSet ( output . notificationTargets , context ) : undefined , resolvedTime : output . resolvedTime !== undefined && output . resolvedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . resolvedTime ) ) ) : undefined , status : __expectString ( output . status ) , summary : __expectString ( output . summary ) , title : __expectString ( output . title ) , } as any ; } ; const deserializeAws_restJson1IncidentRecordSource = ( output , context ) : IncidentRecordSource => { return { createdBy : __expectString ( output . createdBy ) , invokedBy : __expectString ( output . invokedBy ) , resourceArn : __expectString ( output . resourceArn ) , source : __expectString ( output . source ) , } as any ; } ; const deserializeAws_restJson1IncidentRecordSummary = ( output , context ) : IncidentRecordSummary => { return { arn : __expectString ( output . arn ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , impact : __expectInt32 ( output . impact ) , incidentRecordSource : output . incidentRecordSource !== undefined && output . incidentRecordSource !== null ? deserializeAws_restJson1IncidentRecordSource ( output . incidentRecordSource , context ) : undefined , resolvedTime : output . resolvedTime !== undefined && output . resolvedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . resolvedTime ) ) ) : undefined , status : __expectString ( output . status ) , title : __expectString ( output . title ) , } as any ; } ; const deserializeAws_restJson1IncidentRecordSummaryList = ( output , context ) : IncidentRecordSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1IncidentRecordSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1IncidentTemplate = ( output , context ) : IncidentTemplate => { return { dedupeString : __expectString ( output . dedupeString ) , impact : __expectInt32 ( output . impact ) , notificationTargets : output . notificationTargets !== undefined && output . notificationTargets !== null ? deserializeAws_restJson1NotificationTargetSet ( output . notificationTargets , context ) : undefined , summary : __expectString ( output . summary ) , title : __expectString ( output . title ) , } as any ; } ; const deserializeAws_restJson1ItemIdentifier = ( output , context ) : ItemIdentifier => { return { type : __expectString ( output . type ) , value : output . value !== undefined && output . value !== null ? deserializeAws_restJson1ItemValue ( __expectUnion ( output . value ) , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ItemValue = ( output , context ) : ItemValue => { if ( __expectString ( output . arn ) !== undefined ) { return { arn : __expectString ( output . arn ) as any } ; } if ( __expectString ( output . metricDefinition ) !== undefined ) { return { metricDefinition : __expectString ( output . metricDefinition ) as any } ; } if ( __expectString ( output . url ) !== undefined ) { return { url : __expectString ( output . url ) as any } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1NotificationTargetItem = ( output , context ) : NotificationTargetItem => { if ( __expectString ( output . snsTopicArn ) !== undefined ) { return { snsTopicArn : __expectString ( output . snsTopicArn ) as any } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1NotificationTargetSet = ( output , context ) : NotificationTargetItem [ ] => { const uniqueValues = new Set < any > ( ) ; return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } const parsedEntry = deserializeAws_restJson1NotificationTargetItem ( __expectUnion ( entry ) , context ) ; if ( uniqueValues . has ( parsedEntry ) ) { throw new TypeError ( 'All elements of the set "com.amazonaws.ssmincidents#NotificationTargetSet" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1RegionInfo = ( output , context ) : RegionInfo => { return { sseKmsKeyId : __expectString ( output . sseKmsKeyId ) , status : __expectString ( output . status ) , statusMessage : __expectString ( output . statusMessage ) , statusUpdateDateTime : output . statusUpdateDateTime !== undefined && output . statusUpdateDateTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . statusUpdateDateTime ) ) ) : undefined , } as any ; } ; const deserializeAws_restJson1RegionInfoMap = ( output , context ) : { [ key ] : RegionInfo ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1RegionInfo ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1RelatedItem = ( output , context ) : RelatedItem => { return { identifier : output . identifier !== undefined && output . identifier !== null ? deserializeAws_restJson1ItemIdentifier ( output . identifier , context ) : undefined , title : __expectString ( output . title ) , } as any ; } ; const deserializeAws_restJson1RelatedItemList = ( output , context ) : RelatedItem [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1RelatedItem ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ReplicationSet = ( output , context ) : ReplicationSet => { return { arn : __expectString ( output . arn ) , createdBy : __expectString ( output . createdBy ) , createdTime : output . createdTime !== undefined && output . createdTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . createdTime ) ) ) : undefined , deletionProtected : __expectBoolean ( output . deletionProtected ) , lastModifiedBy : __expectString ( output . lastModifiedBy ) , lastModifiedTime : output . lastModifiedTime !== undefined && output . lastModifiedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastModifiedTime ) ) ) : undefined , regionMap : output . regionMap !== undefined && output . regionMap !== null ? deserializeAws_restJson1RegionInfoMap ( output . regionMap , context ) : undefined , status : __expectString ( output . status ) , } as any ; } ; const deserializeAws_restJson1ReplicationSetArnList = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_restJson1ResourcePolicy = ( output , context ) : ResourcePolicy => { return { policyDocument : __expectString ( output . policyDocument ) , policyId : __expectString ( output . policyId ) , ramResourceShareRegion : __expectString ( output . ramResourceShareRegion ) , } as any ; } ; const deserializeAws_restJson1ResourcePolicyList = ( output , context ) : ResourcePolicy [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourcePolicy ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResponsePlanSummary = ( output , context ) : ResponsePlanSummary => { return { arn : __expectString ( output . arn ) , displayName : __expectString ( output . displayName ) , name : __expectString ( output . name ) , } as any ; } ; const deserializeAws_restJson1ResponsePlanSummaryList = ( output , context ) : ResponsePlanSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResponsePlanSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1SsmAutomation = ( output , context ) : SsmAutomation => { return { documentName : __expectString ( output . documentName ) , documentVersion : __expectString ( output . documentVersion ) , parameters : output . parameters !== undefined && output . parameters !== null ? deserializeAws_restJson1SsmParameters ( output . parameters , context ) : undefined , roleArn : __expectString ( output . roleArn ) , targetAccount : __expectString ( output . targetAccount ) , } as any ; } ; const deserializeAws_restJson1SsmParameters = ( output , context ) : { [ key ] : string [ ] ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1SsmParameterValues ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1SsmParameterValues = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_restJson1TagMap = ( 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_restJson1TimelineEvent = ( output , context ) : TimelineEvent => { return { eventData : __expectString ( output . eventData ) , eventId : __expectString ( output . eventId ) , eventTime : output . eventTime !== undefined && output . eventTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . eventTime ) ) ) : undefined , eventType : __expectString ( output . eventType ) , eventUpdatedTime : output . eventUpdatedTime !== undefined && output . eventUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . eventUpdatedTime ) ) ) : undefined , incidentRecordArn : __expectString ( output . incidentRecordArn ) , } 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 "" ; } ;