import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectLong as __expectLong , 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 { v4 as generateIdempotencyToken } from "uuid" ; import { CancelRotateSecretCommandInput , CancelRotateSecretCommandOutput } from "../commands/CancelRotateSecretCommand" ; import { CreateSecretCommandInput , CreateSecretCommandOutput } from "../commands/CreateSecretCommand" ; import { DeleteResourcePolicyCommandInput , DeleteResourcePolicyCommandOutput , } from "../commands/DeleteResourcePolicyCommand" ; import { DeleteSecretCommandInput , DeleteSecretCommandOutput } from "../commands/DeleteSecretCommand" ; import { DescribeSecretCommandInput , DescribeSecretCommandOutput } from "../commands/DescribeSecretCommand" ; import { GetRandomPasswordCommandInput , GetRandomPasswordCommandOutput } from "../commands/GetRandomPasswordCommand" ; import { GetResourcePolicyCommandInput , GetResourcePolicyCommandOutput } from "../commands/GetResourcePolicyCommand" ; import { GetSecretValueCommandInput , GetSecretValueCommandOutput } from "../commands/GetSecretValueCommand" ; import { ListSecretsCommandInput , ListSecretsCommandOutput } from "../commands/ListSecretsCommand" ; import { ListSecretVersionIdsCommandInput , ListSecretVersionIdsCommandOutput , } from "../commands/ListSecretVersionIdsCommand" ; import { PutResourcePolicyCommandInput , PutResourcePolicyCommandOutput } from "../commands/PutResourcePolicyCommand" ; import { PutSecretValueCommandInput , PutSecretValueCommandOutput } from "../commands/PutSecretValueCommand" ; import { RemoveRegionsFromReplicationCommandInput , RemoveRegionsFromReplicationCommandOutput , } from "../commands/RemoveRegionsFromReplicationCommand" ; import { ReplicateSecretToRegionsCommandInput , ReplicateSecretToRegionsCommandOutput , } from "../commands/ReplicateSecretToRegionsCommand" ; import { RestoreSecretCommandInput , RestoreSecretCommandOutput } from "../commands/RestoreSecretCommand" ; import { RotateSecretCommandInput , RotateSecretCommandOutput } from "../commands/RotateSecretCommand" ; import { StopReplicationToReplicaCommandInput , StopReplicationToReplicaCommandOutput , } from "../commands/StopReplicationToReplicaCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateSecretCommandInput , UpdateSecretCommandOutput } from "../commands/UpdateSecretCommand" ; import { UpdateSecretVersionStageCommandInput , UpdateSecretVersionStageCommandOutput , } from "../commands/UpdateSecretVersionStageCommand" ; import { ValidateResourcePolicyCommandInput , ValidateResourcePolicyCommandOutput , } from "../commands/ValidateResourcePolicyCommand" ; import { CancelRotateSecretRequest , CancelRotateSecretResponse , CreateSecretRequest , CreateSecretResponse , DecryptionFailure , DeleteResourcePolicyRequest , DeleteResourcePolicyResponse , DeleteSecretRequest , DeleteSecretResponse , DescribeSecretRequest , DescribeSecretResponse , EncryptionFailure , Filter , GetRandomPasswordRequest , GetRandomPasswordResponse , GetResourcePolicyRequest , GetResourcePolicyResponse , GetSecretValueRequest , GetSecretValueResponse , InternalServiceError , InvalidNextTokenException , InvalidParameterException , InvalidRequestException , LimitExceededException , ListSecretsRequest , ListSecretsResponse , ListSecretVersionIdsRequest , ListSecretVersionIdsResponse , MalformedPolicyDocumentException , PreconditionNotMetException , PublicPolicyException , PutResourcePolicyRequest , PutResourcePolicyResponse , PutSecretValueRequest , PutSecretValueResponse , RemoveRegionsFromReplicationRequest , RemoveRegionsFromReplicationResponse , ReplicaRegionType , ReplicateSecretToRegionsRequest , ReplicateSecretToRegionsResponse , ReplicationStatusType , ResourceExistsException , ResourceNotFoundException , RestoreSecretRequest , RestoreSecretResponse , RotateSecretRequest , RotateSecretResponse , RotationRulesType , SecretListEntry , SecretVersionsListEntry , StopReplicationToReplicaRequest , StopReplicationToReplicaResponse , Tag , TagResourceRequest , UntagResourceRequest , UpdateSecretRequest , UpdateSecretResponse , UpdateSecretVersionStageRequest , UpdateSecretVersionStageResponse , ValidateResourcePolicyRequest , ValidateResourcePolicyResponse , ValidationErrorsEntry , } from "../models/models_0" ; export const serializeAws_json1_1CancelRotateSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.CancelRotateSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CancelRotateSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.CreateSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteResourcePolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.DeleteResourcePolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteResourcePolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.DeleteSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.DescribeSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetRandomPasswordCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.GetRandomPassword" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetRandomPasswordRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetResourcePolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.GetResourcePolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetResourcePolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetSecretValueCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.GetSecretValue" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetSecretValueRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListSecretsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.ListSecrets" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListSecretsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListSecretVersionIdsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.ListSecretVersionIds" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListSecretVersionIdsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1PutResourcePolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.PutResourcePolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1PutResourcePolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1PutSecretValueCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.PutSecretValue" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1PutSecretValueRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RemoveRegionsFromReplicationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.RemoveRegionsFromReplication" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RemoveRegionsFromReplicationRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ReplicateSecretToRegionsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.ReplicateSecretToRegions" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ReplicateSecretToRegionsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RestoreSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.RestoreSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RestoreSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RotateSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.RotateSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RotateSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1StopReplicationToReplicaCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.StopReplicationToReplica" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1StopReplicationToReplicaRequest ( 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" : "secretsmanager.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" : "secretsmanager.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateSecretCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.UpdateSecret" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateSecretRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateSecretVersionStageCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.UpdateSecretVersionStage" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateSecretVersionStageRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ValidateResourcePolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "secretsmanager.ValidateResourcePolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ValidateResourcePolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1CancelRotateSecretCommand = async ( output , context ) : Promise < CancelRotateSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CancelRotateSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CancelRotateSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CancelRotateSecretCommandError = async ( output , context ) : Promise < CancelRotateSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1CreateSecretCommand = async ( output , context ) : Promise < CreateSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateSecretCommandError = async ( output , context ) : Promise < CreateSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "EncryptionFailure" : case "com.amazonaws.secretsmanager#EncryptionFailure" : response = { ... ( await deserializeAws_json1_1EncryptionFailureResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.secretsmanager#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.secretsmanager#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PreconditionNotMetException" : case "com.amazonaws.secretsmanager#PreconditionNotMetException" : response = { ... ( await deserializeAws_json1_1PreconditionNotMetExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceExistsException" : case "com.amazonaws.secretsmanager#ResourceExistsException" : response = { ... ( await deserializeAws_json1_1ResourceExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1DeleteResourcePolicyCommand = async ( output , context ) : Promise < DeleteResourcePolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteResourcePolicyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteResourcePolicyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteResourcePolicyCommandError = async ( output , context ) : Promise < DeleteResourcePolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1DeleteSecretCommand = async ( output , context ) : Promise < DeleteSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteSecretCommandError = async ( output , context ) : Promise < DeleteSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1DescribeSecretCommand = async ( output , context ) : Promise < DescribeSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeSecretCommandError = async ( output , context ) : Promise < DescribeSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1GetRandomPasswordCommand = async ( output , context ) : Promise < GetRandomPasswordCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetRandomPasswordCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetRandomPasswordResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetRandomPasswordCommandError = async ( output , context ) : Promise < GetRandomPasswordCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( 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_1GetResourcePolicyCommand = async ( output , context ) : Promise < GetResourcePolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetResourcePolicyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetResourcePolicyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetResourcePolicyCommandError = async ( output , context ) : Promise < GetResourcePolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1GetSecretValueCommand = async ( output , context ) : Promise < GetSecretValueCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetSecretValueCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetSecretValueResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetSecretValueCommandError = async ( output , context ) : Promise < GetSecretValueCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DecryptionFailure" : case "com.amazonaws.secretsmanager#DecryptionFailure" : response = { ... ( await deserializeAws_json1_1DecryptionFailureResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1ListSecretsCommand = async ( output , context ) : Promise < ListSecretsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListSecretsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListSecretsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListSecretsCommandError = async ( output , context ) : Promise < ListSecretsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidNextTokenException" : case "com.amazonaws.secretsmanager#InvalidNextTokenException" : response = { ... ( await deserializeAws_json1_1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( 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_1ListSecretVersionIdsCommand = async ( output , context ) : Promise < ListSecretVersionIdsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListSecretVersionIdsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListSecretVersionIdsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListSecretVersionIdsCommandError = async ( output , context ) : Promise < ListSecretVersionIdsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidNextTokenException" : case "com.amazonaws.secretsmanager#InvalidNextTokenException" : response = { ... ( await deserializeAws_json1_1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1PutResourcePolicyCommand = async ( output , context ) : Promise < PutResourcePolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1PutResourcePolicyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1PutResourcePolicyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1PutResourcePolicyCommandError = async ( output , context ) : Promise < PutResourcePolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.secretsmanager#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PublicPolicyException" : case "com.amazonaws.secretsmanager#PublicPolicyException" : response = { ... ( await deserializeAws_json1_1PublicPolicyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1PutSecretValueCommand = async ( output , context ) : Promise < PutSecretValueCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1PutSecretValueCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1PutSecretValueResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1PutSecretValueCommandError = async ( output , context ) : Promise < PutSecretValueCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "EncryptionFailure" : case "com.amazonaws.secretsmanager#EncryptionFailure" : response = { ... ( await deserializeAws_json1_1EncryptionFailureResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.secretsmanager#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceExistsException" : case "com.amazonaws.secretsmanager#ResourceExistsException" : response = { ... ( await deserializeAws_json1_1ResourceExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1RemoveRegionsFromReplicationCommand = async ( output , context ) : Promise < RemoveRegionsFromReplicationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RemoveRegionsFromReplicationCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1RemoveRegionsFromReplicationResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RemoveRegionsFromReplicationCommandError = async ( output , context ) : Promise < RemoveRegionsFromReplicationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1ReplicateSecretToRegionsCommand = async ( output , context ) : Promise < ReplicateSecretToRegionsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ReplicateSecretToRegionsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ReplicateSecretToRegionsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ReplicateSecretToRegionsCommandError = async ( output , context ) : Promise < ReplicateSecretToRegionsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1RestoreSecretCommand = async ( output , context ) : Promise < RestoreSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RestoreSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1RestoreSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RestoreSecretCommandError = async ( output , context ) : Promise < RestoreSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1RotateSecretCommand = async ( output , context ) : Promise < RotateSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RotateSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1RotateSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RotateSecretCommandError = async ( output , context ) : Promise < RotateSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1StopReplicationToReplicaCommand = async ( output , context ) : Promise < StopReplicationToReplicaCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1StopReplicationToReplicaCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1StopReplicationToReplicaResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1StopReplicationToReplicaCommandError = async ( output , context ) : Promise < StopReplicationToReplicaCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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 ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; 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 "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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 ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; 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 "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1UpdateSecretCommand = async ( output , context ) : Promise < UpdateSecretCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateSecretCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateSecretResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateSecretCommandError = async ( output , context ) : Promise < UpdateSecretCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "EncryptionFailure" : case "com.amazonaws.secretsmanager#EncryptionFailure" : response = { ... ( await deserializeAws_json1_1EncryptionFailureResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.secretsmanager#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.secretsmanager#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PreconditionNotMetException" : case "com.amazonaws.secretsmanager#PreconditionNotMetException" : response = { ... ( await deserializeAws_json1_1PreconditionNotMetExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceExistsException" : case "com.amazonaws.secretsmanager#ResourceExistsException" : response = { ... ( await deserializeAws_json1_1ResourceExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1UpdateSecretVersionStageCommand = async ( output , context ) : Promise < UpdateSecretVersionStageCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateSecretVersionStageCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateSecretVersionStageResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateSecretVersionStageCommandError = async ( output , context ) : Promise < UpdateSecretVersionStageCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.secretsmanager#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1ValidateResourcePolicyCommand = async ( output , context ) : Promise < ValidateResourcePolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ValidateResourcePolicyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ValidateResourcePolicyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ValidateResourcePolicyCommandError = async ( output , context ) : Promise < ValidateResourcePolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InternalServiceError" : case "com.amazonaws.secretsmanager#InternalServiceError" : response = { ... ( await deserializeAws_json1_1InternalServiceErrorResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.secretsmanager#InvalidParameterException" : response = { ... ( await deserializeAws_json1_1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidRequestException" : case "com.amazonaws.secretsmanager#InvalidRequestException" : response = { ... ( await deserializeAws_json1_1InvalidRequestExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.secretsmanager#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.secretsmanager#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( 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_1DecryptionFailureResponse = async ( parsedOutput , context ) : Promise < DecryptionFailure > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1DecryptionFailure ( body , context ) ; const contents = { name : "DecryptionFailure" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1EncryptionFailureResponse = async ( parsedOutput , context ) : Promise < EncryptionFailure > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1EncryptionFailure ( body , context ) ; const contents = { name : "EncryptionFailure" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InternalServiceErrorResponse = async ( parsedOutput , context ) : Promise < InternalServiceError > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InternalServiceError ( body , context ) ; const contents = { name : "InternalServiceError" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; 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_1InvalidParameterExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidParameterException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidParameterException ( body , context ) ; const contents = { name : "InvalidParameterException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidRequestExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidRequestException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidRequestException ( body , context ) ; const contents = { name : "InvalidRequestException" , $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_1MalformedPolicyDocumentExceptionResponse = async ( parsedOutput , context ) : Promise < MalformedPolicyDocumentException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1MalformedPolicyDocumentException ( body , context ) ; const contents = { name : "MalformedPolicyDocumentException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1PreconditionNotMetExceptionResponse = async ( parsedOutput , context ) : Promise < PreconditionNotMetException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1PreconditionNotMetException ( body , context ) ; const contents = { name : "PreconditionNotMetException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1PublicPolicyExceptionResponse = async ( parsedOutput , context ) : Promise < PublicPolicyException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1PublicPolicyException ( body , context ) ; const contents = { name : "PublicPolicyException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceExistsExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceExistsException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceExistsException ( body , context ) ; const contents = { name : "ResourceExistsException" , $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 serializeAws_json1_1AddReplicaRegionListType = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1ReplicaRegionType ( entry , context ) ; } ) ; } ; const serializeAws_json1_1CancelRotateSecretRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1CreateSecretRequest = ( input , context ) : any => { return { ... ( input . AddReplicaRegions !== undefined && input . AddReplicaRegions !== null && { AddReplicaRegions : serializeAws_json1_1AddReplicaRegionListType ( input . AddReplicaRegions , context ) , } ) , ClientRequestToken : input . ClientRequestToken ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . ForceOverwriteReplicaSecret !== undefined && input . ForceOverwriteReplicaSecret !== null && { ForceOverwriteReplicaSecret : input . ForceOverwriteReplicaSecret } ) , ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . SecretBinary !== undefined && input . SecretBinary !== null && { SecretBinary : context . base64Encoder ( input . SecretBinary ) } ) , ... ( input . SecretString !== undefined && input . SecretString !== null && { SecretString : input . SecretString } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagListType ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1DeleteResourcePolicyRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1DeleteSecretRequest = ( input , context ) : any => { return { ... ( input . ForceDeleteWithoutRecovery !== undefined && input . ForceDeleteWithoutRecovery !== null && { ForceDeleteWithoutRecovery : input . ForceDeleteWithoutRecovery } ) , ... ( input . RecoveryWindowInDays !== undefined && input . RecoveryWindowInDays !== null && { RecoveryWindowInDays : input . RecoveryWindowInDays } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1DescribeSecretRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1Filter = ( input , context ) : any => { return { ... ( input . Key !== undefined && input . Key !== null && { Key : input . Key } ) , ... ( input . Values !== undefined && input . Values !== null && { Values : serializeAws_json1_1FilterValuesStringList ( input . Values , context ) } ) , } ; } ; const serializeAws_json1_1FiltersListType = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Filter ( entry , context ) ; } ) ; } ; const serializeAws_json1_1FilterValuesStringList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1GetRandomPasswordRequest = ( input , context ) : any => { return { ... ( input . ExcludeCharacters !== undefined && input . ExcludeCharacters !== null && { ExcludeCharacters : input . ExcludeCharacters } ) , ... ( input . ExcludeLowercase !== undefined && input . ExcludeLowercase !== null && { ExcludeLowercase : input . ExcludeLowercase } ) , ... ( input . ExcludeNumbers !== undefined && input . ExcludeNumbers !== null && { ExcludeNumbers : input . ExcludeNumbers } ) , ... ( input . ExcludePunctuation !== undefined && input . ExcludePunctuation !== null && { ExcludePunctuation : input . ExcludePunctuation } ) , ... ( input . ExcludeUppercase !== undefined && input . ExcludeUppercase !== null && { ExcludeUppercase : input . ExcludeUppercase } ) , ... ( input . IncludeSpace !== undefined && input . IncludeSpace !== null && { IncludeSpace : input . IncludeSpace } ) , ... ( input . PasswordLength !== undefined && input . PasswordLength !== null && { PasswordLength : input . PasswordLength } ) , ... ( input . RequireEachIncludedType !== undefined && input . RequireEachIncludedType !== null && { RequireEachIncludedType : input . RequireEachIncludedType } ) , } ; } ; const serializeAws_json1_1GetResourcePolicyRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1GetSecretValueRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . VersionId !== undefined && input . VersionId !== null && { VersionId : input . VersionId } ) , ... ( input . VersionStage !== undefined && input . VersionStage !== null && { VersionStage : input . VersionStage } ) , } ; } ; const serializeAws_json1_1ListSecretsRequest = ( input , context ) : any => { return { ... ( input . Filters !== undefined && input . Filters !== null && { Filters : serializeAws_json1_1FiltersListType ( input . Filters , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . SortOrder !== undefined && input . SortOrder !== null && { SortOrder : input . SortOrder } ) , } ; } ; const serializeAws_json1_1ListSecretVersionIdsRequest = ( input , context ) : any => { return { ... ( input . IncludeDeprecated !== undefined && input . IncludeDeprecated !== null && { IncludeDeprecated : input . IncludeDeprecated } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1PutResourcePolicyRequest = ( input , context ) : any => { return { ... ( input . BlockPublicPolicy !== undefined && input . BlockPublicPolicy !== null && { BlockPublicPolicy : input . BlockPublicPolicy } ) , ... ( input . ResourcePolicy !== undefined && input . ResourcePolicy !== null && { ResourcePolicy : input . ResourcePolicy } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1PutSecretValueRequest = ( input , context ) : any => { return { ClientRequestToken : input . ClientRequestToken ?? generateIdempotencyToken ( ) , ... ( input . SecretBinary !== undefined && input . SecretBinary !== null && { SecretBinary : context . base64Encoder ( input . SecretBinary ) } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . SecretString !== undefined && input . SecretString !== null && { SecretString : input . SecretString } ) , ... ( input . VersionStages !== undefined && input . VersionStages !== null && { VersionStages : serializeAws_json1_1SecretVersionStagesType ( input . VersionStages , context ) , } ) , } ; } ; const serializeAws_json1_1RemoveRegionsFromReplicationRequest = ( input , context ) : any => { return { ... ( input . RemoveReplicaRegions !== undefined && input . RemoveReplicaRegions !== null && { RemoveReplicaRegions : serializeAws_json1_1RemoveReplicaRegionListType ( input . RemoveReplicaRegions , context ) , } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1RemoveReplicaRegionListType = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1ReplicaRegionType = ( input , context ) : any => { return { ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , ... ( input . Region !== undefined && input . Region !== null && { Region : input . Region } ) , } ; } ; const serializeAws_json1_1ReplicateSecretToRegionsRequest = ( input , context ) : any => { return { ... ( input . AddReplicaRegions !== undefined && input . AddReplicaRegions !== null && { AddReplicaRegions : serializeAws_json1_1AddReplicaRegionListType ( input . AddReplicaRegions , context ) , } ) , ... ( input . ForceOverwriteReplicaSecret !== undefined && input . ForceOverwriteReplicaSecret !== null && { ForceOverwriteReplicaSecret : input . ForceOverwriteReplicaSecret } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1RestoreSecretRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1RotateSecretRequest = ( input , context ) : any => { return { ClientRequestToken : input . ClientRequestToken ?? generateIdempotencyToken ( ) , ... ( input . RotationLambdaARN !== undefined && input . RotationLambdaARN !== null && { RotationLambdaARN : input . RotationLambdaARN } ) , ... ( input . RotationRules !== undefined && input . RotationRules !== null && { RotationRules : serializeAws_json1_1RotationRulesType ( input . RotationRules , context ) , } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const serializeAws_json1_1RotationRulesType = ( input , context ) : any => { return { ... ( input . AutomaticallyAfterDays !== undefined && input . AutomaticallyAfterDays !== null && { AutomaticallyAfterDays : input . AutomaticallyAfterDays } ) , } ; } ; const serializeAws_json1_1SecretVersionStagesType = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1StopReplicationToReplicaRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; 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_1TagKeyListType = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1TagListType = ( 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 . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagListType ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1UntagResourceRequest = ( input , context ) : any => { return { ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . TagKeys !== undefined && input . TagKeys !== null && { TagKeys : serializeAws_json1_1TagKeyListType ( input . TagKeys , context ) } ) , } ; } ; const serializeAws_json1_1UpdateSecretRequest = ( input , context ) : any => { return { ClientRequestToken : input . ClientRequestToken ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . KmsKeyId !== undefined && input . KmsKeyId !== null && { KmsKeyId : input . KmsKeyId } ) , ... ( input . SecretBinary !== undefined && input . SecretBinary !== null && { SecretBinary : context . base64Encoder ( input . SecretBinary ) } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . SecretString !== undefined && input . SecretString !== null && { SecretString : input . SecretString } ) , } ; } ; const serializeAws_json1_1UpdateSecretVersionStageRequest = ( input , context ) : any => { return { ... ( input . MoveToVersionId !== undefined && input . MoveToVersionId !== null && { MoveToVersionId : input . MoveToVersionId } ) , ... ( input . RemoveFromVersionId !== undefined && input . RemoveFromVersionId !== null && { RemoveFromVersionId : input . RemoveFromVersionId } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , ... ( input . VersionStage !== undefined && input . VersionStage !== null && { VersionStage : input . VersionStage } ) , } ; } ; const serializeAws_json1_1ValidateResourcePolicyRequest = ( input , context ) : any => { return { ... ( input . ResourcePolicy !== undefined && input . ResourcePolicy !== null && { ResourcePolicy : input . ResourcePolicy } ) , ... ( input . SecretId !== undefined && input . SecretId !== null && { SecretId : input . SecretId } ) , } ; } ; const deserializeAws_json1_1CancelRotateSecretResponse = ( output , context ) : CancelRotateSecretResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , VersionId : __expectString ( output . VersionId ) , } as any ; } ; const deserializeAws_json1_1CreateSecretResponse = ( output , context ) : CreateSecretResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , ReplicationStatus : output . ReplicationStatus !== undefined && output . ReplicationStatus !== null ? deserializeAws_json1_1ReplicationStatusListType ( output . ReplicationStatus , context ) : undefined , VersionId : __expectString ( output . VersionId ) , } as any ; } ; const deserializeAws_json1_1DecryptionFailure = ( output , context ) : DecryptionFailure => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1DeleteResourcePolicyResponse = ( output , context ) : DeleteResourcePolicyResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , } as any ; } ; const deserializeAws_json1_1DeleteSecretResponse = ( output , context ) : DeleteSecretResponse => { return { ARN : __expectString ( output . ARN ) , DeletionDate : output . DeletionDate !== undefined && output . DeletionDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . DeletionDate ) ) ) : undefined , Name : __expectString ( output . Name ) , } as any ; } ; const deserializeAws_json1_1DescribeSecretResponse = ( output , context ) : DescribeSecretResponse => { return { ARN : __expectString ( output . ARN ) , CreatedDate : output . CreatedDate !== undefined && output . CreatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedDate ) ) ) : undefined , DeletedDate : output . DeletedDate !== undefined && output . DeletedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . DeletedDate ) ) ) : undefined , Description : __expectString ( output . Description ) , KmsKeyId : __expectString ( output . KmsKeyId ) , LastAccessedDate : output . LastAccessedDate !== undefined && output . LastAccessedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastAccessedDate ) ) ) : undefined , LastChangedDate : output . LastChangedDate !== undefined && output . LastChangedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastChangedDate ) ) ) : undefined , LastRotatedDate : output . LastRotatedDate !== undefined && output . LastRotatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastRotatedDate ) ) ) : undefined , Name : __expectString ( output . Name ) , OwningService : __expectString ( output . OwningService ) , PrimaryRegion : __expectString ( output . PrimaryRegion ) , ReplicationStatus : output . ReplicationStatus !== undefined && output . ReplicationStatus !== null ? deserializeAws_json1_1ReplicationStatusListType ( output . ReplicationStatus , context ) : undefined , RotationEnabled : __expectBoolean ( output . RotationEnabled ) , RotationLambdaARN : __expectString ( output . RotationLambdaARN ) , RotationRules : output . RotationRules !== undefined && output . RotationRules !== null ? deserializeAws_json1_1RotationRulesType ( output . RotationRules , context ) : undefined , Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_1TagListType ( output . Tags , context ) : undefined , VersionIdsToStages : output . VersionIdsToStages !== undefined && output . VersionIdsToStages !== null ? deserializeAws_json1_1SecretVersionsToStagesMapType ( output . VersionIdsToStages , context ) : undefined , } as any ; } ; const deserializeAws_json1_1EncryptionFailure = ( output , context ) : EncryptionFailure => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1GetRandomPasswordResponse = ( output , context ) : GetRandomPasswordResponse => { return { RandomPassword : __expectString ( output . RandomPassword ) , } as any ; } ; const deserializeAws_json1_1GetResourcePolicyResponse = ( output , context ) : GetResourcePolicyResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , ResourcePolicy : __expectString ( output . ResourcePolicy ) , } as any ; } ; const deserializeAws_json1_1GetSecretValueResponse = ( output , context ) : GetSecretValueResponse => { return { ARN : __expectString ( output . ARN ) , CreatedDate : output . CreatedDate !== undefined && output . CreatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedDate ) ) ) : undefined , Name : __expectString ( output . Name ) , SecretBinary : output . SecretBinary !== undefined && output . SecretBinary !== null ? context . base64Decoder ( output . SecretBinary ) : undefined , SecretString : __expectString ( output . SecretString ) , VersionId : __expectString ( output . VersionId ) , VersionStages : output . VersionStages !== undefined && output . VersionStages !== null ? deserializeAws_json1_1SecretVersionStagesType ( output . VersionStages , context ) : undefined , } as any ; } ; const deserializeAws_json1_1InternalServiceError = ( output , context ) : InternalServiceError => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidNextTokenException = ( output , context ) : InvalidNextTokenException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidParameterException = ( output , context ) : InvalidParameterException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InvalidRequestException = ( output , context ) : InvalidRequestException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1KmsKeyIdListType = ( 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_1LimitExceededException = ( output , context ) : LimitExceededException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ListSecretsResponse = ( output , context ) : ListSecretsResponse => { return { NextToken : __expectString ( output . NextToken ) , SecretList : output . SecretList !== undefined && output . SecretList !== null ? deserializeAws_json1_1SecretListType ( output . SecretList , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ListSecretVersionIdsResponse = ( output , context ) : ListSecretVersionIdsResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , NextToken : __expectString ( output . NextToken ) , Versions : output . Versions !== undefined && output . Versions !== null ? deserializeAws_json1_1SecretVersionsListType ( output . Versions , context ) : undefined , } as any ; } ; const deserializeAws_json1_1MalformedPolicyDocumentException = ( output , context ) : MalformedPolicyDocumentException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1PreconditionNotMetException = ( output , context ) : PreconditionNotMetException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1PublicPolicyException = ( output , context ) : PublicPolicyException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1PutResourcePolicyResponse = ( output , context ) : PutResourcePolicyResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , } as any ; } ; const deserializeAws_json1_1PutSecretValueResponse = ( output , context ) : PutSecretValueResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , VersionId : __expectString ( output . VersionId ) , VersionStages : output . VersionStages !== undefined && output . VersionStages !== null ? deserializeAws_json1_1SecretVersionStagesType ( output . VersionStages , context ) : undefined , } as any ; } ; const deserializeAws_json1_1RemoveRegionsFromReplicationResponse = ( output , context ) : RemoveRegionsFromReplicationResponse => { return { ARN : __expectString ( output . ARN ) , ReplicationStatus : output . ReplicationStatus !== undefined && output . ReplicationStatus !== null ? deserializeAws_json1_1ReplicationStatusListType ( output . ReplicationStatus , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ReplicateSecretToRegionsResponse = ( output , context ) : ReplicateSecretToRegionsResponse => { return { ARN : __expectString ( output . ARN ) , ReplicationStatus : output . ReplicationStatus !== undefined && output . ReplicationStatus !== null ? deserializeAws_json1_1ReplicationStatusListType ( output . ReplicationStatus , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ReplicationStatusListType = ( output , context ) : ReplicationStatusType [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ReplicationStatusType ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ReplicationStatusType = ( output , context ) : ReplicationStatusType => { return { KmsKeyId : __expectString ( output . KmsKeyId ) , LastAccessedDate : output . LastAccessedDate !== undefined && output . LastAccessedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastAccessedDate ) ) ) : undefined , Region : __expectString ( output . Region ) , Status : __expectString ( output . Status ) , StatusMessage : __expectString ( output . StatusMessage ) , } as any ; } ; const deserializeAws_json1_1ResourceExistsException = ( output , context ) : ResourceExistsException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1RestoreSecretResponse = ( output , context ) : RestoreSecretResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , } as any ; } ; const deserializeAws_json1_1RotateSecretResponse = ( output , context ) : RotateSecretResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , VersionId : __expectString ( output . VersionId ) , } as any ; } ; const deserializeAws_json1_1RotationRulesType = ( output , context ) : RotationRulesType => { return { AutomaticallyAfterDays : __expectLong ( output . AutomaticallyAfterDays ) , } as any ; } ; const deserializeAws_json1_1SecretListEntry = ( output , context ) : SecretListEntry => { return { ARN : __expectString ( output . ARN ) , CreatedDate : output . CreatedDate !== undefined && output . CreatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedDate ) ) ) : undefined , DeletedDate : output . DeletedDate !== undefined && output . DeletedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . DeletedDate ) ) ) : undefined , Description : __expectString ( output . Description ) , KmsKeyId : __expectString ( output . KmsKeyId ) , LastAccessedDate : output . LastAccessedDate !== undefined && output . LastAccessedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastAccessedDate ) ) ) : undefined , LastChangedDate : output . LastChangedDate !== undefined && output . LastChangedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastChangedDate ) ) ) : undefined , LastRotatedDate : output . LastRotatedDate !== undefined && output . LastRotatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastRotatedDate ) ) ) : undefined , Name : __expectString ( output . Name ) , OwningService : __expectString ( output . OwningService ) , PrimaryRegion : __expectString ( output . PrimaryRegion ) , RotationEnabled : __expectBoolean ( output . RotationEnabled ) , RotationLambdaARN : __expectString ( output . RotationLambdaARN ) , RotationRules : output . RotationRules !== undefined && output . RotationRules !== null ? deserializeAws_json1_1RotationRulesType ( output . RotationRules , context ) : undefined , SecretVersionsToStages : output . SecretVersionsToStages !== undefined && output . SecretVersionsToStages !== null ? deserializeAws_json1_1SecretVersionsToStagesMapType ( output . SecretVersionsToStages , context ) : undefined , Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_1TagListType ( output . Tags , context ) : undefined , } as any ; } ; const deserializeAws_json1_1SecretListType = ( output , context ) : SecretListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1SecretListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1SecretVersionsListEntry = ( output , context ) : SecretVersionsListEntry => { return { CreatedDate : output . CreatedDate !== undefined && output . CreatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreatedDate ) ) ) : undefined , KmsKeyIds : output . KmsKeyIds !== undefined && output . KmsKeyIds !== null ? deserializeAws_json1_1KmsKeyIdListType ( output . KmsKeyIds , context ) : undefined , LastAccessedDate : output . LastAccessedDate !== undefined && output . LastAccessedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastAccessedDate ) ) ) : undefined , VersionId : __expectString ( output . VersionId ) , VersionStages : output . VersionStages !== undefined && output . VersionStages !== null ? deserializeAws_json1_1SecretVersionStagesType ( output . VersionStages , context ) : undefined , } as any ; } ; const deserializeAws_json1_1SecretVersionsListType = ( output , context ) : SecretVersionsListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1SecretVersionsListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1SecretVersionStagesType = ( 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_1SecretVersionsToStagesMapType = ( output , context ) : { [ key ] : string [ ] ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : deserializeAws_json1_1SecretVersionStagesType ( value , context ) , } ; } , { } ) ; } ; const deserializeAws_json1_1StopReplicationToReplicaResponse = ( output , context ) : StopReplicationToReplicaResponse => { return { ARN : __expectString ( output . ARN ) , } as any ; } ; const deserializeAws_json1_1Tag = ( output , context ) : Tag => { return { Key : __expectString ( output . Key ) , Value : __expectString ( output . Value ) , } as any ; } ; const deserializeAws_json1_1TagListType = ( 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_1UpdateSecretResponse = ( output , context ) : UpdateSecretResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , VersionId : __expectString ( output . VersionId ) , } as any ; } ; const deserializeAws_json1_1UpdateSecretVersionStageResponse = ( output , context ) : UpdateSecretVersionStageResponse => { return { ARN : __expectString ( output . ARN ) , Name : __expectString ( output . Name ) , } as any ; } ; const deserializeAws_json1_1ValidateResourcePolicyResponse = ( output , context ) : ValidateResourcePolicyResponse => { return { PolicyValidationPassed : __expectBoolean ( output . PolicyValidationPassed ) , ValidationErrors : output . ValidationErrors !== undefined && output . ValidationErrors !== null ? deserializeAws_json1_1ValidationErrorsType ( output . ValidationErrors , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ValidationErrorsEntry = ( output , context ) : ValidationErrorsEntry => { return { CheckName : __expectString ( output . CheckName ) , ErrorMessage : __expectString ( output . ErrorMessage ) , } as any ; } ; const deserializeAws_json1_1ValidationErrorsType = ( output , context ) : ValidationErrorsEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ValidationErrorsEntry ( entry , context ) ; } ) ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const 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 "" ; } ;