import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { AssociateNodeCommandInput , AssociateNodeCommandOutput } from "../commands/AssociateNodeCommand" ; import { CreateBackupCommandInput , CreateBackupCommandOutput } from "../commands/CreateBackupCommand" ; import { CreateServerCommandInput , CreateServerCommandOutput } from "../commands/CreateServerCommand" ; import { DeleteBackupCommandInput , DeleteBackupCommandOutput } from "../commands/DeleteBackupCommand" ; import { DeleteServerCommandInput , DeleteServerCommandOutput } from "../commands/DeleteServerCommand" ; import { DescribeAccountAttributesCommandInput , DescribeAccountAttributesCommandOutput , } from "../commands/DescribeAccountAttributesCommand" ; import { DescribeBackupsCommandInput , DescribeBackupsCommandOutput } from "../commands/DescribeBackupsCommand" ; import { DescribeEventsCommandInput , DescribeEventsCommandOutput } from "../commands/DescribeEventsCommand" ; import { DescribeNodeAssociationStatusCommandInput , DescribeNodeAssociationStatusCommandOutput , } from "../commands/DescribeNodeAssociationStatusCommand" ; import { DescribeServersCommandInput , DescribeServersCommandOutput } from "../commands/DescribeServersCommand" ; import { DisassociateNodeCommandInput , DisassociateNodeCommandOutput } from "../commands/DisassociateNodeCommand" ; import { ExportServerEngineAttributeCommandInput , ExportServerEngineAttributeCommandOutput , } from "../commands/ExportServerEngineAttributeCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { RestoreServerCommandInput , RestoreServerCommandOutput } from "../commands/RestoreServerCommand" ; import { StartMaintenanceCommandInput , StartMaintenanceCommandOutput } from "../commands/StartMaintenanceCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateServerCommandInput , UpdateServerCommandOutput } from "../commands/UpdateServerCommand" ; import { UpdateServerEngineAttributesCommandInput , UpdateServerEngineAttributesCommandOutput , } from "../commands/UpdateServerEngineAttributesCommand" ; import { AccountAttribute , AssociateNodeRequest , AssociateNodeResponse , Backup , CreateBackupRequest , CreateBackupResponse , CreateServerRequest , CreateServerResponse , DeleteBackupRequest , DeleteBackupResponse , DeleteServerRequest , DeleteServerResponse , DescribeAccountAttributesRequest , DescribeAccountAttributesResponse , DescribeBackupsRequest , DescribeBackupsResponse , DescribeEventsRequest , DescribeEventsResponse , DescribeNodeAssociationStatusRequest , DescribeNodeAssociationStatusResponse , DescribeServersRequest , DescribeServersResponse , DisassociateNodeRequest , DisassociateNodeResponse , EngineAttribute , ExportServerEngineAttributeRequest , ExportServerEngineAttributeResponse , InvalidNextTokenException , InvalidStateException , LimitExceededException , ListTagsForResourceRequest , ListTagsForResourceResponse , ResourceAlreadyExistsException , ResourceNotFoundException , RestoreServerRequest , RestoreServerResponse , Server , ServerEvent , StartMaintenanceRequest , StartMaintenanceResponse , Tag , TagResourceRequest , TagResourceResponse , UntagResourceRequest , UntagResourceResponse , UpdateServerEngineAttributesRequest , UpdateServerEngineAttributesResponse , UpdateServerRequest , UpdateServerResponse , ValidationException , } from "../models/models_0" ; export const serializeAws_json1_1AssociateNodeCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.AssociateNode" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1AssociateNodeRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateBackupCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.CreateBackup" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateBackupRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateServerCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.CreateServer" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateServerRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteBackupCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DeleteBackup" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteBackupRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteServerCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DeleteServer" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteServerRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeAccountAttributesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DescribeAccountAttributes" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeAccountAttributesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeBackupsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DescribeBackups" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeBackupsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeEventsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DescribeEvents" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeEventsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeNodeAssociationStatusCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DescribeNodeAssociationStatus" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeNodeAssociationStatusRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeServersCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DescribeServers" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeServersRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DisassociateNodeCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.DisassociateNode" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DisassociateNodeRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ExportServerEngineAttributeCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.ExportServerEngineAttribute" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ExportServerEngineAttributeRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.ListTagsForResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListTagsForResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RestoreServerCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.RestoreServer" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RestoreServerRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1StartMaintenanceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.StartMaintenance" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1StartMaintenanceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1TagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.TagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1TagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UntagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateServerCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.UpdateServer" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateServerRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateServerEngineAttributesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "OpsWorksCM_V2016_11_01.UpdateServerEngineAttributes" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateServerEngineAttributesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1AssociateNodeCommand = async ( output , context ) : Promise < AssociateNodeCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1AssociateNodeCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1AssociateNodeResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1AssociateNodeCommandError = async ( output , context ) : Promise < AssociateNodeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1CreateBackupCommand = async ( output , context ) : Promise < CreateBackupCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateBackupCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateBackupResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateBackupCommandError = async ( output , context ) : Promise < CreateBackupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.opsworkscm#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1CreateServerCommand = async ( output , context ) : Promise < CreateServerCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateServerCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateServerResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateServerCommandError = async ( output , context ) : Promise < CreateServerCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "LimitExceededException" : case "com.amazonaws.opsworkscm#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceAlreadyExistsException" : case "com.amazonaws.opsworkscm#ResourceAlreadyExistsException" : response = { ... ( await deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DeleteBackupCommand = async ( output , context ) : Promise < DeleteBackupCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteBackupCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteBackupResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteBackupCommandError = async ( output , context ) : Promise < DeleteBackupCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DeleteServerCommand = async ( output , context ) : Promise < DeleteServerCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteServerCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteServerResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteServerCommandError = async ( output , context ) : Promise < DeleteServerCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DescribeAccountAttributesCommand = async ( output , context ) : Promise < DescribeAccountAttributesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeAccountAttributesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeAccountAttributesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeAccountAttributesCommandError = async ( output , context ) : Promise < DescribeAccountAttributesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DescribeBackupsCommand = async ( output , context ) : Promise < DescribeBackupsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeBackupsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeBackupsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeBackupsCommandError = async ( output , context ) : Promise < DescribeBackupsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.opsworkscm#InvalidNextTokenException" : response = { ... ( await deserializeAws_json1_1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DescribeEventsCommand = async ( output , context ) : Promise < DescribeEventsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeEventsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeEventsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeEventsCommandError = async ( output , context ) : Promise < DescribeEventsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.opsworkscm#InvalidNextTokenException" : response = { ... ( await deserializeAws_json1_1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DescribeNodeAssociationStatusCommand = async ( output , context ) : Promise < DescribeNodeAssociationStatusCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeNodeAssociationStatusCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeNodeAssociationStatusResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeNodeAssociationStatusCommandError = async ( output , context ) : Promise < DescribeNodeAssociationStatusCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DescribeServersCommand = async ( output , context ) : Promise < DescribeServersCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeServersCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeServersResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeServersCommandError = async ( output , context ) : Promise < DescribeServersCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.opsworkscm#InvalidNextTokenException" : response = { ... ( await deserializeAws_json1_1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1DisassociateNodeCommand = async ( output , context ) : Promise < DisassociateNodeCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DisassociateNodeCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DisassociateNodeResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DisassociateNodeCommandError = async ( output , context ) : Promise < DisassociateNodeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1ExportServerEngineAttributeCommand = async ( output , context ) : Promise < ExportServerEngineAttributeCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ExportServerEngineAttributeCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ExportServerEngineAttributeResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ExportServerEngineAttributeCommandError = async ( output , context ) : Promise < ExportServerEngineAttributeCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListTagsForResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListTagsForResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1RestoreServerCommand = async ( output , context ) : Promise < RestoreServerCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RestoreServerCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1RestoreServerResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RestoreServerCommandError = async ( output , context ) : Promise < RestoreServerCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1StartMaintenanceCommand = async ( output , context ) : Promise < StartMaintenanceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1StartMaintenanceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1StartMaintenanceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1StartMaintenanceCommandError = async ( output , context ) : Promise < StartMaintenanceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1TagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1TagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UntagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UntagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1UpdateServerCommand = async ( output , context ) : Promise < UpdateServerCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateServerCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateServerResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateServerCommandError = async ( output , context ) : Promise < UpdateServerCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1UpdateServerEngineAttributesCommand = async ( output , context ) : Promise < UpdateServerEngineAttributesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateServerEngineAttributesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateServerEngineAttributesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateServerEngineAttributesCommandError = async ( output , context ) : Promise < UpdateServerEngineAttributesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidStateException" : case "com.amazonaws.opsworkscm#InvalidStateException" : response = { ... ( await deserializeAws_json1_1InvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.opsworkscm#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.opsworkscm#ValidationException" : response = { ... ( await deserializeAws_json1_1ValidationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; const deserializeAws_json1_1InvalidNextTokenExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidNextTokenException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidNextTokenException ( body , context ) ; const contents = { name : "InvalidNextTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidStateExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidStateException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidStateException ( body , context ) ; const contents = { name : "InvalidStateException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1LimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < LimitExceededException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1LimitExceededException ( body , context ) ; const contents = { name : "LimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceAlreadyExistsExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceAlreadyExistsException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceAlreadyExistsException ( body , context ) ; const contents = { name : "ResourceAlreadyExistsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceNotFoundException ( body , context ) ; const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ValidationExceptionResponse = async ( parsedOutput , context ) : Promise < ValidationException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ValidationException ( body , context ) ; const contents = { name : "ValidationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_1AssociateNodeRequest = ( input , context ) : any => { return { ... ( input . EngineAttributes !== undefined && input . EngineAttributes !== null && { EngineAttributes : serializeAws_json1_1EngineAttributes ( input . EngineAttributes , context ) , } ) , ... ( input . NodeName !== undefined && input . NodeName !== null && { NodeName : input . NodeName } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1CreateBackupRequest = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1CreateServerRequest = ( input , context ) : any => { return { ... ( input . AssociatePublicIpAddress !== undefined && input . AssociatePublicIpAddress !== null && { AssociatePublicIpAddress : input . AssociatePublicIpAddress } ) , ... ( input . BackupId !== undefined && input . BackupId !== null && { BackupId : input . BackupId } ) , ... ( input . BackupRetentionCount !== undefined && input . BackupRetentionCount !== null && { BackupRetentionCount : input . BackupRetentionCount } ) , ... ( input . CustomCertificate !== undefined && input . CustomCertificate !== null && { CustomCertificate : input . CustomCertificate } ) , ... ( input . CustomDomain !== undefined && input . CustomDomain !== null && { CustomDomain : input . CustomDomain } ) , ... ( input . CustomPrivateKey !== undefined && input . CustomPrivateKey !== null && { CustomPrivateKey : input . CustomPrivateKey } ) , ... ( input . DisableAutomatedBackup !== undefined && input . DisableAutomatedBackup !== null && { DisableAutomatedBackup : input . DisableAutomatedBackup } ) , ... ( input . Engine !== undefined && input . Engine !== null && { Engine : input . Engine } ) , ... ( input . EngineAttributes !== undefined && input . EngineAttributes !== null && { EngineAttributes : serializeAws_json1_1EngineAttributes ( input . EngineAttributes , context ) , } ) , ... ( input . EngineModel !== undefined && input . EngineModel !== null && { EngineModel : input . EngineModel } ) , ... ( input . EngineVersion !== undefined && input . EngineVersion !== null && { EngineVersion : input . EngineVersion } ) , ... ( input . InstanceProfileArn !== undefined && input . InstanceProfileArn !== null && { InstanceProfileArn : input . InstanceProfileArn } ) , ... ( input . InstanceType !== undefined && input . InstanceType !== null && { InstanceType : input . InstanceType } ) , ... ( input . KeyPair !== undefined && input . KeyPair !== null && { KeyPair : input . KeyPair } ) , ... ( input . PreferredBackupWindow !== undefined && input . PreferredBackupWindow !== null && { PreferredBackupWindow : input . PreferredBackupWindow } ) , ... ( input . PreferredMaintenanceWindow !== undefined && input . PreferredMaintenanceWindow !== null && { PreferredMaintenanceWindow : input . PreferredMaintenanceWindow } ) , ... ( input . SecurityGroupIds !== undefined && input . SecurityGroupIds !== null && { SecurityGroupIds : serializeAws_json1_1Strings ( input . SecurityGroupIds , context ) , } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , ... ( input . ServiceRoleArn !== undefined && input . ServiceRoleArn !== null && { ServiceRoleArn : input . ServiceRoleArn } ) , ... ( input . SubnetIds !== undefined && input . SubnetIds !== null && { SubnetIds : serializeAws_json1_1Strings ( input . SubnetIds , context ) } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1DeleteBackupRequest = ( input , context ) : any => { return { ... ( input . BackupId !== undefined && input . BackupId !== null && { BackupId : input . BackupId } ) , } ; } ; const serializeAws_json1_1DeleteServerRequest = ( input , context ) : any => { return { ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1DescribeAccountAttributesRequest = ( input , context ) : any => { return { } ; } ; const serializeAws_json1_1DescribeBackupsRequest = ( input , context ) : any => { return { ... ( input . BackupId !== undefined && input . BackupId !== null && { BackupId : input . BackupId } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1DescribeEventsRequest = ( input , context ) : any => { return { ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1DescribeNodeAssociationStatusRequest = ( input , context ) : any => { return { ... ( input . NodeAssociationStatusToken !== undefined && input . NodeAssociationStatusToken !== null && { NodeAssociationStatusToken : input . NodeAssociationStatusToken } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1DescribeServersRequest = ( input , context ) : any => { return { ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1DisassociateNodeRequest = ( input , context ) : any => { return { ... ( input . EngineAttributes !== undefined && input . EngineAttributes !== null && { EngineAttributes : serializeAws_json1_1EngineAttributes ( input . EngineAttributes , context ) , } ) , ... ( input . NodeName !== undefined && input . NodeName !== null && { NodeName : input . NodeName } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1EngineAttribute = ( input , context ) : any => { return { ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Value !== undefined && input . Value !== null && { Value : input . Value } ) , } ; } ; const serializeAws_json1_1EngineAttributes = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1EngineAttribute ( entry , context ) ; } ) ; } ; const serializeAws_json1_1ExportServerEngineAttributeRequest = ( input , context ) : any => { return { ... ( input . ExportAttributeName !== undefined && input . ExportAttributeName !== null && { ExportAttributeName : input . ExportAttributeName } ) , ... ( input . InputAttributes !== undefined && input . InputAttributes !== null && { InputAttributes : serializeAws_json1_1EngineAttributes ( input . InputAttributes , context ) , } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1ListTagsForResourceRequest = ( input , context ) : any => { return { ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ResourceArn !== undefined && input . ResourceArn !== null && { ResourceArn : input . ResourceArn } ) , } ; } ; const serializeAws_json1_1RestoreServerRequest = ( input , context ) : any => { return { ... ( input . BackupId !== undefined && input . BackupId !== null && { BackupId : input . BackupId } ) , ... ( input . InstanceType !== undefined && input . InstanceType !== null && { InstanceType : input . InstanceType } ) , ... ( input . KeyPair !== undefined && input . KeyPair !== null && { KeyPair : input . KeyPair } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1StartMaintenanceRequest = ( input , context ) : any => { return { ... ( input . EngineAttributes !== undefined && input . EngineAttributes !== null && { EngineAttributes : serializeAws_json1_1EngineAttributes ( input . EngineAttributes , context ) , } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1Strings = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1Tag = ( input , context ) : any => { return { ... ( input . Key !== undefined && input . Key !== null && { Key : input . Key } ) , ... ( input . Value !== undefined && input . Value !== null && { Value : input . Value } ) , } ; } ; const serializeAws_json1_1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const serializeAws_json1_1TagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceArn !== undefined && input . ResourceArn !== null && { ResourceArn : input . ResourceArn } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1UntagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceArn !== undefined && input . ResourceArn !== null && { ResourceArn : input . ResourceArn } ) , ... ( input . TagKeys !== undefined && input . TagKeys !== null && { TagKeys : serializeAws_json1_1TagKeyList ( input . TagKeys , context ) } ) , } ; } ; const serializeAws_json1_1UpdateServerEngineAttributesRequest = ( input , context ) : any => { return { ... ( input . AttributeName !== undefined && input . AttributeName !== null && { AttributeName : input . AttributeName } ) , ... ( input . AttributeValue !== undefined && input . AttributeValue !== null && { AttributeValue : input . AttributeValue } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const serializeAws_json1_1UpdateServerRequest = ( input , context ) : any => { return { ... ( input . BackupRetentionCount !== undefined && input . BackupRetentionCount !== null && { BackupRetentionCount : input . BackupRetentionCount } ) , ... ( input . DisableAutomatedBackup !== undefined && input . DisableAutomatedBackup !== null && { DisableAutomatedBackup : input . DisableAutomatedBackup } ) , ... ( input . PreferredBackupWindow !== undefined && input . PreferredBackupWindow !== null && { PreferredBackupWindow : input . PreferredBackupWindow } ) , ... ( input . PreferredMaintenanceWindow !== undefined && input . PreferredMaintenanceWindow !== null && { PreferredMaintenanceWindow : input . PreferredMaintenanceWindow } ) , ... ( input . ServerName !== undefined && input . ServerName !== null && { ServerName : input . ServerName } ) , } ; } ; const deserializeAws_json1_1AccountAttribute = ( output , context ) : AccountAttribute => { return { Maximum : __expectInt32 ( output . Maximum ) , Name : __expectString ( output . Name ) , Used : __expectInt32 ( output . Used ) , } as any ; } ; const deserializeAws_json1_1AccountAttributes = ( output , context ) : AccountAttribute [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1AccountAttribute ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1AssociateNodeResponse = ( output , context ) : AssociateNodeResponse => { return { NodeAssociationStatusToken : __expectString ( output . NodeAssociationStatusToken ) , } as any ; } ; const deserializeAws_json1_1Backup = ( output , context ) : Backup => { return { BackupArn : __expectString ( output . BackupArn ) , BackupId : __expectString ( output . BackupId ) , BackupType : __expectString ( output . BackupType ) , CreatedAt : output . CreatedAt !== undefined && output . CreatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedAt ) ) ) : undefined , Description : __expectString ( output . Description ) , Engine : __expectString ( output . Engine ) , EngineModel : __expectString ( output . EngineModel ) , EngineVersion : __expectString ( output . EngineVersion ) , InstanceProfileArn : __expectString ( output . InstanceProfileArn ) , InstanceType : __expectString ( output . InstanceType ) , KeyPair : __expectString ( output . KeyPair ) , PreferredBackupWindow : __expectString ( output . PreferredBackupWindow ) , PreferredMaintenanceWindow : __expectString ( output . PreferredMaintenanceWindow ) , S3DataSize : __expectInt32 ( output . S3DataSize ) , S3DataUrl : __expectString ( output . S3DataUrl ) , S3LogUrl : __expectString ( output . S3LogUrl ) , SecurityGroupIds : output . SecurityGroupIds !== undefined && output . SecurityGroupIds !== null ? deserializeAws_json1_1Strings ( output . SecurityGroupIds , context ) : undefined , ServerName : __expectString ( output . ServerName ) , ServiceRoleArn : __expectString ( output . ServiceRoleArn ) , Status : __expectString ( output . Status ) , StatusDescription : __expectString ( output . StatusDescription ) , SubnetIds : output . SubnetIds !== undefined && output . SubnetIds !== null ? deserializeAws_json1_1Strings ( output . SubnetIds , context ) : undefined , ToolsVersion : __expectString ( output . ToolsVersion ) , UserArn : __expectString ( output . UserArn ) , } as any ; } ; const deserializeAws_json1_1Backups = ( output , context ) : Backup [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Backup ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1CreateBackupResponse = ( output , context ) : CreateBackupResponse => { return { Backup : output . Backup !== undefined && output . Backup !== null ? deserializeAws_json1_1Backup ( output . Backup , context ) : undefined , } as any ; } ; const deserializeAws_json1_1CreateServerResponse = ( output , context ) : CreateServerResponse => { return { Server : output . Server !== undefined && output . Server !== null ? deserializeAws_json1_1Server ( output . Server , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DeleteBackupResponse = ( output , context ) : DeleteBackupResponse => { return { } as any ; } ; const deserializeAws_json1_1DeleteServerResponse = ( output , context ) : DeleteServerResponse => { return { } as any ; } ; const deserializeAws_json1_1DescribeAccountAttributesResponse = ( output , context ) : DescribeAccountAttributesResponse => { return { Attributes : output . Attributes !== undefined && output . Attributes !== null ? deserializeAws_json1_1AccountAttributes ( output . Attributes , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DescribeBackupsResponse = ( output , context ) : DescribeBackupsResponse => { return { Backups : output . Backups !== undefined && output . Backups !== null ? deserializeAws_json1_1Backups ( output . Backups , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_1DescribeEventsResponse = ( output , context ) : DescribeEventsResponse => { return { NextToken : __expectString ( output . NextToken ) , ServerEvents : output . ServerEvents !== undefined && output . ServerEvents !== null ? deserializeAws_json1_1ServerEvents ( output . ServerEvents , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DescribeNodeAssociationStatusResponse = ( output , context ) : DescribeNodeAssociationStatusResponse => { return { EngineAttributes : output . EngineAttributes !== undefined && output . EngineAttributes !== null ? deserializeAws_json1_1EngineAttributes ( output . EngineAttributes , context ) : undefined , NodeAssociationStatus : __expectString ( output . NodeAssociationStatus ) , } as any ; } ; const deserializeAws_json1_1DescribeServersResponse = ( output , context ) : DescribeServersResponse => { return { NextToken : __expectString ( output . NextToken ) , Servers : output . Servers !== undefined && output . Servers !== null ? deserializeAws_json1_1Servers ( output . Servers , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DisassociateNodeResponse = ( output , context ) : DisassociateNodeResponse => { return { NodeAssociationStatusToken : __expectString ( output . NodeAssociationStatusToken ) , } as any ; } ; const deserializeAws_json1_1EngineAttribute = ( output , context ) : EngineAttribute => { return { Name : __expectString ( output . Name ) , Value : __expectString ( output . Value ) , } as any ; } ; const deserializeAws_json1_1EngineAttributes = ( output , context ) : EngineAttribute [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1EngineAttribute ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ExportServerEngineAttributeResponse = ( output , context ) : ExportServerEngineAttributeResponse => { return { EngineAttribute : output . EngineAttribute !== undefined && output . EngineAttribute !== null ? deserializeAws_json1_1EngineAttribute ( output . EngineAttribute , context ) : undefined , ServerName : __expectString ( output . ServerName ) , } as any ; } ; const deserializeAws_json1_1InvalidNextTokenException = ( output , context ) : InvalidNextTokenException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidStateException = ( output , context ) : InvalidStateException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1LimitExceededException = ( output , context ) : LimitExceededException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ListTagsForResourceResponse = ( output , context ) : ListTagsForResourceResponse => { return { NextToken : __expectString ( output . NextToken ) , Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_1TagList ( output . Tags , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ResourceAlreadyExistsException = ( output , context ) : ResourceAlreadyExistsException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1RestoreServerResponse = ( output , context ) : RestoreServerResponse => { return { Server : output . Server !== undefined && output . Server !== null ? deserializeAws_json1_1Server ( output . Server , context ) : undefined , } as any ; } ; const deserializeAws_json1_1Server = ( output , context ) : Server => { return { AssociatePublicIpAddress : __expectBoolean ( output . AssociatePublicIpAddress ) , BackupRetentionCount : __expectInt32 ( output . BackupRetentionCount ) , CloudFormationStackArn : __expectString ( output . CloudFormationStackArn ) , CreatedAt : output . CreatedAt !== undefined && output . CreatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedAt ) ) ) : undefined , CustomDomain : __expectString ( output . CustomDomain ) , DisableAutomatedBackup : __expectBoolean ( output . DisableAutomatedBackup ) , Endpoint : __expectString ( output . Endpoint ) , Engine : __expectString ( output . Engine ) , EngineAttributes : output . EngineAttributes !== undefined && output . EngineAttributes !== null ? deserializeAws_json1_1EngineAttributes ( output . EngineAttributes , context ) : undefined , EngineModel : __expectString ( output . EngineModel ) , EngineVersion : __expectString ( output . EngineVersion ) , InstanceProfileArn : __expectString ( output . InstanceProfileArn ) , InstanceType : __expectString ( output . InstanceType ) , KeyPair : __expectString ( output . KeyPair ) , MaintenanceStatus : __expectString ( output . MaintenanceStatus ) , PreferredBackupWindow : __expectString ( output . PreferredBackupWindow ) , PreferredMaintenanceWindow : __expectString ( output . PreferredMaintenanceWindow ) , SecurityGroupIds : output . SecurityGroupIds !== undefined && output . SecurityGroupIds !== null ? deserializeAws_json1_1Strings ( output . SecurityGroupIds , context ) : undefined , ServerArn : __expectString ( output . ServerArn ) , ServerName : __expectString ( output . ServerName ) , ServiceRoleArn : __expectString ( output . ServiceRoleArn ) , Status : __expectString ( output . Status ) , StatusReason : __expectString ( output . StatusReason ) , SubnetIds : output . SubnetIds !== undefined && output . SubnetIds !== null ? deserializeAws_json1_1Strings ( output . SubnetIds , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ServerEvent = ( output , context ) : ServerEvent => { return { CreatedAt : output . CreatedAt !== undefined && output . CreatedAt !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedAt ) ) ) : undefined , LogUrl : __expectString ( output . LogUrl ) , Message : __expectString ( output . Message ) , ServerName : __expectString ( output . ServerName ) , } as any ; } ; const deserializeAws_json1_1ServerEvents = ( output , context ) : ServerEvent [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ServerEvent ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1Servers = ( output , context ) : Server [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Server ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1StartMaintenanceResponse = ( output , context ) : StartMaintenanceResponse => { return { Server : output . Server !== undefined && output . Server !== null ? deserializeAws_json1_1Server ( output . Server , context ) : undefined , } as any ; } ; const deserializeAws_json1_1Strings = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1Tag = ( output , context ) : Tag => { return { Key : __expectString ( output . Key ) , Value : __expectString ( output . Value ) , } as any ; } ; const deserializeAws_json1_1TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1TagResourceResponse = ( output , context ) : TagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_1UntagResourceResponse = ( output , context ) : UntagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_1UpdateServerEngineAttributesResponse = ( output , context ) : UpdateServerEngineAttributesResponse => { return { Server : output . Server !== undefined && output . Server !== null ? deserializeAws_json1_1Server ( output . Server , context ) : undefined , } as any ; } ; const deserializeAws_json1_1UpdateServerResponse = ( output , context ) : UpdateServerResponse => { return { Server : output . Server !== undefined && output . Server !== null ? deserializeAws_json1_1Server ( output . Server , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ValidationException = ( output , context ) : ValidationException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;