import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectObject as __expectObject , expectString as __expectString , extendedEncodeURIComponent as __extendedEncodeURIComponent , limitedParseDouble as __limitedParseDouble , parseRfc3339DateTime as __parseRfc3339DateTime , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { AddNotificationChannelsCommandInput , AddNotificationChannelsCommandOutput , } from "../commands/AddNotificationChannelsCommand" ; import { BatchGetFrameMetricDataCommandInput , BatchGetFrameMetricDataCommandOutput , } from "../commands/BatchGetFrameMetricDataCommand" ; import { ConfigureAgentCommandInput , ConfigureAgentCommandOutput } from "../commands/ConfigureAgentCommand" ; import { CreateProfilingGroupCommandInput , CreateProfilingGroupCommandOutput , } from "../commands/CreateProfilingGroupCommand" ; import { DeleteProfilingGroupCommandInput , DeleteProfilingGroupCommandOutput , } from "../commands/DeleteProfilingGroupCommand" ; import { DescribeProfilingGroupCommandInput , DescribeProfilingGroupCommandOutput , } from "../commands/DescribeProfilingGroupCommand" ; import { GetFindingsReportAccountSummaryCommandInput , GetFindingsReportAccountSummaryCommandOutput , } from "../commands/GetFindingsReportAccountSummaryCommand" ; import { GetNotificationConfigurationCommandInput , GetNotificationConfigurationCommandOutput , } from "../commands/GetNotificationConfigurationCommand" ; import { GetPolicyCommandInput , GetPolicyCommandOutput } from "../commands/GetPolicyCommand" ; import { GetProfileCommandInput , GetProfileCommandOutput } from "../commands/GetProfileCommand" ; import { GetRecommendationsCommandInput , GetRecommendationsCommandOutput } from "../commands/GetRecommendationsCommand" ; import { ListFindingsReportsCommandInput , ListFindingsReportsCommandOutput , } from "../commands/ListFindingsReportsCommand" ; import { ListProfileTimesCommandInput , ListProfileTimesCommandOutput } from "../commands/ListProfileTimesCommand" ; import { ListProfilingGroupsCommandInput , ListProfilingGroupsCommandOutput , } from "../commands/ListProfilingGroupsCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { PostAgentProfileCommandInput , PostAgentProfileCommandOutput } from "../commands/PostAgentProfileCommand" ; import { PutPermissionCommandInput , PutPermissionCommandOutput } from "../commands/PutPermissionCommand" ; import { RemoveNotificationChannelCommandInput , RemoveNotificationChannelCommandOutput , } from "../commands/RemoveNotificationChannelCommand" ; import { RemovePermissionCommandInput , RemovePermissionCommandOutput } from "../commands/RemovePermissionCommand" ; import { SubmitFeedbackCommandInput , SubmitFeedbackCommandOutput } from "../commands/SubmitFeedbackCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateProfilingGroupCommandInput , UpdateProfilingGroupCommandOutput , } from "../commands/UpdateProfilingGroupCommand" ; import { AgentConfiguration , AgentOrchestrationConfig , AgentParameterField , AggregatedProfileTime , Anomaly , AnomalyInstance , Channel , ConflictException , EventPublisher , FindingsReportSummary , FrameMetric , FrameMetricDatum , InternalServerException , Match , MetadataField , Metric , NotificationConfiguration , Pattern , ProfileTime , ProfilingGroupDescription , ProfilingStatus , Recommendation , ResourceNotFoundException , ServiceQuotaExceededException , ThrottlingException , TimestampStructure , UserFeedback , ValidationException , } from "../models/models_0" ; export const serializeAws_restJson1AddNotificationChannelsCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/notificationConfiguration" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; body = JSON . stringify ( { ... ( input . channels !== undefined && input . channels !== null && { channels : serializeAws_restJson1Channels ( input . channels , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1BatchGetFrameMetricDataCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/frames/-/metrics" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . startTime !== undefined && { startTime : ( input . startTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . endTime !== undefined && { endTime : ( input . endTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . period !== undefined && { period : input . period } ) , ... ( input . targetResolution !== undefined && { targetResolution : input . targetResolution } ) , } ; let body ; body = JSON . stringify ( { ... ( input . frameMetrics !== undefined && input . frameMetrics !== null && { frameMetrics : serializeAws_restJson1FrameMetrics ( input . frameMetrics , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ConfigureAgentCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/configureAgent" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; body = JSON . stringify ( { ... ( input . fleetInstanceId !== undefined && input . fleetInstanceId !== null && { fleetInstanceId : input . fleetInstanceId } ) , ... ( input . metadata !== undefined && input . metadata !== null && { metadata : serializeAws_restJson1Metadata ( input . metadata , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateProfilingGroupCommand = 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 || "" }` + "/profilingGroups" ; const query = { ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; body = JSON . stringify ( { ... ( input . agentOrchestrationConfig !== undefined && input . agentOrchestrationConfig !== null && { agentOrchestrationConfig : serializeAws_restJson1AgentOrchestrationConfig ( input . agentOrchestrationConfig , context ) , } ) , ... ( input . computePlatform !== undefined && input . computePlatform !== null && { computePlatform : input . computePlatform } ) , ... ( input . profilingGroupName !== undefined && input . profilingGroupName !== null && { profilingGroupName : input . profilingGroupName } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1TagsMap ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1DeleteProfilingGroupCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DescribeProfilingGroupCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetFindingsReportAccountSummaryCommand = 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 || "" }` + "/internal/findingsReports" ; const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , ... ( input . dailyReportsOnly !== undefined && { dailyReportsOnly : input . dailyReportsOnly . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetNotificationConfigurationCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/notificationConfiguration" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetPolicyCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/policy" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetProfileCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { ... ( isSerializableHeaderValue ( input . accept ) && { accept : input . accept ! } ) , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/profilingGroups/{profilingGroupName}/profile" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . startTime !== undefined && { startTime : ( input . startTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . period !== undefined && { period : input . period } ) , ... ( input . endTime !== undefined && { endTime : ( input . endTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . maxDepth !== undefined && { maxDepth : input . maxDepth . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetRecommendationsCommand = 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 || "" }` + "/internal/profilingGroups/{profilingGroupName}/recommendations" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . startTime !== undefined && { startTime : ( input . startTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . endTime !== undefined && { endTime : ( input . endTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . locale !== undefined && { locale : input . locale } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListFindingsReportsCommand = 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 || "" }` + "/internal/profilingGroups/{profilingGroupName}/findingsReports" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . startTime !== undefined && { startTime : ( input . startTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . endTime !== undefined && { endTime : ( input . endTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , ... ( input . dailyReportsOnly !== undefined && { dailyReportsOnly : input . dailyReportsOnly . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListProfileTimesCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/profileTimes" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . startTime !== undefined && { startTime : ( input . startTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . endTime !== undefined && { endTime : ( input . endTime . toISOString ( ) . split ( "." ) [ 0 ] + "Z" ) . toString ( ) } ) , ... ( input . period !== undefined && { period : input . period } ) , ... ( input . orderBy !== undefined && { orderBy : input . orderBy } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListProfilingGroupsCommand = 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 || "" }` + "/profilingGroups" ; const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , ... ( input . includeDescription !== undefined && { includeDescription : input . includeDescription . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , 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_restJson1PostAgentProfileCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/octet-stream" , ... ( isSerializableHeaderValue ( input . contentType ) && { "content-type" : input . contentType ! } ) , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/profilingGroups/{profilingGroupName}/agentProfile" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } const query = { ... ( input . profileToken !== undefined && { profileToken : input . profileToken } ) , } ; let body ; if ( input . agentProfile !== undefined ) { body = input . agentProfile ; } return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1PutPermissionCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/policy/{actionGroup}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } if ( input . actionGroup !== undefined ) { const labelValue = input . actionGroup ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: actionGroup." ) ; } resolvedPath = resolvedPath . replace ( "{actionGroup}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: actionGroup." ) ; } let body ; body = JSON . stringify ( { ... ( input . principals !== undefined && input . principals !== null && { principals : serializeAws_restJson1Principals ( input . principals , context ) } ) , ... ( input . revisionId !== undefined && input . revisionId !== null && { revisionId : input . revisionId } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "PUT" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1RemoveNotificationChannelCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/notificationConfiguration/{channelId}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } if ( input . channelId !== undefined ) { const labelValue = input . channelId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: channelId." ) ; } resolvedPath = resolvedPath . replace ( "{channelId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: channelId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1RemovePermissionCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}/policy/{actionGroup}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } if ( input . actionGroup !== undefined ) { const labelValue = input . actionGroup ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: actionGroup." ) ; } resolvedPath = resolvedPath . replace ( "{actionGroup}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: actionGroup." ) ; } const query = { ... ( input . revisionId !== undefined && { revisionId : input . revisionId } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1SubmitFeedbackCommand = 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 || "" }` + "/internal/profilingGroups/{profilingGroupName}/anomalies/{anomalyInstanceId}/feedback" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } if ( input . anomalyInstanceId !== undefined ) { const labelValue = input . anomalyInstanceId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: anomalyInstanceId." ) ; } resolvedPath = resolvedPath . replace ( "{anomalyInstanceId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: anomalyInstanceId." ) ; } let body ; body = JSON . stringify ( { ... ( input . comment !== undefined && input . comment !== null && { comment : input . comment } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ) ; 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_restJson1TagsMap ( 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_restJson1UpdateProfilingGroupCommand = 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 || "" }` + "/profilingGroups/{profilingGroupName}" ; if ( input . profilingGroupName !== undefined ) { const labelValue = input . profilingGroupName ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: profilingGroupName." ) ; } resolvedPath = resolvedPath . replace ( "{profilingGroupName}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: profilingGroupName." ) ; } let body ; body = JSON . stringify ( { ... ( input . agentOrchestrationConfig !== undefined && input . agentOrchestrationConfig !== null && { agentOrchestrationConfig : serializeAws_restJson1AgentOrchestrationConfig ( input . agentOrchestrationConfig , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "PUT" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1AddNotificationChannelsCommand = async ( output , context ) : Promise < AddNotificationChannelsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1AddNotificationChannelsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , notificationConfiguration : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . notificationConfiguration !== undefined && data . notificationConfiguration !== null ) { contents . notificationConfiguration = deserializeAws_restJson1NotificationConfiguration ( data . notificationConfiguration , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1AddNotificationChannelsCommandError = async ( output , context ) : Promise < AddNotificationChannelsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.codeguruprofiler#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1BatchGetFrameMetricDataCommand = async ( output , context ) : Promise < BatchGetFrameMetricDataCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1BatchGetFrameMetricDataCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , endTime : undefined , endTimes : undefined , frameMetricData : undefined , resolution : undefined , startTime : undefined , unprocessedEndTimes : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . endTime !== undefined && data . endTime !== null ) { contents . endTime = __expectNonNull ( __parseRfc3339DateTime ( data . endTime ) ) ; } if ( data . endTimes !== undefined && data . endTimes !== null ) { contents . endTimes = deserializeAws_restJson1ListOfTimestamps ( data . endTimes , context ) ; } if ( data . frameMetricData !== undefined && data . frameMetricData !== null ) { contents . frameMetricData = deserializeAws_restJson1FrameMetricData ( data . frameMetricData , context ) ; } if ( data . resolution !== undefined && data . resolution !== null ) { contents . resolution = __expectString ( data . resolution ) ; } if ( data . startTime !== undefined && data . startTime !== null ) { contents . startTime = __expectNonNull ( __parseRfc3339DateTime ( data . startTime ) ) ; } if ( data . unprocessedEndTimes !== undefined && data . unprocessedEndTimes !== null ) { contents . unprocessedEndTimes = deserializeAws_restJson1UnprocessedEndTimeMap ( data . unprocessedEndTimes , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1BatchGetFrameMetricDataCommandError = async ( output , context ) : Promise < BatchGetFrameMetricDataCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1ConfigureAgentCommand = async ( output , context ) : Promise < ConfigureAgentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ConfigureAgentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , configuration : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . configuration = deserializeAws_restJson1AgentConfiguration ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ConfigureAgentCommandError = async ( output , context ) : Promise < ConfigureAgentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1CreateProfilingGroupCommand = async ( output , context ) : Promise < CreateProfilingGroupCommandOutput > => { if ( output . statusCode !== 201 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateProfilingGroupCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , profilingGroup : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . profilingGroup = deserializeAws_restJson1ProfilingGroupDescription ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateProfilingGroupCommandError = async ( output , context ) : Promise < CreateProfilingGroupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.codeguruprofiler#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1DeleteProfilingGroupCommand = async ( output , context ) : Promise < DeleteProfilingGroupCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteProfilingGroupCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteProfilingGroupCommandError = async ( output , context ) : Promise < DeleteProfilingGroupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1DescribeProfilingGroupCommand = async ( output , context ) : Promise < DescribeProfilingGroupCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DescribeProfilingGroupCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , profilingGroup : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . profilingGroup = deserializeAws_restJson1ProfilingGroupDescription ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DescribeProfilingGroupCommandError = async ( output , context ) : Promise < DescribeProfilingGroupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1GetFindingsReportAccountSummaryCommand = async ( output , context ) : Promise < GetFindingsReportAccountSummaryCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetFindingsReportAccountSummaryCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , reportSummaries : 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 . reportSummaries !== undefined && data . reportSummaries !== null ) { contents . reportSummaries = deserializeAws_restJson1FindingsReportSummaries ( data . reportSummaries , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetFindingsReportAccountSummaryCommandError = async ( output , context ) : Promise < GetFindingsReportAccountSummaryCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1GetNotificationConfigurationCommand = async ( output , context ) : Promise < GetNotificationConfigurationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetNotificationConfigurationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , notificationConfiguration : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . notificationConfiguration !== undefined && data . notificationConfiguration !== null ) { contents . notificationConfiguration = deserializeAws_restJson1NotificationConfiguration ( data . notificationConfiguration , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetNotificationConfigurationCommandError = async ( output , context ) : Promise < GetNotificationConfigurationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1GetPolicyCommand = async ( output , context ) : Promise < GetPolicyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetPolicyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , policy : undefined , revisionId : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . policy !== undefined && data . policy !== null ) { contents . policy = __expectString ( data . policy ) ; } if ( data . revisionId !== undefined && data . revisionId !== null ) { contents . revisionId = __expectString ( data . revisionId ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetPolicyCommandError = async ( output , context ) : Promise < GetPolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( 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_restJson1GetProfileCommand = async ( output , context ) : Promise < GetProfileCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetProfileCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , contentEncoding : undefined , contentType : undefined , profile : undefined , } ; if ( output . headers [ "content-type" ] !== undefined ) { contents . contentType = output . headers [ "content-type" ] ; } if ( output . headers [ "content-encoding" ] !== undefined ) { contents . contentEncoding = output . headers [ "content-encoding" ] ; } const data = await collectBody ( output . body , context ) ; contents . profile = data ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetProfileCommandError = async ( output , context ) : Promise < GetProfileCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1GetRecommendationsCommand = async ( output , context ) : Promise < GetRecommendationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetRecommendationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , anomalies : undefined , profileEndTime : undefined , profileStartTime : undefined , profilingGroupName : undefined , recommendations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . anomalies !== undefined && data . anomalies !== null ) { contents . anomalies = deserializeAws_restJson1Anomalies ( data . anomalies , context ) ; } if ( data . profileEndTime !== undefined && data . profileEndTime !== null ) { contents . profileEndTime = __expectNonNull ( __parseRfc3339DateTime ( data . profileEndTime ) ) ; } if ( data . profileStartTime !== undefined && data . profileStartTime !== null ) { contents . profileStartTime = __expectNonNull ( __parseRfc3339DateTime ( data . profileStartTime ) ) ; } if ( data . profilingGroupName !== undefined && data . profilingGroupName !== null ) { contents . profilingGroupName = __expectString ( data . profilingGroupName ) ; } if ( data . recommendations !== undefined && data . recommendations !== null ) { contents . recommendations = deserializeAws_restJson1Recommendations ( data . recommendations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetRecommendationsCommandError = async ( output , context ) : Promise < GetRecommendationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1ListFindingsReportsCommand = async ( output , context ) : Promise < ListFindingsReportsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListFindingsReportsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , findingsReportSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . findingsReportSummaries !== undefined && data . findingsReportSummaries !== null ) { contents . findingsReportSummaries = deserializeAws_restJson1FindingsReportSummaries ( data . findingsReportSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListFindingsReportsCommandError = async ( output , context ) : Promise < ListFindingsReportsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1ListProfileTimesCommand = async ( output , context ) : Promise < ListProfileTimesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListProfileTimesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , profileTimes : 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 . profileTimes !== undefined && data . profileTimes !== null ) { contents . profileTimes = deserializeAws_restJson1ProfileTimes ( data . profileTimes , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListProfileTimesCommandError = async ( output , context ) : Promise < ListProfileTimesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1ListProfilingGroupsCommand = async ( output , context ) : Promise < ListProfilingGroupsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListProfilingGroupsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , profilingGroupNames : undefined , profilingGroups : 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 . profilingGroupNames !== undefined && data . profilingGroupNames !== null ) { contents . profilingGroupNames = deserializeAws_restJson1ProfilingGroupNames ( data . profilingGroupNames , context ) ; } if ( data . profilingGroups !== undefined && data . profilingGroups !== null ) { contents . profilingGroups = deserializeAws_restJson1ProfilingGroupDescriptions ( data . profilingGroups , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListProfilingGroupsCommandError = async ( output , context ) : Promise < ListProfilingGroupsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( 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_restJson1TagsMap ( data . tags , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1PostAgentProfileCommand = async ( output , context ) : Promise < PostAgentProfileCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1PostAgentProfileCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1PostAgentProfileCommandError = async ( output , context ) : Promise < PostAgentProfileCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1PutPermissionCommand = async ( output , context ) : Promise < PutPermissionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1PutPermissionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , policy : undefined , revisionId : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . policy !== undefined && data . policy !== null ) { contents . policy = __expectString ( data . policy ) ; } if ( data . revisionId !== undefined && data . revisionId !== null ) { contents . revisionId = __expectString ( data . revisionId ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1PutPermissionCommandError = async ( output , context ) : Promise < PutPermissionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1RemoveNotificationChannelCommand = async ( output , context ) : Promise < RemoveNotificationChannelCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1RemoveNotificationChannelCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , notificationConfiguration : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . notificationConfiguration !== undefined && data . notificationConfiguration !== null ) { contents . notificationConfiguration = deserializeAws_restJson1NotificationConfiguration ( data . notificationConfiguration , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1RemoveNotificationChannelCommandError = async ( output , context ) : Promise < RemoveNotificationChannelCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1RemovePermissionCommand = async ( output , context ) : Promise < RemovePermissionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1RemovePermissionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , policy : undefined , revisionId : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . policy !== undefined && data . policy !== null ) { contents . policy = __expectString ( data . policy ) ; } if ( data . revisionId !== undefined && data . revisionId !== null ) { contents . revisionId = __expectString ( data . revisionId ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1RemovePermissionCommandError = async ( output , context ) : Promise < RemovePermissionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1SubmitFeedbackCommand = async ( output , context ) : Promise < SubmitFeedbackCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1SubmitFeedbackCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1SubmitFeedbackCommandError = async ( output , context ) : Promise < SubmitFeedbackCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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 "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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 "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1UpdateProfilingGroupCommand = async ( output , context ) : Promise < UpdateProfilingGroupCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateProfilingGroupCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , profilingGroup : undefined , } ; const data = __expectObject ( await parseBody ( output . body , context ) ) ; contents . profilingGroup = deserializeAws_restJson1ProfilingGroupDescription ( data , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateProfilingGroupCommandError = async ( output , context ) : Promise < UpdateProfilingGroupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.codeguruprofiler#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServerException" : case "com.amazonaws.codeguruprofiler#InternalServerException" : response = { ... ( await deserializeAws_restJson1InternalServerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.codeguruprofiler#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.codeguruprofiler#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.codeguruprofiler#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_restJson1ConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ConflictException > => { const contents = { name : "ConflictException" , $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_restJson1InternalServerExceptionResponse = async ( parsedOutput , context ) : Promise < InternalServerException > => { const contents = { name : "InternalServerException" , $fault : "server" , $retryable : { } , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceQuotaExceededException > => { const contents = { name : "ServiceQuotaExceededException" , $fault : "client" , $retryable : { } , $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_restJson1ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const contents = { name : "ThrottlingException" , $fault : "client" , $retryable : { } , $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_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_restJson1AgentOrchestrationConfig = ( input , context ) : any => { return { ... ( input . profilingEnabled !== undefined && input . profilingEnabled !== null && { profilingEnabled : input . profilingEnabled } ) , } ; } ; const serializeAws_restJson1Channel = ( input , context ) : any => { return { ... ( input . eventPublishers !== undefined && input . eventPublishers !== null && { eventPublishers : serializeAws_restJson1EventPublishers ( input . eventPublishers , context ) , } ) , ... ( input . id !== undefined && input . id !== null && { id : input . id } ) , ... ( input . uri !== undefined && input . uri !== null && { uri : input . uri } ) , } ; } ; const serializeAws_restJson1Channels = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Channel ( entry , context ) ; } ) ; } ; const serializeAws_restJson1EventPublishers = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1FrameMetric = ( input , context ) : any => { return { ... ( input . frameName !== undefined && input . frameName !== null && { frameName : input . frameName } ) , ... ( input . threadStates !== undefined && input . threadStates !== null && { threadStates : serializeAws_restJson1ThreadStates ( input . threadStates , context ) } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ; } ; const serializeAws_restJson1FrameMetrics = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1FrameMetric ( entry , context ) ; } ) ; } ; const serializeAws_restJson1Metadata = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1Principals = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1TagsMap = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1ThreadStates = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const deserializeAws_restJson1AgentConfiguration = ( output , context ) : AgentConfiguration => { return { agentParameters : output . agentParameters !== undefined && output . agentParameters !== null ? deserializeAws_restJson1AgentParameters ( output . agentParameters , context ) : undefined , periodInSeconds : __expectInt32 ( output . periodInSeconds ) , shouldProfile : __expectBoolean ( output . shouldProfile ) , } as any ; } ; const deserializeAws_restJson1AgentOrchestrationConfig = ( output , context ) : AgentOrchestrationConfig => { return { profilingEnabled : __expectBoolean ( output . profilingEnabled ) , } as any ; } ; const deserializeAws_restJson1AgentParameters = ( 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_restJson1AggregatedProfileTime = ( output , context ) : AggregatedProfileTime => { return { period : __expectString ( output . period ) , start : output . start !== undefined && output . start !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . start ) ) : undefined , } as any ; } ; const deserializeAws_restJson1Anomalies = ( output , context ) : Anomaly [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Anomaly ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Anomaly = ( output , context ) : Anomaly => { return { instances : output . instances !== undefined && output . instances !== null ? deserializeAws_restJson1AnomalyInstances ( output . instances , context ) : undefined , metric : output . metric !== undefined && output . metric !== null ? deserializeAws_restJson1Metric ( output . metric , context ) : undefined , reason : __expectString ( output . reason ) , } as any ; } ; const deserializeAws_restJson1AnomalyInstance = ( output , context ) : AnomalyInstance => { return { endTime : output . endTime !== undefined && output . endTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . endTime ) ) : undefined , id : __expectString ( output . id ) , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , userFeedback : output . userFeedback !== undefined && output . userFeedback !== null ? deserializeAws_restJson1UserFeedback ( output . userFeedback , context ) : undefined , } as any ; } ; const deserializeAws_restJson1AnomalyInstances = ( output , context ) : AnomalyInstance [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1AnomalyInstance ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Channel = ( output , context ) : Channel => { return { eventPublishers : output . eventPublishers !== undefined && output . eventPublishers !== null ? deserializeAws_restJson1EventPublishers ( output . eventPublishers , context ) : undefined , id : __expectString ( output . id ) , uri : __expectString ( output . uri ) , } as any ; } ; const deserializeAws_restJson1Channels = ( output , context ) : Channel [ ] => { const uniqueValues = new Set < any > ( ) ; return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } const parsedEntry = deserializeAws_restJson1Channel ( entry , context ) ; if ( uniqueValues . has ( parsedEntry ) ) { throw new TypeError ( 'All elements of the set "com.amazonaws.codeguruprofiler#Channels" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1EventPublishers = ( output , context ) : ( EventPublisher | 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.codeguruprofiler#EventPublishers" must be unique.' ) ; } else { uniqueValues . add ( parsedEntry ) ; return parsedEntry ; } } ) ; } ; const deserializeAws_restJson1FindingsReportSummaries = ( output , context ) : FindingsReportSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1FindingsReportSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1FindingsReportSummary = ( output , context ) : FindingsReportSummary => { return { id : __expectString ( output . id ) , profileEndTime : output . profileEndTime !== undefined && output . profileEndTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . profileEndTime ) ) : undefined , profileStartTime : output . profileStartTime !== undefined && output . profileStartTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . profileStartTime ) ) : undefined , profilingGroupName : __expectString ( output . profilingGroupName ) , totalNumberOfFindings : __expectInt32 ( output . totalNumberOfFindings ) , } as any ; } ; const deserializeAws_restJson1FrameMetric = ( output , context ) : FrameMetric => { return { frameName : __expectString ( output . frameName ) , threadStates : output . threadStates !== undefined && output . threadStates !== null ? deserializeAws_restJson1ThreadStates ( output . threadStates , context ) : undefined , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1FrameMetricData = ( output , context ) : FrameMetricDatum [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1FrameMetricDatum ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1FrameMetricDatum = ( output , context ) : FrameMetricDatum => { return { frameMetric : output . frameMetric !== undefined && output . frameMetric !== null ? deserializeAws_restJson1FrameMetric ( output . frameMetric , context ) : undefined , values : output . values !== undefined && output . values !== null ? deserializeAws_restJson1FrameMetricValues ( output . values , context ) : undefined , } as any ; } ; const deserializeAws_restJson1FrameMetricValues = ( output , context ) : number [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __limitedParseDouble ( entry ) as any ; } ) ; } ; const deserializeAws_restJson1ListOfTimestamps = ( output , context ) : TimestampStructure [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1TimestampStructure ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Match = ( output , context ) : Match => { return { frameAddress : __expectString ( output . frameAddress ) , targetFramesIndex : __expectInt32 ( output . targetFramesIndex ) , thresholdBreachValue : __limitedParseDouble ( output . thresholdBreachValue ) , } as any ; } ; const deserializeAws_restJson1Matches = ( output , context ) : Match [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Match ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Metric = ( output , context ) : Metric => { return { frameName : __expectString ( output . frameName ) , threadStates : output . threadStates !== undefined && output . threadStates !== null ? deserializeAws_restJson1Strings ( output . threadStates , context ) : undefined , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1NotificationConfiguration = ( output , context ) : NotificationConfiguration => { return { channels : output . channels !== undefined && output . channels !== null ? deserializeAws_restJson1Channels ( output . channels , context ) : undefined , } as any ; } ; const deserializeAws_restJson1Pattern = ( output , context ) : Pattern => { return { countersToAggregate : output . countersToAggregate !== undefined && output . countersToAggregate !== null ? deserializeAws_restJson1Strings ( output . countersToAggregate , context ) : undefined , description : __expectString ( output . description ) , id : __expectString ( output . id ) , name : __expectString ( output . name ) , resolutionSteps : __expectString ( output . resolutionSteps ) , targetFrames : output . targetFrames !== undefined && output . targetFrames !== null ? deserializeAws_restJson1TargetFrames ( output . targetFrames , context ) : undefined , thresholdPercent : __limitedParseDouble ( output . thresholdPercent ) , } as any ; } ; const deserializeAws_restJson1ProfileTime = ( output , context ) : ProfileTime => { return { start : output . start !== undefined && output . start !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . start ) ) : undefined , } as any ; } ; const deserializeAws_restJson1ProfileTimes = ( output , context ) : ProfileTime [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ProfileTime ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ProfilingGroupDescription = ( output , context ) : ProfilingGroupDescription => { return { agentOrchestrationConfig : output . agentOrchestrationConfig !== undefined && output . agentOrchestrationConfig !== null ? deserializeAws_restJson1AgentOrchestrationConfig ( output . agentOrchestrationConfig , context ) : undefined , arn : __expectString ( output . arn ) , computePlatform : __expectString ( output . computePlatform ) , createdAt : output . createdAt !== undefined && output . createdAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . createdAt ) ) : undefined , name : __expectString ( output . name ) , profilingStatus : output . profilingStatus !== undefined && output . profilingStatus !== null ? deserializeAws_restJson1ProfilingStatus ( output . profilingStatus , context ) : undefined , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1TagsMap ( output . tags , context ) : undefined , updatedAt : output . updatedAt !== undefined && output . updatedAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . updatedAt ) ) : undefined , } as any ; } ; const deserializeAws_restJson1ProfilingGroupDescriptions = ( output , context ) : ProfilingGroupDescription [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ProfilingGroupDescription ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ProfilingGroupNames = ( 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_restJson1ProfilingStatus = ( output , context ) : ProfilingStatus => { return { latestAgentOrchestratedAt : output . latestAgentOrchestratedAt !== undefined && output . latestAgentOrchestratedAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . latestAgentOrchestratedAt ) ) : undefined , latestAgentProfileReportedAt : output . latestAgentProfileReportedAt !== undefined && output . latestAgentProfileReportedAt !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . latestAgentProfileReportedAt ) ) : undefined , latestAggregatedProfile : output . latestAggregatedProfile !== undefined && output . latestAggregatedProfile !== null ? deserializeAws_restJson1AggregatedProfileTime ( output . latestAggregatedProfile , context ) : undefined , } as any ; } ; const deserializeAws_restJson1Recommendation = ( output , context ) : Recommendation => { return { allMatchesCount : __expectInt32 ( output . allMatchesCount ) , allMatchesSum : __limitedParseDouble ( output . allMatchesSum ) , endTime : output . endTime !== undefined && output . endTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . endTime ) ) : undefined , pattern : output . pattern !== undefined && output . pattern !== null ? deserializeAws_restJson1Pattern ( output . pattern , context ) : undefined , startTime : output . startTime !== undefined && output . startTime !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . startTime ) ) : undefined , topMatches : output . topMatches !== undefined && output . topMatches !== null ? deserializeAws_restJson1Matches ( output . topMatches , context ) : undefined , } as any ; } ; const deserializeAws_restJson1Recommendations = ( output , context ) : Recommendation [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Recommendation ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Strings = ( 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_restJson1TagsMap = ( 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_restJson1TargetFrame = ( 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_restJson1TargetFrames = ( output , context ) : string [ ] [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1TargetFrame ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ThreadStates = ( 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_restJson1TimestampStructure = ( output , context ) : TimestampStructure => { return { value : output . value !== undefined && output . value !== null ? __expectNonNull ( __parseRfc3339DateTime ( output . value ) ) : undefined , } as any ; } ; const deserializeAws_restJson1UnprocessedEndTimeMap = ( output , context ) : { [ key ] : TimestampStructure [ ] ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_restJson1ListOfTimestamps ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_restJson1UserFeedback = ( output , context ) : UserFeedback => { return { type : __expectString ( output . type ) , } 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 "" ; } ;