import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { CancelKeyDeletionCommandInput , CancelKeyDeletionCommandOutput } from "../commands/CancelKeyDeletionCommand" ; import { ConnectCustomKeyStoreCommandInput , ConnectCustomKeyStoreCommandOutput , } from "../commands/ConnectCustomKeyStoreCommand" ; import { CreateAliasCommandInput , CreateAliasCommandOutput } from "../commands/CreateAliasCommand" ; import { CreateCustomKeyStoreCommandInput , CreateCustomKeyStoreCommandOutput , } from "../commands/CreateCustomKeyStoreCommand" ; import { CreateGrantCommandInput , CreateGrantCommandOutput } from "../commands/CreateGrantCommand" ; import { CreateKeyCommandInput , CreateKeyCommandOutput } from "../commands/CreateKeyCommand" ; import { DecryptCommandInput , DecryptCommandOutput } from "../commands/DecryptCommand" ; import { DeleteAliasCommandInput , DeleteAliasCommandOutput } from "../commands/DeleteAliasCommand" ; import { DeleteCustomKeyStoreCommandInput , DeleteCustomKeyStoreCommandOutput , } from "../commands/DeleteCustomKeyStoreCommand" ; import { DeleteImportedKeyMaterialCommandInput , DeleteImportedKeyMaterialCommandOutput , } from "../commands/DeleteImportedKeyMaterialCommand" ; import { DescribeCustomKeyStoresCommandInput , DescribeCustomKeyStoresCommandOutput , } from "../commands/DescribeCustomKeyStoresCommand" ; import { DescribeKeyCommandInput , DescribeKeyCommandOutput } from "../commands/DescribeKeyCommand" ; import { DisableKeyCommandInput , DisableKeyCommandOutput } from "../commands/DisableKeyCommand" ; import { DisableKeyRotationCommandInput , DisableKeyRotationCommandOutput } from "../commands/DisableKeyRotationCommand" ; import { DisconnectCustomKeyStoreCommandInput , DisconnectCustomKeyStoreCommandOutput , } from "../commands/DisconnectCustomKeyStoreCommand" ; import { EnableKeyCommandInput , EnableKeyCommandOutput } from "../commands/EnableKeyCommand" ; import { EnableKeyRotationCommandInput , EnableKeyRotationCommandOutput } from "../commands/EnableKeyRotationCommand" ; import { EncryptCommandInput , EncryptCommandOutput } from "../commands/EncryptCommand" ; import { GenerateDataKeyCommandInput , GenerateDataKeyCommandOutput } from "../commands/GenerateDataKeyCommand" ; import { GenerateDataKeyPairCommandInput , GenerateDataKeyPairCommandOutput , } from "../commands/GenerateDataKeyPairCommand" ; import { GenerateDataKeyPairWithoutPlaintextCommandInput , GenerateDataKeyPairWithoutPlaintextCommandOutput , } from "../commands/GenerateDataKeyPairWithoutPlaintextCommand" ; import { GenerateDataKeyWithoutPlaintextCommandInput , GenerateDataKeyWithoutPlaintextCommandOutput , } from "../commands/GenerateDataKeyWithoutPlaintextCommand" ; import { GenerateRandomCommandInput , GenerateRandomCommandOutput } from "../commands/GenerateRandomCommand" ; import { GetKeyPolicyCommandInput , GetKeyPolicyCommandOutput } from "../commands/GetKeyPolicyCommand" ; import { GetKeyRotationStatusCommandInput , GetKeyRotationStatusCommandOutput , } from "../commands/GetKeyRotationStatusCommand" ; import { GetParametersForImportCommandInput , GetParametersForImportCommandOutput , } from "../commands/GetParametersForImportCommand" ; import { GetPublicKeyCommandInput , GetPublicKeyCommandOutput } from "../commands/GetPublicKeyCommand" ; import { ImportKeyMaterialCommandInput , ImportKeyMaterialCommandOutput } from "../commands/ImportKeyMaterialCommand" ; import { ListAliasesCommandInput , ListAliasesCommandOutput } from "../commands/ListAliasesCommand" ; import { ListGrantsCommandInput , ListGrantsCommandOutput } from "../commands/ListGrantsCommand" ; import { ListKeyPoliciesCommandInput , ListKeyPoliciesCommandOutput } from "../commands/ListKeyPoliciesCommand" ; import { ListKeysCommandInput , ListKeysCommandOutput } from "../commands/ListKeysCommand" ; import { ListResourceTagsCommandInput , ListResourceTagsCommandOutput } from "../commands/ListResourceTagsCommand" ; import { ListRetirableGrantsCommandInput , ListRetirableGrantsCommandOutput , } from "../commands/ListRetirableGrantsCommand" ; import { PutKeyPolicyCommandInput , PutKeyPolicyCommandOutput } from "../commands/PutKeyPolicyCommand" ; import { ReEncryptCommandInput , ReEncryptCommandOutput } from "../commands/ReEncryptCommand" ; import { ReplicateKeyCommandInput , ReplicateKeyCommandOutput } from "../commands/ReplicateKeyCommand" ; import { RetireGrantCommandInput , RetireGrantCommandOutput } from "../commands/RetireGrantCommand" ; import { RevokeGrantCommandInput , RevokeGrantCommandOutput } from "../commands/RevokeGrantCommand" ; import { ScheduleKeyDeletionCommandInput , ScheduleKeyDeletionCommandOutput , } from "../commands/ScheduleKeyDeletionCommand" ; import { SignCommandInput , SignCommandOutput } from "../commands/SignCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateAliasCommandInput , UpdateAliasCommandOutput } from "../commands/UpdateAliasCommand" ; import { UpdateCustomKeyStoreCommandInput , UpdateCustomKeyStoreCommandOutput , } from "../commands/UpdateCustomKeyStoreCommand" ; import { UpdateKeyDescriptionCommandInput , UpdateKeyDescriptionCommandOutput , } from "../commands/UpdateKeyDescriptionCommand" ; import { UpdatePrimaryRegionCommandInput , UpdatePrimaryRegionCommandOutput , } from "../commands/UpdatePrimaryRegionCommand" ; import { VerifyCommandInput , VerifyCommandOutput } from "../commands/VerifyCommand" ; import { AliasListEntry , AlreadyExistsException , CancelKeyDeletionRequest , CancelKeyDeletionResponse , CloudHsmClusterInUseException , CloudHsmClusterInvalidConfigurationException , CloudHsmClusterNotActiveException , CloudHsmClusterNotFoundException , CloudHsmClusterNotRelatedException , ConnectCustomKeyStoreRequest , ConnectCustomKeyStoreResponse , CreateAliasRequest , CreateCustomKeyStoreRequest , CreateCustomKeyStoreResponse , CreateGrantRequest , CreateGrantResponse , CreateKeyRequest , CreateKeyResponse , CustomKeyStoreHasCMKsException , CustomKeyStoreInvalidStateException , CustomKeyStoreNameInUseException , CustomKeyStoreNotFoundException , CustomKeyStoresListEntry , DecryptRequest , DecryptResponse , DeleteAliasRequest , DeleteCustomKeyStoreRequest , DeleteCustomKeyStoreResponse , DeleteImportedKeyMaterialRequest , DependencyTimeoutException , DescribeCustomKeyStoresRequest , DescribeCustomKeyStoresResponse , DescribeKeyRequest , DescribeKeyResponse , DisabledException , DisableKeyRequest , DisableKeyRotationRequest , DisconnectCustomKeyStoreRequest , DisconnectCustomKeyStoreResponse , EnableKeyRequest , EnableKeyRotationRequest , EncryptionAlgorithmSpec , EncryptRequest , EncryptResponse , ExpiredImportTokenException , GenerateDataKeyPairRequest , GenerateDataKeyPairResponse , GenerateDataKeyPairWithoutPlaintextRequest , GenerateDataKeyPairWithoutPlaintextResponse , GenerateDataKeyRequest , GenerateDataKeyResponse , GenerateDataKeyWithoutPlaintextRequest , GenerateDataKeyWithoutPlaintextResponse , GenerateRandomRequest , GenerateRandomResponse , GetKeyPolicyRequest , GetKeyPolicyResponse , GetKeyRotationStatusRequest , GetKeyRotationStatusResponse , GetParametersForImportRequest , GetParametersForImportResponse , GetPublicKeyRequest , GetPublicKeyResponse , GrantConstraints , GrantListEntry , GrantOperation , ImportKeyMaterialRequest , ImportKeyMaterialResponse , IncorrectKeyException , IncorrectKeyMaterialException , IncorrectTrustAnchorException , InvalidAliasNameException , InvalidArnException , InvalidCiphertextException , InvalidGrantIdException , InvalidGrantTokenException , InvalidImportTokenException , InvalidKeyUsageException , InvalidMarkerException , KeyListEntry , KeyMetadata , KeyUnavailableException , KMSInternalException , KMSInvalidSignatureException , KMSInvalidStateException , LimitExceededException , ListAliasesRequest , ListAliasesResponse , ListGrantsRequest , ListGrantsResponse , ListKeyPoliciesRequest , ListKeyPoliciesResponse , ListKeysRequest , ListKeysResponse , ListResourceTagsRequest , ListResourceTagsResponse , ListRetirableGrantsRequest , MalformedPolicyDocumentException , MultiRegionConfiguration , MultiRegionKey , NotFoundException , PutKeyPolicyRequest , ReEncryptRequest , ReEncryptResponse , ReplicateKeyRequest , ReplicateKeyResponse , RetireGrantRequest , RevokeGrantRequest , ScheduleKeyDeletionRequest , ScheduleKeyDeletionResponse , SigningAlgorithmSpec , SignRequest , SignResponse , Tag , TagException , TagResourceRequest , UnsupportedOperationException , UntagResourceRequest , UpdateAliasRequest , UpdateCustomKeyStoreRequest , UpdateCustomKeyStoreResponse , UpdateKeyDescriptionRequest , UpdatePrimaryRegionRequest , VerifyRequest , VerifyResponse , } from "../models/models_0" ; export const serializeAws_json1_1CancelKeyDeletionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.CancelKeyDeletion" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CancelKeyDeletionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ConnectCustomKeyStoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ConnectCustomKeyStore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ConnectCustomKeyStoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateAliasCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.CreateAlias" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateAliasRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateCustomKeyStoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.CreateCustomKeyStore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateCustomKeyStoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateGrantCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.CreateGrant" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateGrantRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.CreateKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DecryptCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.Decrypt" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DecryptRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteAliasCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DeleteAlias" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteAliasRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteCustomKeyStoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DeleteCustomKeyStore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteCustomKeyStoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteImportedKeyMaterialCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DeleteImportedKeyMaterial" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteImportedKeyMaterialRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeCustomKeyStoresCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DescribeCustomKeyStores" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeCustomKeyStoresRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DescribeKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DescribeKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DescribeKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DisableKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DisableKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DisableKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DisableKeyRotationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DisableKeyRotation" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DisableKeyRotationRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DisconnectCustomKeyStoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.DisconnectCustomKeyStore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DisconnectCustomKeyStoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1EnableKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.EnableKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1EnableKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1EnableKeyRotationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.EnableKeyRotation" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1EnableKeyRotationRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1EncryptCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.Encrypt" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1EncryptRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GenerateDataKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GenerateDataKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GenerateDataKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GenerateDataKeyPairCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GenerateDataKeyPair" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GenerateDataKeyPairRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GenerateDataKeyPairWithoutPlaintext" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GenerateDataKeyPairWithoutPlaintextRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GenerateDataKeyWithoutPlaintextCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GenerateDataKeyWithoutPlaintext" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GenerateDataKeyWithoutPlaintextRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GenerateRandomCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GenerateRandom" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GenerateRandomRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetKeyPolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GetKeyPolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetKeyPolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetKeyRotationStatusCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GetKeyRotationStatus" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetKeyRotationStatusRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetParametersForImportCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GetParametersForImport" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetParametersForImportRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetPublicKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.GetPublicKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetPublicKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ImportKeyMaterialCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ImportKeyMaterial" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ImportKeyMaterialRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListAliasesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListAliases" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListAliasesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListGrantsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListGrants" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListGrantsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListKeyPoliciesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListKeyPolicies" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListKeyPoliciesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListKeysCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListKeys" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListKeysRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListResourceTagsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListResourceTags" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListResourceTagsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListRetirableGrantsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ListRetirableGrants" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListRetirableGrantsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1PutKeyPolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.PutKeyPolicy" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1PutKeyPolicyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ReEncryptCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ReEncrypt" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ReEncryptRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ReplicateKeyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ReplicateKey" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ReplicateKeyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RetireGrantCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.RetireGrant" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RetireGrantRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RevokeGrantCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.RevokeGrant" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RevokeGrantRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ScheduleKeyDeletionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.ScheduleKeyDeletion" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ScheduleKeyDeletionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1SignCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.Sign" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1SignRequest ( 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" : "TrentService.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" : "TrentService.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateAliasCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.UpdateAlias" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateAliasRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateCustomKeyStoreCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.UpdateCustomKeyStore" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateCustomKeyStoreRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateKeyDescriptionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.UpdateKeyDescription" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateKeyDescriptionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdatePrimaryRegionCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.UpdatePrimaryRegion" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdatePrimaryRegionRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1VerifyCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "TrentService.Verify" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1VerifyRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1CancelKeyDeletionCommand = async ( output , context ) : Promise < CancelKeyDeletionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CancelKeyDeletionCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CancelKeyDeletionResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CancelKeyDeletionCommandError = async ( output , context ) : Promise < CancelKeyDeletionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ConnectCustomKeyStoreCommand = async ( output , context ) : Promise < ConnectCustomKeyStoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ConnectCustomKeyStoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ConnectCustomKeyStoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ConnectCustomKeyStoreCommandError = async ( output , context ) : Promise < ConnectCustomKeyStoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CloudHsmClusterInvalidConfigurationException" : case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotActiveException" : case "com.amazonaws.kms#CloudHsmClusterNotActiveException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1CreateAliasCommand = async ( output , context ) : Promise < CreateAliasCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateAliasCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateAliasCommandError = async ( output , context ) : Promise < CreateAliasCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AlreadyExistsException" : case "com.amazonaws.kms#AlreadyExistsException" : response = { ... ( await deserializeAws_json1_1AlreadyExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidAliasNameException" : case "com.amazonaws.kms#InvalidAliasNameException" : response = { ... ( await deserializeAws_json1_1InvalidAliasNameExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1CreateCustomKeyStoreCommand = async ( output , context ) : Promise < CreateCustomKeyStoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateCustomKeyStoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateCustomKeyStoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateCustomKeyStoreCommandError = async ( output , context ) : Promise < CreateCustomKeyStoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CloudHsmClusterInUseException" : case "com.amazonaws.kms#CloudHsmClusterInUseException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterInvalidConfigurationException" : case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotActiveException" : case "com.amazonaws.kms#CloudHsmClusterNotActiveException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotFoundException" : case "com.amazonaws.kms#CloudHsmClusterNotFoundException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNameInUseException" : case "com.amazonaws.kms#CustomKeyStoreNameInUseException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IncorrectTrustAnchorException" : case "com.amazonaws.kms#IncorrectTrustAnchorException" : response = { ... ( await deserializeAws_json1_1IncorrectTrustAnchorExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1CreateGrantCommand = async ( output , context ) : Promise < CreateGrantCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateGrantCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateGrantResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateGrantCommandError = async ( output , context ) : Promise < CreateGrantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1CreateKeyCommand = async ( output , context ) : Promise < CreateKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateKeyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateKeyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateKeyCommandError = async ( output , context ) : Promise < CreateKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CloudHsmClusterInvalidConfigurationException" : case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.kms#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagException" : case "com.amazonaws.kms#TagException" : response = { ... ( await deserializeAws_json1_1TagExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1DecryptCommand = async ( output , context ) : Promise < DecryptCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DecryptCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DecryptResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DecryptCommandError = async ( output , context ) : Promise < DecryptCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IncorrectKeyException" : case "com.amazonaws.kms#IncorrectKeyException" : response = { ... ( await deserializeAws_json1_1IncorrectKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidCiphertextException" : case "com.amazonaws.kms#InvalidCiphertextException" : response = { ... ( await deserializeAws_json1_1InvalidCiphertextExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1DeleteAliasCommand = async ( output , context ) : Promise < DeleteAliasCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteAliasCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteAliasCommandError = async ( output , context ) : Promise < DeleteAliasCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1DeleteCustomKeyStoreCommand = async ( output , context ) : Promise < DeleteCustomKeyStoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteCustomKeyStoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteCustomKeyStoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteCustomKeyStoreCommandError = async ( output , context ) : Promise < DeleteCustomKeyStoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CustomKeyStoreHasCMKsException" : case "com.amazonaws.kms#CustomKeyStoreHasCMKsException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreHasCMKsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1DeleteImportedKeyMaterialCommand = async ( output , context ) : Promise < DeleteImportedKeyMaterialCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteImportedKeyMaterialCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteImportedKeyMaterialCommandError = async ( output , context ) : Promise < DeleteImportedKeyMaterialCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1DescribeCustomKeyStoresCommand = async ( output , context ) : Promise < DescribeCustomKeyStoresCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeCustomKeyStoresCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeCustomKeyStoresResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeCustomKeyStoresCommandError = async ( output , context ) : Promise < DescribeCustomKeyStoresCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1DescribeKeyCommand = async ( output , context ) : Promise < DescribeKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DescribeKeyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DescribeKeyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DescribeKeyCommandError = async ( output , context ) : Promise < DescribeKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1DisableKeyCommand = async ( output , context ) : Promise < DisableKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DisableKeyCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DisableKeyCommandError = async ( output , context ) : Promise < DisableKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1DisableKeyRotationCommand = async ( output , context ) : Promise < DisableKeyRotationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DisableKeyRotationCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DisableKeyRotationCommandError = async ( output , context ) : Promise < DisableKeyRotationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1DisconnectCustomKeyStoreCommand = async ( output , context ) : Promise < DisconnectCustomKeyStoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DisconnectCustomKeyStoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DisconnectCustomKeyStoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DisconnectCustomKeyStoreCommandError = async ( output , context ) : Promise < DisconnectCustomKeyStoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1EnableKeyCommand = async ( output , context ) : Promise < EnableKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1EnableKeyCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1EnableKeyCommandError = async ( output , context ) : Promise < EnableKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1EnableKeyRotationCommand = async ( output , context ) : Promise < EnableKeyRotationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1EnableKeyRotationCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1EnableKeyRotationCommandError = async ( output , context ) : Promise < EnableKeyRotationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1EncryptCommand = async ( output , context ) : Promise < EncryptCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1EncryptCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1EncryptResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1EncryptCommandError = async ( output , context ) : Promise < EncryptCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1GenerateDataKeyCommand = async ( output , context ) : Promise < GenerateDataKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GenerateDataKeyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GenerateDataKeyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GenerateDataKeyCommandError = async ( output , context ) : Promise < GenerateDataKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1GenerateDataKeyPairCommand = async ( output , context ) : Promise < GenerateDataKeyPairCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GenerateDataKeyPairCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GenerateDataKeyPairResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GenerateDataKeyPairCommandError = async ( output , context ) : Promise < GenerateDataKeyPairCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1GenerateDataKeyPairWithoutPlaintextCommand = async ( output , context ) : Promise < GenerateDataKeyPairWithoutPlaintextCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextCommandError = async ( output , context ) : Promise < GenerateDataKeyPairWithoutPlaintextCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1GenerateDataKeyWithoutPlaintextCommand = async ( output , context ) : Promise < GenerateDataKeyWithoutPlaintextCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GenerateDataKeyWithoutPlaintextResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextCommandError = async ( output , context ) : Promise < GenerateDataKeyWithoutPlaintextCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1GenerateRandomCommand = async ( output , context ) : Promise < GenerateRandomCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GenerateRandomCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GenerateRandomResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GenerateRandomCommandError = async ( output , context ) : Promise < GenerateRandomCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1GetKeyPolicyCommand = async ( output , context ) : Promise < GetKeyPolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetKeyPolicyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetKeyPolicyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetKeyPolicyCommandError = async ( output , context ) : Promise < GetKeyPolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1GetKeyRotationStatusCommand = async ( output , context ) : Promise < GetKeyRotationStatusCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetKeyRotationStatusCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetKeyRotationStatusResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetKeyRotationStatusCommandError = async ( output , context ) : Promise < GetKeyRotationStatusCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1GetParametersForImportCommand = async ( output , context ) : Promise < GetParametersForImportCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetParametersForImportCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetParametersForImportResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetParametersForImportCommandError = async ( output , context ) : Promise < GetParametersForImportCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1GetPublicKeyCommand = async ( output , context ) : Promise < GetPublicKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetPublicKeyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetPublicKeyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetPublicKeyCommandError = async ( output , context ) : Promise < GetPublicKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1ImportKeyMaterialCommand = async ( output , context ) : Promise < ImportKeyMaterialCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ImportKeyMaterialCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ImportKeyMaterialResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ImportKeyMaterialCommandError = async ( output , context ) : Promise < ImportKeyMaterialCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ExpiredImportTokenException" : case "com.amazonaws.kms#ExpiredImportTokenException" : response = { ... ( await deserializeAws_json1_1ExpiredImportTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IncorrectKeyMaterialException" : case "com.amazonaws.kms#IncorrectKeyMaterialException" : response = { ... ( await deserializeAws_json1_1IncorrectKeyMaterialExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidCiphertextException" : case "com.amazonaws.kms#InvalidCiphertextException" : response = { ... ( await deserializeAws_json1_1InvalidCiphertextExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidImportTokenException" : case "com.amazonaws.kms#InvalidImportTokenException" : response = { ... ( await deserializeAws_json1_1InvalidImportTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1ListAliasesCommand = async ( output , context ) : Promise < ListAliasesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListAliasesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListAliasesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListAliasesCommandError = async ( output , context ) : Promise < ListAliasesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ListGrantsCommand = async ( output , context ) : Promise < ListGrantsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListGrantsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListGrantsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListGrantsCommandError = async ( output , context ) : Promise < ListGrantsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantIdException" : case "com.amazonaws.kms#InvalidGrantIdException" : response = { ... ( await deserializeAws_json1_1InvalidGrantIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ListKeyPoliciesCommand = async ( output , context ) : Promise < ListKeyPoliciesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListKeyPoliciesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListKeyPoliciesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListKeyPoliciesCommandError = async ( output , context ) : Promise < ListKeyPoliciesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ListKeysCommand = async ( output , context ) : Promise < ListKeysCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListKeysCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListKeysResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListKeysCommandError = async ( output , context ) : Promise < ListKeysCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1ListResourceTagsCommand = async ( output , context ) : Promise < ListResourceTagsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListResourceTagsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListResourceTagsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListResourceTagsCommandError = async ( output , context ) : Promise < ListResourceTagsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ListRetirableGrantsCommand = async ( output , context ) : Promise < ListRetirableGrantsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListRetirableGrantsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListGrantsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListRetirableGrantsCommandError = async ( output , context ) : Promise < ListRetirableGrantsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidMarkerException" : case "com.amazonaws.kms#InvalidMarkerException" : response = { ... ( await deserializeAws_json1_1InvalidMarkerExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1PutKeyPolicyCommand = async ( output , context ) : Promise < PutKeyPolicyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1PutKeyPolicyCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1PutKeyPolicyCommandError = async ( output , context ) : Promise < PutKeyPolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.kms#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1ReEncryptCommand = async ( output , context ) : Promise < ReEncryptCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ReEncryptCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ReEncryptResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ReEncryptCommandError = async ( output , context ) : Promise < ReEncryptCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "IncorrectKeyException" : case "com.amazonaws.kms#IncorrectKeyException" : response = { ... ( await deserializeAws_json1_1IncorrectKeyExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidCiphertextException" : case "com.amazonaws.kms#InvalidCiphertextException" : response = { ... ( await deserializeAws_json1_1InvalidCiphertextExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ReplicateKeyCommand = async ( output , context ) : Promise < ReplicateKeyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ReplicateKeyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ReplicateKeyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ReplicateKeyCommandError = async ( output , context ) : Promise < ReplicateKeyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AlreadyExistsException" : case "com.amazonaws.kms#AlreadyExistsException" : response = { ... ( await deserializeAws_json1_1AlreadyExistsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedPolicyDocumentException" : case "com.amazonaws.kms#MalformedPolicyDocumentException" : response = { ... ( await deserializeAws_json1_1MalformedPolicyDocumentExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagException" : case "com.amazonaws.kms#TagException" : response = { ... ( await deserializeAws_json1_1TagExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1RetireGrantCommand = async ( output , context ) : Promise < RetireGrantCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RetireGrantCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RetireGrantCommandError = async ( output , context ) : Promise < RetireGrantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantIdException" : case "com.amazonaws.kms#InvalidGrantIdException" : response = { ... ( await deserializeAws_json1_1InvalidGrantIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1RevokeGrantCommand = async ( output , context ) : Promise < RevokeGrantCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RevokeGrantCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RevokeGrantCommandError = async ( output , context ) : Promise < RevokeGrantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantIdException" : case "com.amazonaws.kms#InvalidGrantIdException" : response = { ... ( await deserializeAws_json1_1InvalidGrantIdExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1ScheduleKeyDeletionCommand = async ( output , context ) : Promise < ScheduleKeyDeletionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ScheduleKeyDeletionCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ScheduleKeyDeletionResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ScheduleKeyDeletionCommandError = async ( output , context ) : Promise < ScheduleKeyDeletionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1SignCommand = async ( output , context ) : Promise < SignCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1SignCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1SignResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1SignCommandError = async ( output , context ) : Promise < SignCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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 "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagException" : case "com.amazonaws.kms#TagException" : response = { ... ( await deserializeAws_json1_1TagExceptionResponse ( 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 "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagException" : case "com.amazonaws.kms#TagException" : response = { ... ( await deserializeAws_json1_1TagExceptionResponse ( 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_1UpdateAliasCommand = async ( output , context ) : Promise < UpdateAliasCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateAliasCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateAliasCommandError = async ( output , context ) : Promise < UpdateAliasCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "LimitExceededException" : case "com.amazonaws.kms#LimitExceededException" : response = { ... ( await deserializeAws_json1_1LimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1UpdateCustomKeyStoreCommand = async ( output , context ) : Promise < UpdateCustomKeyStoreCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateCustomKeyStoreCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateCustomKeyStoreResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateCustomKeyStoreCommandError = async ( output , context ) : Promise < UpdateCustomKeyStoreCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CloudHsmClusterInvalidConfigurationException" : case "com.amazonaws.kms#CloudHsmClusterInvalidConfigurationException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotActiveException" : case "com.amazonaws.kms#CloudHsmClusterNotActiveException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotFoundException" : case "com.amazonaws.kms#CloudHsmClusterNotFoundException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CloudHsmClusterNotRelatedException" : case "com.amazonaws.kms#CloudHsmClusterNotRelatedException" : response = { ... ( await deserializeAws_json1_1CloudHsmClusterNotRelatedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreInvalidStateException" : case "com.amazonaws.kms#CustomKeyStoreInvalidStateException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNameInUseException" : case "com.amazonaws.kms#CustomKeyStoreNameInUseException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "CustomKeyStoreNotFoundException" : case "com.amazonaws.kms#CustomKeyStoreNotFoundException" : response = { ... ( await deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( 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_1UpdateKeyDescriptionCommand = async ( output , context ) : Promise < UpdateKeyDescriptionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateKeyDescriptionCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateKeyDescriptionCommandError = async ( output , context ) : Promise < UpdateKeyDescriptionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1UpdatePrimaryRegionCommand = async ( output , context ) : Promise < UpdatePrimaryRegionCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdatePrimaryRegionCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdatePrimaryRegionCommandError = async ( output , context ) : Promise < UpdatePrimaryRegionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidArnException" : case "com.amazonaws.kms#InvalidArnException" : response = { ... ( await deserializeAws_json1_1InvalidArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnsupportedOperationException" : case "com.amazonaws.kms#UnsupportedOperationException" : response = { ... ( await deserializeAws_json1_1UnsupportedOperationExceptionResponse ( 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_1VerifyCommand = async ( output , context ) : Promise < VerifyCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1VerifyCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1VerifyResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1VerifyCommandError = async ( output , context ) : Promise < VerifyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DependencyTimeoutException" : case "com.amazonaws.kms#DependencyTimeoutException" : response = { ... ( await deserializeAws_json1_1DependencyTimeoutExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "DisabledException" : case "com.amazonaws.kms#DisabledException" : response = { ... ( await deserializeAws_json1_1DisabledExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidGrantTokenException" : case "com.amazonaws.kms#InvalidGrantTokenException" : response = { ... ( await deserializeAws_json1_1InvalidGrantTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidKeyUsageException" : case "com.amazonaws.kms#InvalidKeyUsageException" : response = { ... ( await deserializeAws_json1_1InvalidKeyUsageExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KeyUnavailableException" : case "com.amazonaws.kms#KeyUnavailableException" : response = { ... ( await deserializeAws_json1_1KeyUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInternalException" : case "com.amazonaws.kms#KMSInternalException" : response = { ... ( await deserializeAws_json1_1KMSInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidSignatureException" : case "com.amazonaws.kms#KMSInvalidSignatureException" : response = { ... ( await deserializeAws_json1_1KMSInvalidSignatureExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "KMSInvalidStateException" : case "com.amazonaws.kms#KMSInvalidStateException" : response = { ... ( await deserializeAws_json1_1KMSInvalidStateExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NotFoundException" : case "com.amazonaws.kms#NotFoundException" : response = { ... ( await deserializeAws_json1_1NotFoundExceptionResponse ( 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_1AlreadyExistsExceptionResponse = async ( parsedOutput , context ) : Promise < AlreadyExistsException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1AlreadyExistsException ( body , context ) ; const contents = { name : "AlreadyExistsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CloudHsmClusterInUseExceptionResponse = async ( parsedOutput , context ) : Promise < CloudHsmClusterInUseException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CloudHsmClusterInUseException ( body , context ) ; const contents = { name : "CloudHsmClusterInUseException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CloudHsmClusterInvalidConfigurationExceptionResponse = async ( parsedOutput , context ) : Promise < CloudHsmClusterInvalidConfigurationException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CloudHsmClusterInvalidConfigurationException ( body , context ) ; const contents = { name : "CloudHsmClusterInvalidConfigurationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CloudHsmClusterNotActiveExceptionResponse = async ( parsedOutput , context ) : Promise < CloudHsmClusterNotActiveException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CloudHsmClusterNotActiveException ( body , context ) ; const contents = { name : "CloudHsmClusterNotActiveException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CloudHsmClusterNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < CloudHsmClusterNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CloudHsmClusterNotFoundException ( body , context ) ; const contents = { name : "CloudHsmClusterNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CloudHsmClusterNotRelatedExceptionResponse = async ( parsedOutput , context ) : Promise < CloudHsmClusterNotRelatedException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CloudHsmClusterNotRelatedException ( body , context ) ; const contents = { name : "CloudHsmClusterNotRelatedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CustomKeyStoreHasCMKsExceptionResponse = async ( parsedOutput , context ) : Promise < CustomKeyStoreHasCMKsException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CustomKeyStoreHasCMKsException ( body , context ) ; const contents = { name : "CustomKeyStoreHasCMKsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CustomKeyStoreInvalidStateExceptionResponse = async ( parsedOutput , context ) : Promise < CustomKeyStoreInvalidStateException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CustomKeyStoreInvalidStateException ( body , context ) ; const contents = { name : "CustomKeyStoreInvalidStateException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CustomKeyStoreNameInUseExceptionResponse = async ( parsedOutput , context ) : Promise < CustomKeyStoreNameInUseException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CustomKeyStoreNameInUseException ( body , context ) ; const contents = { name : "CustomKeyStoreNameInUseException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1CustomKeyStoreNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < CustomKeyStoreNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CustomKeyStoreNotFoundException ( body , context ) ; const contents = { name : "CustomKeyStoreNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1DependencyTimeoutExceptionResponse = async ( parsedOutput , context ) : Promise < DependencyTimeoutException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1DependencyTimeoutException ( body , context ) ; const contents = { name : "DependencyTimeoutException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1DisabledExceptionResponse = async ( parsedOutput , context ) : Promise < DisabledException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1DisabledException ( body , context ) ; const contents = { name : "DisabledException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ExpiredImportTokenExceptionResponse = async ( parsedOutput , context ) : Promise < ExpiredImportTokenException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ExpiredImportTokenException ( body , context ) ; const contents = { name : "ExpiredImportTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1IncorrectKeyExceptionResponse = async ( parsedOutput , context ) : Promise < IncorrectKeyException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1IncorrectKeyException ( body , context ) ; const contents = { name : "IncorrectKeyException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1IncorrectKeyMaterialExceptionResponse = async ( parsedOutput , context ) : Promise < IncorrectKeyMaterialException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1IncorrectKeyMaterialException ( body , context ) ; const contents = { name : "IncorrectKeyMaterialException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1IncorrectTrustAnchorExceptionResponse = async ( parsedOutput , context ) : Promise < IncorrectTrustAnchorException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1IncorrectTrustAnchorException ( body , context ) ; const contents = { name : "IncorrectTrustAnchorException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidAliasNameExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidAliasNameException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidAliasNameException ( body , context ) ; const contents = { name : "InvalidAliasNameException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidArnExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidArnException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidArnException ( body , context ) ; const contents = { name : "InvalidArnException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidCiphertextExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidCiphertextException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidCiphertextException ( body , context ) ; const contents = { name : "InvalidCiphertextException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidGrantIdExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidGrantIdException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidGrantIdException ( body , context ) ; const contents = { name : "InvalidGrantIdException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidGrantTokenExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidGrantTokenException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidGrantTokenException ( body , context ) ; const contents = { name : "InvalidGrantTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidImportTokenExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidImportTokenException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidImportTokenException ( body , context ) ; const contents = { name : "InvalidImportTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidKeyUsageExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidKeyUsageException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidKeyUsageException ( body , context ) ; const contents = { name : "InvalidKeyUsageException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidMarkerExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidMarkerException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidMarkerException ( body , context ) ; const contents = { name : "InvalidMarkerException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1KeyUnavailableExceptionResponse = async ( parsedOutput , context ) : Promise < KeyUnavailableException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1KeyUnavailableException ( body , context ) ; const contents = { name : "KeyUnavailableException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1KMSInternalExceptionResponse = async ( parsedOutput , context ) : Promise < KMSInternalException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1KMSInternalException ( body , context ) ; const contents = { name : "KMSInternalException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1KMSInvalidSignatureExceptionResponse = async ( parsedOutput , context ) : Promise < KMSInvalidSignatureException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1KMSInvalidSignatureException ( body , context ) ; const contents = { name : "KMSInvalidSignatureException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1KMSInvalidStateExceptionResponse = async ( parsedOutput , context ) : Promise < KMSInvalidStateException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1KMSInvalidStateException ( body , context ) ; const contents = { name : "KMSInvalidStateException" , $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_1NotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < NotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1NotFoundException ( body , context ) ; const contents = { name : "NotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1TagExceptionResponse = async ( parsedOutput , context ) : Promise < TagException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1TagException ( body , context ) ; const contents = { name : "TagException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1UnsupportedOperationExceptionResponse = async ( parsedOutput , context ) : Promise < UnsupportedOperationException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1UnsupportedOperationException ( body , context ) ; const contents = { name : "UnsupportedOperationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_1CancelKeyDeletionRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1ConnectCustomKeyStoreRequest = ( input , context ) : any => { return { ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , } ; } ; const serializeAws_json1_1CreateAliasRequest = ( input , context ) : any => { return { ... ( input . AliasName !== undefined && input . AliasName !== null && { AliasName : input . AliasName } ) , ... ( input . TargetKeyId !== undefined && input . TargetKeyId !== null && { TargetKeyId : input . TargetKeyId } ) , } ; } ; const serializeAws_json1_1CreateCustomKeyStoreRequest = ( input , context ) : any => { return { ... ( input . CloudHsmClusterId !== undefined && input . CloudHsmClusterId !== null && { CloudHsmClusterId : input . CloudHsmClusterId } ) , ... ( input . CustomKeyStoreName !== undefined && input . CustomKeyStoreName !== null && { CustomKeyStoreName : input . CustomKeyStoreName } ) , ... ( input . KeyStorePassword !== undefined && input . KeyStorePassword !== null && { KeyStorePassword : input . KeyStorePassword } ) , ... ( input . TrustAnchorCertificate !== undefined && input . TrustAnchorCertificate !== null && { TrustAnchorCertificate : input . TrustAnchorCertificate } ) , } ; } ; const serializeAws_json1_1CreateGrantRequest = ( input , context ) : any => { return { ... ( input . Constraints !== undefined && input . Constraints !== null && { Constraints : serializeAws_json1_1GrantConstraints ( input . Constraints , context ) } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . GranteePrincipal !== undefined && input . GranteePrincipal !== null && { GranteePrincipal : input . GranteePrincipal } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Operations !== undefined && input . Operations !== null && { Operations : serializeAws_json1_1GrantOperationList ( input . Operations , context ) } ) , ... ( input . RetiringPrincipal !== undefined && input . RetiringPrincipal !== null && { RetiringPrincipal : input . RetiringPrincipal } ) , } ; } ; const serializeAws_json1_1CreateKeyRequest = ( input , context ) : any => { return { ... ( input . BypassPolicyLockoutSafetyCheck !== undefined && input . BypassPolicyLockoutSafetyCheck !== null && { BypassPolicyLockoutSafetyCheck : input . BypassPolicyLockoutSafetyCheck , } ) , ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , ... ( input . CustomerMasterKeySpec !== undefined && input . CustomerMasterKeySpec !== null && { CustomerMasterKeySpec : input . CustomerMasterKeySpec } ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . KeySpec !== undefined && input . KeySpec !== null && { KeySpec : input . KeySpec } ) , ... ( input . KeyUsage !== undefined && input . KeyUsage !== null && { KeyUsage : input . KeyUsage } ) , ... ( input . MultiRegion !== undefined && input . MultiRegion !== null && { MultiRegion : input . MultiRegion } ) , ... ( input . Origin !== undefined && input . Origin !== null && { Origin : input . Origin } ) , ... ( input . Policy !== undefined && input . Policy !== null && { Policy : input . Policy } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1DecryptRequest = ( input , context ) : any => { return { ... ( input . CiphertextBlob !== undefined && input . CiphertextBlob !== null && { CiphertextBlob : context . base64Encoder ( input . CiphertextBlob ) } ) , ... ( input . EncryptionAlgorithm !== undefined && input . EncryptionAlgorithm !== null && { EncryptionAlgorithm : input . EncryptionAlgorithm } ) , ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1DeleteAliasRequest = ( input , context ) : any => { return { ... ( input . AliasName !== undefined && input . AliasName !== null && { AliasName : input . AliasName } ) , } ; } ; const serializeAws_json1_1DeleteCustomKeyStoreRequest = ( input , context ) : any => { return { ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , } ; } ; const serializeAws_json1_1DeleteImportedKeyMaterialRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1DescribeCustomKeyStoresRequest = ( input , context ) : any => { return { ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , ... ( input . CustomKeyStoreName !== undefined && input . CustomKeyStoreName !== null && { CustomKeyStoreName : input . CustomKeyStoreName } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1DescribeKeyRequest = ( input , context ) : any => { return { ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1DisableKeyRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1DisableKeyRotationRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1DisconnectCustomKeyStoreRequest = ( input , context ) : any => { return { ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , } ; } ; const serializeAws_json1_1EnableKeyRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1EnableKeyRotationRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1EncryptionContextType = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_json1_1EncryptRequest = ( input , context ) : any => { return { ... ( input . EncryptionAlgorithm !== undefined && input . EncryptionAlgorithm !== null && { EncryptionAlgorithm : input . EncryptionAlgorithm } ) , ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Plaintext !== undefined && input . Plaintext !== null && { Plaintext : context . base64Encoder ( input . Plaintext ) } ) , } ; } ; const serializeAws_json1_1GenerateDataKeyPairRequest = ( input , context ) : any => { return { ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . KeyPairSpec !== undefined && input . KeyPairSpec !== null && { KeyPairSpec : input . KeyPairSpec } ) , } ; } ; const serializeAws_json1_1GenerateDataKeyPairWithoutPlaintextRequest = ( input , context ) : any => { return { ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . KeyPairSpec !== undefined && input . KeyPairSpec !== null && { KeyPairSpec : input . KeyPairSpec } ) , } ; } ; const serializeAws_json1_1GenerateDataKeyRequest = ( input , context ) : any => { return { ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . KeySpec !== undefined && input . KeySpec !== null && { KeySpec : input . KeySpec } ) , ... ( input . NumberOfBytes !== undefined && input . NumberOfBytes !== null && { NumberOfBytes : input . NumberOfBytes } ) , } ; } ; const serializeAws_json1_1GenerateDataKeyWithoutPlaintextRequest = ( input , context ) : any => { return { ... ( input . EncryptionContext !== undefined && input . EncryptionContext !== null && { EncryptionContext : serializeAws_json1_1EncryptionContextType ( input . EncryptionContext , context ) , } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . KeySpec !== undefined && input . KeySpec !== null && { KeySpec : input . KeySpec } ) , ... ( input . NumberOfBytes !== undefined && input . NumberOfBytes !== null && { NumberOfBytes : input . NumberOfBytes } ) , } ; } ; const serializeAws_json1_1GenerateRandomRequest = ( input , context ) : any => { return { ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , ... ( input . NumberOfBytes !== undefined && input . NumberOfBytes !== null && { NumberOfBytes : input . NumberOfBytes } ) , } ; } ; const serializeAws_json1_1GetKeyPolicyRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . PolicyName !== undefined && input . PolicyName !== null && { PolicyName : input . PolicyName } ) , } ; } ; const serializeAws_json1_1GetKeyRotationStatusRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1GetParametersForImportRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . WrappingAlgorithm !== undefined && input . WrappingAlgorithm !== null && { WrappingAlgorithm : input . WrappingAlgorithm } ) , ... ( input . WrappingKeySpec !== undefined && input . WrappingKeySpec !== null && { WrappingKeySpec : input . WrappingKeySpec } ) , } ; } ; const serializeAws_json1_1GetPublicKeyRequest = ( input , context ) : any => { return { ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1GrantConstraints = ( input , context ) : any => { return { ... ( input . EncryptionContextEquals !== undefined && input . EncryptionContextEquals !== null && { EncryptionContextEquals : serializeAws_json1_1EncryptionContextType ( input . EncryptionContextEquals , context ) , } ) , ... ( input . EncryptionContextSubset !== undefined && input . EncryptionContextSubset !== null && { EncryptionContextSubset : serializeAws_json1_1EncryptionContextType ( input . EncryptionContextSubset , context ) , } ) , } ; } ; const serializeAws_json1_1GrantOperationList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1GrantTokenList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1ImportKeyMaterialRequest = ( input , context ) : any => { return { ... ( input . EncryptedKeyMaterial !== undefined && input . EncryptedKeyMaterial !== null && { EncryptedKeyMaterial : context . base64Encoder ( input . EncryptedKeyMaterial ) , } ) , ... ( input . ExpirationModel !== undefined && input . ExpirationModel !== null && { ExpirationModel : input . ExpirationModel } ) , ... ( input . ImportToken !== undefined && input . ImportToken !== null && { ImportToken : context . base64Encoder ( input . ImportToken ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . ValidTo !== undefined && input . ValidTo !== null && { ValidTo : Math . round ( input . ValidTo . getTime ( ) / 1000 ) } ) , } ; } ; const serializeAws_json1_1ListAliasesRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1ListGrantsRequest = ( input , context ) : any => { return { ... ( input . GrantId !== undefined && input . GrantId !== null && { GrantId : input . GrantId } ) , ... ( input . GranteePrincipal !== undefined && input . GranteePrincipal !== null && { GranteePrincipal : input . GranteePrincipal } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1ListKeyPoliciesRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1ListKeysRequest = ( input , context ) : any => { return { ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1ListResourceTagsRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , } ; } ; const serializeAws_json1_1ListRetirableGrantsRequest = ( input , context ) : any => { return { ... ( input . Limit !== undefined && input . Limit !== null && { Limit : input . Limit } ) , ... ( input . Marker !== undefined && input . Marker !== null && { Marker : input . Marker } ) , ... ( input . RetiringPrincipal !== undefined && input . RetiringPrincipal !== null && { RetiringPrincipal : input . RetiringPrincipal } ) , } ; } ; const serializeAws_json1_1PutKeyPolicyRequest = ( input , context ) : any => { return { ... ( input . BypassPolicyLockoutSafetyCheck !== undefined && input . BypassPolicyLockoutSafetyCheck !== null && { BypassPolicyLockoutSafetyCheck : input . BypassPolicyLockoutSafetyCheck , } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Policy !== undefined && input . Policy !== null && { Policy : input . Policy } ) , ... ( input . PolicyName !== undefined && input . PolicyName !== null && { PolicyName : input . PolicyName } ) , } ; } ; const serializeAws_json1_1ReEncryptRequest = ( input , context ) : any => { return { ... ( input . CiphertextBlob !== undefined && input . CiphertextBlob !== null && { CiphertextBlob : context . base64Encoder ( input . CiphertextBlob ) } ) , ... ( input . DestinationEncryptionAlgorithm !== undefined && input . DestinationEncryptionAlgorithm !== null && { DestinationEncryptionAlgorithm : input . DestinationEncryptionAlgorithm , } ) , ... ( input . DestinationEncryptionContext !== undefined && input . DestinationEncryptionContext !== null && { DestinationEncryptionContext : serializeAws_json1_1EncryptionContextType ( input . DestinationEncryptionContext , context ) , } ) , ... ( input . DestinationKeyId !== undefined && input . DestinationKeyId !== null && { DestinationKeyId : input . DestinationKeyId } ) , ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . SourceEncryptionAlgorithm !== undefined && input . SourceEncryptionAlgorithm !== null && { SourceEncryptionAlgorithm : input . SourceEncryptionAlgorithm } ) , ... ( input . SourceEncryptionContext !== undefined && input . SourceEncryptionContext !== null && { SourceEncryptionContext : serializeAws_json1_1EncryptionContextType ( input . SourceEncryptionContext , context ) , } ) , ... ( input . SourceKeyId !== undefined && input . SourceKeyId !== null && { SourceKeyId : input . SourceKeyId } ) , } ; } ; const serializeAws_json1_1ReplicateKeyRequest = ( input , context ) : any => { return { ... ( input . BypassPolicyLockoutSafetyCheck !== undefined && input . BypassPolicyLockoutSafetyCheck !== null && { BypassPolicyLockoutSafetyCheck : input . BypassPolicyLockoutSafetyCheck , } ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Policy !== undefined && input . Policy !== null && { Policy : input . Policy } ) , ... ( input . ReplicaRegion !== undefined && input . ReplicaRegion !== null && { ReplicaRegion : input . ReplicaRegion } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1RetireGrantRequest = ( input , context ) : any => { return { ... ( input . GrantId !== undefined && input . GrantId !== null && { GrantId : input . GrantId } ) , ... ( input . GrantToken !== undefined && input . GrantToken !== null && { GrantToken : input . GrantToken } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1RevokeGrantRequest = ( input , context ) : any => { return { ... ( input . GrantId !== undefined && input . GrantId !== null && { GrantId : input . GrantId } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1ScheduleKeyDeletionRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . PendingWindowInDays !== undefined && input . PendingWindowInDays !== null && { PendingWindowInDays : input . PendingWindowInDays } ) , } ; } ; const serializeAws_json1_1SignRequest = ( input , context ) : any => { return { ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Message !== undefined && input . Message !== null && { Message : context . base64Encoder ( input . Message ) } ) , ... ( input . MessageType !== undefined && input . MessageType !== null && { MessageType : input . MessageType } ) , ... ( input . SigningAlgorithm !== undefined && input . SigningAlgorithm !== null && { SigningAlgorithm : input . SigningAlgorithm } ) , } ; } ; const serializeAws_json1_1Tag = ( input , context ) : any => { return { ... ( input . TagKey !== undefined && input . TagKey !== null && { TagKey : input . TagKey } ) , ... ( input . TagValue !== undefined && input . TagValue !== null && { TagValue : input . TagValue } ) , } ; } ; const serializeAws_json1_1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const serializeAws_json1_1TagResourceRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1UntagResourceRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . TagKeys !== undefined && input . TagKeys !== null && { TagKeys : serializeAws_json1_1TagKeyList ( input . TagKeys , context ) } ) , } ; } ; const serializeAws_json1_1UpdateAliasRequest = ( input , context ) : any => { return { ... ( input . AliasName !== undefined && input . AliasName !== null && { AliasName : input . AliasName } ) , ... ( input . TargetKeyId !== undefined && input . TargetKeyId !== null && { TargetKeyId : input . TargetKeyId } ) , } ; } ; const serializeAws_json1_1UpdateCustomKeyStoreRequest = ( input , context ) : any => { return { ... ( input . CloudHsmClusterId !== undefined && input . CloudHsmClusterId !== null && { CloudHsmClusterId : input . CloudHsmClusterId } ) , ... ( input . CustomKeyStoreId !== undefined && input . CustomKeyStoreId !== null && { CustomKeyStoreId : input . CustomKeyStoreId } ) , ... ( input . KeyStorePassword !== undefined && input . KeyStorePassword !== null && { KeyStorePassword : input . KeyStorePassword } ) , ... ( input . NewCustomKeyStoreName !== undefined && input . NewCustomKeyStoreName !== null && { NewCustomKeyStoreName : input . NewCustomKeyStoreName } ) , } ; } ; const serializeAws_json1_1UpdateKeyDescriptionRequest = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , } ; } ; const serializeAws_json1_1UpdatePrimaryRegionRequest = ( input , context ) : any => { return { ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . PrimaryRegion !== undefined && input . PrimaryRegion !== null && { PrimaryRegion : input . PrimaryRegion } ) , } ; } ; const serializeAws_json1_1VerifyRequest = ( input , context ) : any => { return { ... ( input . GrantTokens !== undefined && input . GrantTokens !== null && { GrantTokens : serializeAws_json1_1GrantTokenList ( input . GrantTokens , context ) } ) , ... ( input . KeyId !== undefined && input . KeyId !== null && { KeyId : input . KeyId } ) , ... ( input . Message !== undefined && input . Message !== null && { Message : context . base64Encoder ( input . Message ) } ) , ... ( input . MessageType !== undefined && input . MessageType !== null && { MessageType : input . MessageType } ) , ... ( input . Signature !== undefined && input . Signature !== null && { Signature : context . base64Encoder ( input . Signature ) } ) , ... ( input . SigningAlgorithm !== undefined && input . SigningAlgorithm !== null && { SigningAlgorithm : input . SigningAlgorithm } ) , } ; } ; const deserializeAws_json1_1AliasList = ( output , context ) : AliasListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1AliasListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1AliasListEntry = ( output , context ) : AliasListEntry => { return { AliasArn : __expectString ( output . AliasArn ) , AliasName : __expectString ( output . AliasName ) , CreationDate : output . CreationDate !== undefined && output . CreationDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationDate ) ) ) : undefined , LastUpdatedDate : output . LastUpdatedDate !== undefined && output . LastUpdatedDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . LastUpdatedDate ) ) ) : undefined , TargetKeyId : __expectString ( output . TargetKeyId ) , } as any ; } ; const deserializeAws_json1_1AlreadyExistsException = ( output , context ) : AlreadyExistsException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CancelKeyDeletionResponse = ( output , context ) : CancelKeyDeletionResponse => { return { KeyId : __expectString ( output . KeyId ) , } as any ; } ; const deserializeAws_json1_1CloudHsmClusterInUseException = ( output , context ) : CloudHsmClusterInUseException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CloudHsmClusterInvalidConfigurationException = ( output , context ) : CloudHsmClusterInvalidConfigurationException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CloudHsmClusterNotActiveException = ( output , context ) : CloudHsmClusterNotActiveException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CloudHsmClusterNotFoundException = ( output , context ) : CloudHsmClusterNotFoundException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CloudHsmClusterNotRelatedException = ( output , context ) : CloudHsmClusterNotRelatedException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1ConnectCustomKeyStoreResponse = ( output , context ) : ConnectCustomKeyStoreResponse => { return { } as any ; } ; const deserializeAws_json1_1CreateCustomKeyStoreResponse = ( output , context ) : CreateCustomKeyStoreResponse => { return { CustomKeyStoreId : __expectString ( output . CustomKeyStoreId ) , } as any ; } ; const deserializeAws_json1_1CreateGrantResponse = ( output , context ) : CreateGrantResponse => { return { GrantId : __expectString ( output . GrantId ) , GrantToken : __expectString ( output . GrantToken ) , } as any ; } ; const deserializeAws_json1_1CreateKeyResponse = ( output , context ) : CreateKeyResponse => { return { KeyMetadata : output . KeyMetadata !== undefined && output . KeyMetadata !== null ? deserializeAws_json1_1KeyMetadata ( output . KeyMetadata , context ) : undefined , } as any ; } ; const deserializeAws_json1_1CustomKeyStoreHasCMKsException = ( output , context ) : CustomKeyStoreHasCMKsException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CustomKeyStoreInvalidStateException = ( output , context ) : CustomKeyStoreInvalidStateException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CustomKeyStoreNameInUseException = ( output , context ) : CustomKeyStoreNameInUseException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CustomKeyStoreNotFoundException = ( output , context ) : CustomKeyStoreNotFoundException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1CustomKeyStoresList = ( output , context ) : CustomKeyStoresListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1CustomKeyStoresListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1CustomKeyStoresListEntry = ( output , context ) : CustomKeyStoresListEntry => { return { CloudHsmClusterId : __expectString ( output . CloudHsmClusterId ) , ConnectionErrorCode : __expectString ( output . ConnectionErrorCode ) , ConnectionState : __expectString ( output . ConnectionState ) , CreationDate : output . CreationDate !== undefined && output . CreationDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationDate ) ) ) : undefined , CustomKeyStoreId : __expectString ( output . CustomKeyStoreId ) , CustomKeyStoreName : __expectString ( output . CustomKeyStoreName ) , TrustAnchorCertificate : __expectString ( output . TrustAnchorCertificate ) , } as any ; } ; const deserializeAws_json1_1DecryptResponse = ( output , context ) : DecryptResponse => { return { EncryptionAlgorithm : __expectString ( output . EncryptionAlgorithm ) , KeyId : __expectString ( output . KeyId ) , Plaintext : output . Plaintext !== undefined && output . Plaintext !== null ? context . base64Decoder ( output . Plaintext ) : undefined , } as any ; } ; const deserializeAws_json1_1DeleteCustomKeyStoreResponse = ( output , context ) : DeleteCustomKeyStoreResponse => { return { } as any ; } ; const deserializeAws_json1_1DependencyTimeoutException = ( output , context ) : DependencyTimeoutException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1DescribeCustomKeyStoresResponse = ( output , context ) : DescribeCustomKeyStoresResponse => { return { CustomKeyStores : output . CustomKeyStores !== undefined && output . CustomKeyStores !== null ? deserializeAws_json1_1CustomKeyStoresList ( output . CustomKeyStores , context ) : undefined , NextMarker : __expectString ( output . NextMarker ) , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1DescribeKeyResponse = ( output , context ) : DescribeKeyResponse => { return { KeyMetadata : output . KeyMetadata !== undefined && output . KeyMetadata !== null ? deserializeAws_json1_1KeyMetadata ( output . KeyMetadata , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DisabledException = ( output , context ) : DisabledException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1DisconnectCustomKeyStoreResponse = ( output , context ) : DisconnectCustomKeyStoreResponse => { return { } as any ; } ; const deserializeAws_json1_1EncryptionAlgorithmSpecList = ( output , context ) : ( EncryptionAlgorithmSpec | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1EncryptionContextType = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_json1_1EncryptResponse = ( output , context ) : EncryptResponse => { return { CiphertextBlob : output . CiphertextBlob !== undefined && output . CiphertextBlob !== null ? context . base64Decoder ( output . CiphertextBlob ) : undefined , EncryptionAlgorithm : __expectString ( output . EncryptionAlgorithm ) , KeyId : __expectString ( output . KeyId ) , } as any ; } ; const deserializeAws_json1_1ExpiredImportTokenException = ( output , context ) : ExpiredImportTokenException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1GenerateDataKeyPairResponse = ( output , context ) : GenerateDataKeyPairResponse => { return { KeyId : __expectString ( output . KeyId ) , KeyPairSpec : __expectString ( output . KeyPairSpec ) , PrivateKeyCiphertextBlob : output . PrivateKeyCiphertextBlob !== undefined && output . PrivateKeyCiphertextBlob !== null ? context . base64Decoder ( output . PrivateKeyCiphertextBlob ) : undefined , PrivateKeyPlaintext : output . PrivateKeyPlaintext !== undefined && output . PrivateKeyPlaintext !== null ? context . base64Decoder ( output . PrivateKeyPlaintext ) : undefined , PublicKey : output . PublicKey !== undefined && output . PublicKey !== null ? context . base64Decoder ( output . PublicKey ) : undefined , } as any ; } ; const deserializeAws_json1_1GenerateDataKeyPairWithoutPlaintextResponse = ( output , context ) : GenerateDataKeyPairWithoutPlaintextResponse => { return { KeyId : __expectString ( output . KeyId ) , KeyPairSpec : __expectString ( output . KeyPairSpec ) , PrivateKeyCiphertextBlob : output . PrivateKeyCiphertextBlob !== undefined && output . PrivateKeyCiphertextBlob !== null ? context . base64Decoder ( output . PrivateKeyCiphertextBlob ) : undefined , PublicKey : output . PublicKey !== undefined && output . PublicKey !== null ? context . base64Decoder ( output . PublicKey ) : undefined , } as any ; } ; const deserializeAws_json1_1GenerateDataKeyResponse = ( output , context ) : GenerateDataKeyResponse => { return { CiphertextBlob : output . CiphertextBlob !== undefined && output . CiphertextBlob !== null ? context . base64Decoder ( output . CiphertextBlob ) : undefined , KeyId : __expectString ( output . KeyId ) , Plaintext : output . Plaintext !== undefined && output . Plaintext !== null ? context . base64Decoder ( output . Plaintext ) : undefined , } as any ; } ; const deserializeAws_json1_1GenerateDataKeyWithoutPlaintextResponse = ( output , context ) : GenerateDataKeyWithoutPlaintextResponse => { return { CiphertextBlob : output . CiphertextBlob !== undefined && output . CiphertextBlob !== null ? context . base64Decoder ( output . CiphertextBlob ) : undefined , KeyId : __expectString ( output . KeyId ) , } as any ; } ; const deserializeAws_json1_1GenerateRandomResponse = ( output , context ) : GenerateRandomResponse => { return { Plaintext : output . Plaintext !== undefined && output . Plaintext !== null ? context . base64Decoder ( output . Plaintext ) : undefined , } as any ; } ; const deserializeAws_json1_1GetKeyPolicyResponse = ( output , context ) : GetKeyPolicyResponse => { return { Policy : __expectString ( output . Policy ) , } as any ; } ; const deserializeAws_json1_1GetKeyRotationStatusResponse = ( output , context ) : GetKeyRotationStatusResponse => { return { KeyRotationEnabled : __expectBoolean ( output . KeyRotationEnabled ) , } as any ; } ; const deserializeAws_json1_1GetParametersForImportResponse = ( output , context ) : GetParametersForImportResponse => { return { ImportToken : output . ImportToken !== undefined && output . ImportToken !== null ? context . base64Decoder ( output . ImportToken ) : undefined , KeyId : __expectString ( output . KeyId ) , ParametersValidTo : output . ParametersValidTo !== undefined && output . ParametersValidTo !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . ParametersValidTo ) ) ) : undefined , PublicKey : output . PublicKey !== undefined && output . PublicKey !== null ? context . base64Decoder ( output . PublicKey ) : undefined , } as any ; } ; const deserializeAws_json1_1GetPublicKeyResponse = ( output , context ) : GetPublicKeyResponse => { return { CustomerMasterKeySpec : __expectString ( output . CustomerMasterKeySpec ) , EncryptionAlgorithms : output . EncryptionAlgorithms !== undefined && output . EncryptionAlgorithms !== null ? deserializeAws_json1_1EncryptionAlgorithmSpecList ( output . EncryptionAlgorithms , context ) : undefined , KeyId : __expectString ( output . KeyId ) , KeySpec : __expectString ( output . KeySpec ) , KeyUsage : __expectString ( output . KeyUsage ) , PublicKey : output . PublicKey !== undefined && output . PublicKey !== null ? context . base64Decoder ( output . PublicKey ) : undefined , SigningAlgorithms : output . SigningAlgorithms !== undefined && output . SigningAlgorithms !== null ? deserializeAws_json1_1SigningAlgorithmSpecList ( output . SigningAlgorithms , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GrantConstraints = ( output , context ) : GrantConstraints => { return { EncryptionContextEquals : output . EncryptionContextEquals !== undefined && output . EncryptionContextEquals !== null ? deserializeAws_json1_1EncryptionContextType ( output . EncryptionContextEquals , context ) : undefined , EncryptionContextSubset : output . EncryptionContextSubset !== undefined && output . EncryptionContextSubset !== null ? deserializeAws_json1_1EncryptionContextType ( output . EncryptionContextSubset , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GrantList = ( output , context ) : GrantListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1GrantListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1GrantListEntry = ( output , context ) : GrantListEntry => { return { Constraints : output . Constraints !== undefined && output . Constraints !== null ? deserializeAws_json1_1GrantConstraints ( output . Constraints , context ) : undefined , CreationDate : output . CreationDate !== undefined && output . CreationDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationDate ) ) ) : undefined , GrantId : __expectString ( output . GrantId ) , GranteePrincipal : __expectString ( output . GranteePrincipal ) , IssuingAccount : __expectString ( output . IssuingAccount ) , KeyId : __expectString ( output . KeyId ) , Name : __expectString ( output . Name ) , Operations : output . Operations !== undefined && output . Operations !== null ? deserializeAws_json1_1GrantOperationList ( output . Operations , context ) : undefined , RetiringPrincipal : __expectString ( output . RetiringPrincipal ) , } as any ; } ; const deserializeAws_json1_1GrantOperationList = ( output , context ) : ( GrantOperation | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1ImportKeyMaterialResponse = ( output , context ) : ImportKeyMaterialResponse => { return { } as any ; } ; const deserializeAws_json1_1IncorrectKeyException = ( output , context ) : IncorrectKeyException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1IncorrectKeyMaterialException = ( output , context ) : IncorrectKeyMaterialException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1IncorrectTrustAnchorException = ( output , context ) : IncorrectTrustAnchorException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidAliasNameException = ( output , context ) : InvalidAliasNameException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidArnException = ( output , context ) : InvalidArnException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidCiphertextException = ( output , context ) : InvalidCiphertextException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidGrantIdException = ( output , context ) : InvalidGrantIdException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidGrantTokenException = ( output , context ) : InvalidGrantTokenException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidImportTokenException = ( output , context ) : InvalidImportTokenException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidKeyUsageException = ( output , context ) : InvalidKeyUsageException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1InvalidMarkerException = ( output , context ) : InvalidMarkerException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1KeyList = ( output , context ) : KeyListEntry [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1KeyListEntry ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1KeyListEntry = ( output , context ) : KeyListEntry => { return { KeyArn : __expectString ( output . KeyArn ) , KeyId : __expectString ( output . KeyId ) , } as any ; } ; const deserializeAws_json1_1KeyMetadata = ( output , context ) : KeyMetadata => { return { AWSAccountId : __expectString ( output . AWSAccountId ) , Arn : __expectString ( output . Arn ) , CloudHsmClusterId : __expectString ( output . CloudHsmClusterId ) , CreationDate : output . CreationDate !== undefined && output . CreationDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreationDate ) ) ) : undefined , CustomKeyStoreId : __expectString ( output . CustomKeyStoreId ) , CustomerMasterKeySpec : __expectString ( output . CustomerMasterKeySpec ) , DeletionDate : output . DeletionDate !== undefined && output . DeletionDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . DeletionDate ) ) ) : undefined , Description : __expectString ( output . Description ) , Enabled : __expectBoolean ( output . Enabled ) , EncryptionAlgorithms : output . EncryptionAlgorithms !== undefined && output . EncryptionAlgorithms !== null ? deserializeAws_json1_1EncryptionAlgorithmSpecList ( output . EncryptionAlgorithms , context ) : undefined , ExpirationModel : __expectString ( output . ExpirationModel ) , KeyId : __expectString ( output . KeyId ) , KeyManager : __expectString ( output . KeyManager ) , KeySpec : __expectString ( output . KeySpec ) , KeyState : __expectString ( output . KeyState ) , KeyUsage : __expectString ( output . KeyUsage ) , MultiRegion : __expectBoolean ( output . MultiRegion ) , MultiRegionConfiguration : output . MultiRegionConfiguration !== undefined && output . MultiRegionConfiguration !== null ? deserializeAws_json1_1MultiRegionConfiguration ( output . MultiRegionConfiguration , context ) : undefined , Origin : __expectString ( output . Origin ) , PendingDeletionWindowInDays : __expectInt32 ( output . PendingDeletionWindowInDays ) , SigningAlgorithms : output . SigningAlgorithms !== undefined && output . SigningAlgorithms !== null ? deserializeAws_json1_1SigningAlgorithmSpecList ( output . SigningAlgorithms , context ) : undefined , ValidTo : output . ValidTo !== undefined && output . ValidTo !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . ValidTo ) ) ) : undefined , } as any ; } ; const deserializeAws_json1_1KeyUnavailableException = ( output , context ) : KeyUnavailableException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1KMSInternalException = ( output , context ) : KMSInternalException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1KMSInvalidSignatureException = ( output , context ) : KMSInvalidSignatureException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1KMSInvalidStateException = ( output , context ) : KMSInvalidStateException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1LimitExceededException = ( output , context ) : LimitExceededException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1ListAliasesResponse = ( output , context ) : ListAliasesResponse => { return { Aliases : output . Aliases !== undefined && output . Aliases !== null ? deserializeAws_json1_1AliasList ( output . Aliases , context ) : undefined , NextMarker : __expectString ( output . NextMarker ) , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1ListGrantsResponse = ( output , context ) : ListGrantsResponse => { return { Grants : output . Grants !== undefined && output . Grants !== null ? deserializeAws_json1_1GrantList ( output . Grants , context ) : undefined , NextMarker : __expectString ( output . NextMarker ) , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1ListKeyPoliciesResponse = ( output , context ) : ListKeyPoliciesResponse => { return { NextMarker : __expectString ( output . NextMarker ) , PolicyNames : output . PolicyNames !== undefined && output . PolicyNames !== null ? deserializeAws_json1_1PolicyNameList ( output . PolicyNames , context ) : undefined , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1ListKeysResponse = ( output , context ) : ListKeysResponse => { return { Keys : output . Keys !== undefined && output . Keys !== null ? deserializeAws_json1_1KeyList ( output . Keys , context ) : undefined , NextMarker : __expectString ( output . NextMarker ) , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1ListResourceTagsResponse = ( output , context ) : ListResourceTagsResponse => { return { NextMarker : __expectString ( output . NextMarker ) , Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_1TagList ( output . Tags , context ) : undefined , Truncated : __expectBoolean ( output . Truncated ) , } as any ; } ; const deserializeAws_json1_1MalformedPolicyDocumentException = ( output , context ) : MalformedPolicyDocumentException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1MultiRegionConfiguration = ( output , context ) : MultiRegionConfiguration => { return { MultiRegionKeyType : __expectString ( output . MultiRegionKeyType ) , PrimaryKey : output . PrimaryKey !== undefined && output . PrimaryKey !== null ? deserializeAws_json1_1MultiRegionKey ( output . PrimaryKey , context ) : undefined , ReplicaKeys : output . ReplicaKeys !== undefined && output . ReplicaKeys !== null ? deserializeAws_json1_1MultiRegionKeyList ( output . ReplicaKeys , context ) : undefined , } as any ; } ; const deserializeAws_json1_1MultiRegionKey = ( output , context ) : MultiRegionKey => { return { Arn : __expectString ( output . Arn ) , Region : __expectString ( output . Region ) , } as any ; } ; const deserializeAws_json1_1MultiRegionKeyList = ( output , context ) : MultiRegionKey [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1MultiRegionKey ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1NotFoundException = ( output , context ) : NotFoundException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1PolicyNameList = ( 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_1ReEncryptResponse = ( output , context ) : ReEncryptResponse => { return { CiphertextBlob : output . CiphertextBlob !== undefined && output . CiphertextBlob !== null ? context . base64Decoder ( output . CiphertextBlob ) : undefined , DestinationEncryptionAlgorithm : __expectString ( output . DestinationEncryptionAlgorithm ) , KeyId : __expectString ( output . KeyId ) , SourceEncryptionAlgorithm : __expectString ( output . SourceEncryptionAlgorithm ) , SourceKeyId : __expectString ( output . SourceKeyId ) , } as any ; } ; const deserializeAws_json1_1ReplicateKeyResponse = ( output , context ) : ReplicateKeyResponse => { return { ReplicaKeyMetadata : output . ReplicaKeyMetadata !== undefined && output . ReplicaKeyMetadata !== null ? deserializeAws_json1_1KeyMetadata ( output . ReplicaKeyMetadata , context ) : undefined , ReplicaPolicy : __expectString ( output . ReplicaPolicy ) , ReplicaTags : output . ReplicaTags !== undefined && output . ReplicaTags !== null ? deserializeAws_json1_1TagList ( output . ReplicaTags , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ScheduleKeyDeletionResponse = ( output , context ) : ScheduleKeyDeletionResponse => { return { DeletionDate : output . DeletionDate !== undefined && output . DeletionDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . DeletionDate ) ) ) : undefined , KeyId : __expectString ( output . KeyId ) , KeyState : __expectString ( output . KeyState ) , PendingWindowInDays : __expectInt32 ( output . PendingWindowInDays ) , } as any ; } ; const deserializeAws_json1_1SigningAlgorithmSpecList = ( output , context ) : ( SigningAlgorithmSpec | string ) [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_json1_1SignResponse = ( output , context ) : SignResponse => { return { KeyId : __expectString ( output . KeyId ) , Signature : output . Signature !== undefined && output . Signature !== null ? context . base64Decoder ( output . Signature ) : undefined , SigningAlgorithm : __expectString ( output . SigningAlgorithm ) , } as any ; } ; const deserializeAws_json1_1Tag = ( output , context ) : Tag => { return { TagKey : __expectString ( output . TagKey ) , TagValue : __expectString ( output . TagValue ) , } as any ; } ; const deserializeAws_json1_1TagException = ( output , context ) : TagException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1UnsupportedOperationException = ( output , context ) : UnsupportedOperationException => { return { message : __expectString ( output . message ) , } as any ; } ; const deserializeAws_json1_1UpdateCustomKeyStoreResponse = ( output , context ) : UpdateCustomKeyStoreResponse => { return { } as any ; } ; const deserializeAws_json1_1VerifyResponse = ( output , context ) : VerifyResponse => { return { KeyId : __expectString ( output . KeyId ) , SignatureValid : __expectBoolean ( output . SignatureValid ) , SigningAlgorithm : __expectString ( output . SigningAlgorithm ) , } as any ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const buildHttpRpcRequest = async ( context , headers , path , resolvedHostname , body ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const contents = { protocol , hostname , port , method : "POST" , path : basePath . endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) + path : basePath + path , headers , } ; if ( resolvedHostname !== undefined ) { contents . hostname = resolvedHostname ; } if ( body !== undefined ) { contents . body = body ; } return new __HttpRequest ( contents ) ; } ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;