import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse , isValidHostname as __isValidHostname , } from "@aws-sdk/protocol-http" ; import { expectInt32 as __expectInt32 , expectLong as __expectLong , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectString as __expectString , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , HeaderBag as __HeaderBag , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { v4 as generateIdempotencyToken } from "uuid" ; import { CreateHttpNamespaceCommandInput , CreateHttpNamespaceCommandOutput , } from "../commands/CreateHttpNamespaceCommand" ; import { CreatePrivateDnsNamespaceCommandInput , CreatePrivateDnsNamespaceCommandOutput , } from "../commands/CreatePrivateDnsNamespaceCommand" ; import { CreatePublicDnsNamespaceCommandInput , CreatePublicDnsNamespaceCommandOutput , } from "../commands/CreatePublicDnsNamespaceCommand" ; import { CreateServiceCommandInput , CreateServiceCommandOutput } from "../commands/CreateServiceCommand" ; import { DeleteNamespaceCommandInput , DeleteNamespaceCommandOutput } from "../commands/DeleteNamespaceCommand" ; import { DeleteServiceCommandInput , DeleteServiceCommandOutput } from "../commands/DeleteServiceCommand" ; import { DeregisterInstanceCommandInput , DeregisterInstanceCommandOutput } from "../commands/DeregisterInstanceCommand" ; import { DiscoverInstancesCommandInput , DiscoverInstancesCommandOutput } from "../commands/DiscoverInstancesCommand" ; import { GetInstanceCommandInput , GetInstanceCommandOutput } from "../commands/GetInstanceCommand" ; import { GetInstancesHealthStatusCommandInput , GetInstancesHealthStatusCommandOutput , } from "../commands/GetInstancesHealthStatusCommand" ; import { GetNamespaceCommandInput , GetNamespaceCommandOutput } from "../commands/GetNamespaceCommand" ; import { GetOperationCommandInput , GetOperationCommandOutput } from "../commands/GetOperationCommand" ; import { GetServiceCommandInput , GetServiceCommandOutput } from "../commands/GetServiceCommand" ; import { ListInstancesCommandInput , ListInstancesCommandOutput } from "../commands/ListInstancesCommand" ; import { ListNamespacesCommandInput , ListNamespacesCommandOutput } from "../commands/ListNamespacesCommand" ; import { ListOperationsCommandInput , ListOperationsCommandOutput } from "../commands/ListOperationsCommand" ; import { ListServicesCommandInput , ListServicesCommandOutput } from "../commands/ListServicesCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { RegisterInstanceCommandInput , RegisterInstanceCommandOutput } from "../commands/RegisterInstanceCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateHttpNamespaceCommandInput , UpdateHttpNamespaceCommandOutput , } from "../commands/UpdateHttpNamespaceCommand" ; import { UpdateInstanceCustomHealthStatusCommandInput , UpdateInstanceCustomHealthStatusCommandOutput , } from "../commands/UpdateInstanceCustomHealthStatusCommand" ; import { UpdatePrivateDnsNamespaceCommandInput , UpdatePrivateDnsNamespaceCommandOutput , } from "../commands/UpdatePrivateDnsNamespaceCommand" ; import { UpdatePublicDnsNamespaceCommandInput , UpdatePublicDnsNamespaceCommandOutput , } from "../commands/UpdatePublicDnsNamespaceCommand" ; import { UpdateServiceCommandInput , UpdateServiceCommandOutput } from "../commands/UpdateServiceCommand" ; import { CreateHttpNamespaceRequest , CreateHttpNamespaceResponse , CreatePrivateDnsNamespaceRequest , CreatePrivateDnsNamespaceResponse , CreatePublicDnsNamespaceRequest , CreatePublicDnsNamespaceResponse , CreateServiceRequest , CreateServiceResponse , CustomHealthNotFound , DeleteNamespaceRequest , DeleteNamespaceResponse , DeleteServiceRequest , DeleteServiceResponse , DeregisterInstanceRequest , DeregisterInstanceResponse , DiscoverInstancesRequest , DiscoverInstancesResponse , DnsConfig , DnsConfigChange , DnsProperties , DnsRecord , DuplicateRequest , GetInstanceRequest , GetInstanceResponse , GetInstancesHealthStatusRequest , GetInstancesHealthStatusResponse , GetNamespaceRequest , GetNamespaceResponse , GetOperationRequest , GetOperationResponse , GetServiceRequest , GetServiceResponse , HealthCheckConfig , HealthCheckCustomConfig , HealthStatus , HttpInstanceSummary , HttpNamespaceChange , HttpProperties , Instance , InstanceNotFound , InstanceSummary , InvalidInput , ListInstancesRequest , ListInstancesResponse , ListNamespacesRequest , ListNamespacesResponse , ListOperationsRequest , ListOperationsResponse , ListServicesRequest , ListServicesResponse , ListTagsForResourceRequest , ListTagsForResourceResponse , Namespace , NamespaceAlreadyExists , NamespaceFilter , NamespaceNotFound , NamespaceProperties , NamespaceSummary , Operation , OperationFilter , OperationNotFound , OperationSummary , OperationTargetType , PrivateDnsNamespaceChange , PrivateDnsNamespaceProperties , PrivateDnsNamespacePropertiesChange , PrivateDnsPropertiesMutable , PrivateDnsPropertiesMutableChange , PublicDnsNamespaceChange , PublicDnsNamespaceProperties , PublicDnsNamespacePropertiesChange , PublicDnsPropertiesMutable , PublicDnsPropertiesMutableChange , RegisterInstanceRequest , RegisterInstanceResponse , RequestLimitExceeded , ResourceInUse , ResourceLimitExceeded , ResourceNotFoundException , Service , ServiceAlreadyExists , ServiceChange , ServiceFilter , ServiceNotFound , ServiceSummary , SOA , SOAChange , Tag , TagResourceRequest , TagResourceResponse , TooManyTagsException , UntagResourceRequest , UntagResourceResponse , UpdateHttpNamespaceRequest , UpdateHttpNamespaceResponse , UpdateInstanceCustomHealthStatusRequest , UpdatePrivateDnsNamespaceRequest , UpdatePrivateDnsNamespaceResponse , UpdatePublicDnsNamespaceRequest , UpdatePublicDnsNamespaceResponse , UpdateServiceRequest , UpdateServiceResponse , } from "../models/models_0" ; export const serializeAws_json1_1CreateHttpNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.CreateHttpNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateHttpNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreatePrivateDnsNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.CreatePrivateDnsNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreatePrivateDnsNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreatePublicDnsNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.CreatePublicDnsNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreatePublicDnsNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1CreateServiceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.CreateService" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1CreateServiceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.DeleteNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeleteServiceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.DeleteService" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeleteServiceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DeregisterInstanceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.DeregisterInstance" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DeregisterInstanceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1DiscoverInstancesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.DiscoverInstances" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1DiscoverInstancesRequest ( input , context ) ) ; let { hostname : resolvedHostname } = await context . endpoint ( ) ; if ( context . disableHostPrefix !== true ) { resolvedHostname = "data-" + resolvedHostname ; if ( ! __isValidHostname ( resolvedHostname ) ) { throw new Error ( "ValidationError: prefixed hostname must be hostname compatible." ) ; } } return buildHttpRpcRequest ( context , headers , "/" , resolvedHostname , body ) ; } ; export const serializeAws_json1_1GetInstanceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.GetInstance" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetInstanceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetInstancesHealthStatusCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.GetInstancesHealthStatus" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetInstancesHealthStatusRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.GetNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetOperationCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.GetOperation" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetOperationRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1GetServiceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.GetService" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1GetServiceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListInstancesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.ListInstances" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListInstancesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListNamespacesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.ListNamespaces" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListNamespacesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListOperationsCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.ListOperations" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListOperationsRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListServicesCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.ListServices" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListServicesRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.ListTagsForResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1ListTagsForResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1RegisterInstanceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.RegisterInstance" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1RegisterInstanceRequest ( 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" : "Route53AutoNaming_v20170314.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" : "Route53AutoNaming_v20170314.UntagResource" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UntagResourceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateHttpNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.UpdateHttpNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateHttpNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateInstanceCustomHealthStatusCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.UpdateInstanceCustomHealthStatus" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateInstanceCustomHealthStatusRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdatePrivateDnsNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.UpdatePrivateDnsNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdatePrivateDnsNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdatePublicDnsNamespaceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.UpdatePublicDnsNamespace" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdatePublicDnsNamespaceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const serializeAws_json1_1UpdateServiceCommand = async ( input , context ) : Promise < __HttpRequest > => { const headers = { "content-type" : "application/x-amz-json-1.1" , "x-amz-target" : "Route53AutoNaming_v20170314.UpdateService" , } ; let body ; body = JSON . stringify ( serializeAws_json1_1UpdateServiceRequest ( input , context ) ) ; return buildHttpRpcRequest ( context , headers , "/" , undefined , body ) ; } ; export const deserializeAws_json1_1CreateHttpNamespaceCommand = async ( output , context ) : Promise < CreateHttpNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateHttpNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateHttpNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateHttpNamespaceCommandError = async ( output , context ) : Promise < CreateHttpNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceAlreadyExists" : case "com.amazonaws.servicediscovery#NamespaceAlreadyExists" : response = { ... ( await deserializeAws_json1_1NamespaceAlreadyExistsResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceLimitExceeded" : case "com.amazonaws.servicediscovery#ResourceLimitExceeded" : response = { ... ( await deserializeAws_json1_1ResourceLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.servicediscovery#TooManyTagsException" : response = { ... ( await deserializeAws_json1_1TooManyTagsExceptionResponse ( 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_1CreatePrivateDnsNamespaceCommand = async ( output , context ) : Promise < CreatePrivateDnsNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreatePrivateDnsNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreatePrivateDnsNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreatePrivateDnsNamespaceCommandError = async ( output , context ) : Promise < CreatePrivateDnsNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceAlreadyExists" : case "com.amazonaws.servicediscovery#NamespaceAlreadyExists" : response = { ... ( await deserializeAws_json1_1NamespaceAlreadyExistsResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceLimitExceeded" : case "com.amazonaws.servicediscovery#ResourceLimitExceeded" : response = { ... ( await deserializeAws_json1_1ResourceLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.servicediscovery#TooManyTagsException" : response = { ... ( await deserializeAws_json1_1TooManyTagsExceptionResponse ( 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_1CreatePublicDnsNamespaceCommand = async ( output , context ) : Promise < CreatePublicDnsNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreatePublicDnsNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreatePublicDnsNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreatePublicDnsNamespaceCommandError = async ( output , context ) : Promise < CreatePublicDnsNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceAlreadyExists" : case "com.amazonaws.servicediscovery#NamespaceAlreadyExists" : response = { ... ( await deserializeAws_json1_1NamespaceAlreadyExistsResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceLimitExceeded" : case "com.amazonaws.servicediscovery#ResourceLimitExceeded" : response = { ... ( await deserializeAws_json1_1ResourceLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.servicediscovery#TooManyTagsException" : response = { ... ( await deserializeAws_json1_1TooManyTagsExceptionResponse ( 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_1CreateServiceCommand = async ( output , context ) : Promise < CreateServiceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1CreateServiceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1CreateServiceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1CreateServiceCommandError = async ( output , context ) : Promise < CreateServiceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceLimitExceeded" : case "com.amazonaws.servicediscovery#ResourceLimitExceeded" : response = { ... ( await deserializeAws_json1_1ResourceLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceAlreadyExists" : case "com.amazonaws.servicediscovery#ServiceAlreadyExists" : response = { ... ( await deserializeAws_json1_1ServiceAlreadyExistsResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.servicediscovery#TooManyTagsException" : response = { ... ( await deserializeAws_json1_1TooManyTagsExceptionResponse ( 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_1DeleteNamespaceCommand = async ( output , context ) : Promise < DeleteNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteNamespaceCommandError = async ( output , context ) : Promise < DeleteNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( 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_1DeleteServiceCommand = async ( output , context ) : Promise < DeleteServiceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeleteServiceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeleteServiceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeleteServiceCommandError = async ( output , context ) : Promise < DeleteServiceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1DeregisterInstanceCommand = async ( output , context ) : Promise < DeregisterInstanceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DeregisterInstanceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DeregisterInstanceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DeregisterInstanceCommandError = async ( output , context ) : Promise < DeregisterInstanceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InstanceNotFound" : case "com.amazonaws.servicediscovery#InstanceNotFound" : response = { ... ( await deserializeAws_json1_1InstanceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1DiscoverInstancesCommand = async ( output , context ) : Promise < DiscoverInstancesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1DiscoverInstancesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1DiscoverInstancesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1DiscoverInstancesCommandError = async ( output , context ) : Promise < DiscoverInstancesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "RequestLimitExceeded" : case "com.amazonaws.servicediscovery#RequestLimitExceeded" : response = { ... ( await deserializeAws_json1_1RequestLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1GetInstanceCommand = async ( output , context ) : Promise < GetInstanceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetInstanceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetInstanceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetInstanceCommandError = async ( output , context ) : Promise < GetInstanceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InstanceNotFound" : case "com.amazonaws.servicediscovery#InstanceNotFound" : response = { ... ( await deserializeAws_json1_1InstanceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1GetInstancesHealthStatusCommand = async ( output , context ) : Promise < GetInstancesHealthStatusCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetInstancesHealthStatusCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetInstancesHealthStatusResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetInstancesHealthStatusCommandError = async ( output , context ) : Promise < GetInstancesHealthStatusCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InstanceNotFound" : case "com.amazonaws.servicediscovery#InstanceNotFound" : response = { ... ( await deserializeAws_json1_1InstanceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1GetNamespaceCommand = async ( output , context ) : Promise < GetNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetNamespaceCommandError = async ( output , context ) : Promise < GetNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( 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_1GetOperationCommand = async ( output , context ) : Promise < GetOperationCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetOperationCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetOperationResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetOperationCommandError = async ( output , context ) : Promise < GetOperationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotFound" : case "com.amazonaws.servicediscovery#OperationNotFound" : response = { ... ( await deserializeAws_json1_1OperationNotFoundResponse ( 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_1GetServiceCommand = async ( output , context ) : Promise < GetServiceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1GetServiceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1GetServiceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1GetServiceCommandError = async ( output , context ) : Promise < GetServiceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1ListInstancesCommand = async ( output , context ) : Promise < ListInstancesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListInstancesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListInstancesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListInstancesCommandError = async ( output , context ) : Promise < ListInstancesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1ListNamespacesCommand = async ( output , context ) : Promise < ListNamespacesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListNamespacesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListNamespacesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListNamespacesCommandError = async ( output , context ) : Promise < ListNamespacesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( 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_1ListOperationsCommand = async ( output , context ) : Promise < ListOperationsCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListOperationsCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListOperationsResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListOperationsCommandError = async ( output , context ) : Promise < ListOperationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( 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_1ListServicesCommand = async ( output , context ) : Promise < ListServicesCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListServicesCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListServicesResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListServicesCommandError = async ( output , context ) : Promise < ListServicesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1ListTagsForResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1ListTagsForResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.servicediscovery#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1RegisterInstanceCommand = async ( output , context ) : Promise < RegisterInstanceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1RegisterInstanceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1RegisterInstanceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1RegisterInstanceCommandError = async ( output , context ) : Promise < RegisterInstanceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceLimitExceeded" : case "com.amazonaws.servicediscovery#ResourceLimitExceeded" : response = { ... ( await deserializeAws_json1_1ResourceLimitExceededResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1TagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1TagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.servicediscovery#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.servicediscovery#TooManyTagsException" : response = { ... ( await deserializeAws_json1_1TooManyTagsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UntagResourceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UntagResourceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.servicediscovery#ResourceNotFoundException" : response = { ... ( await deserializeAws_json1_1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_json1_1UpdateHttpNamespaceCommand = async ( output , context ) : Promise < UpdateHttpNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateHttpNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateHttpNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateHttpNamespaceCommandError = async ( output , context ) : Promise < UpdateHttpNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( 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_1UpdateInstanceCustomHealthStatusCommand = async ( output , context ) : Promise < UpdateInstanceCustomHealthStatusCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateInstanceCustomHealthStatusCommandError ( output , context ) ; } await collectBody ( output . body , context ) ; const response = { $metadata : deserializeMetadata ( output ) , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateInstanceCustomHealthStatusCommandError = async ( output , context ) : Promise < UpdateInstanceCustomHealthStatusCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "CustomHealthNotFound" : case "com.amazonaws.servicediscovery#CustomHealthNotFound" : response = { ... ( await deserializeAws_json1_1CustomHealthNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InstanceNotFound" : case "com.amazonaws.servicediscovery#InstanceNotFound" : response = { ... ( await deserializeAws_json1_1InstanceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1UpdatePrivateDnsNamespaceCommand = async ( output , context ) : Promise < UpdatePrivateDnsNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdatePrivateDnsNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdatePrivateDnsNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdatePrivateDnsNamespaceCommandError = async ( output , context ) : Promise < UpdatePrivateDnsNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( 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_1UpdatePublicDnsNamespaceCommand = async ( output , context ) : Promise < UpdatePublicDnsNamespaceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdatePublicDnsNamespaceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdatePublicDnsNamespaceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdatePublicDnsNamespaceCommandError = async ( output , context ) : Promise < UpdatePublicDnsNamespaceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "NamespaceNotFound" : case "com.amazonaws.servicediscovery#NamespaceNotFound" : response = { ... ( await deserializeAws_json1_1NamespaceNotFoundResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceInUse" : case "com.amazonaws.servicediscovery#ResourceInUse" : response = { ... ( await deserializeAws_json1_1ResourceInUseResponse ( 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_1UpdateServiceCommand = async ( output , context ) : Promise < UpdateServiceCommandOutput > => { if ( output . statusCode >= 300 ) { return deserializeAws_json1_1UpdateServiceCommandError ( output , context ) ; } const data = await parseBody ( output . body , context ) ; let contents = { } ; contents = deserializeAws_json1_1UpdateServiceResponse ( data , context ) ; const response = { $metadata : deserializeMetadata ( output ) , ... contents , } ; return Promise . resolve ( response ) ; } ; const deserializeAws_json1_1UpdateServiceCommandError = async ( output , context ) : Promise < UpdateServiceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "DuplicateRequest" : case "com.amazonaws.servicediscovery#DuplicateRequest" : response = { ... ( await deserializeAws_json1_1DuplicateRequestResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidInput" : case "com.amazonaws.servicediscovery#InvalidInput" : response = { ... ( await deserializeAws_json1_1InvalidInputResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceNotFound" : case "com.amazonaws.servicediscovery#ServiceNotFound" : response = { ... ( await deserializeAws_json1_1ServiceNotFoundResponse ( 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_1CustomHealthNotFoundResponse = async ( parsedOutput , context ) : Promise < CustomHealthNotFound > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1CustomHealthNotFound ( body , context ) ; const contents = { name : "CustomHealthNotFound" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1DuplicateRequestResponse = async ( parsedOutput , context ) : Promise < DuplicateRequest > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1DuplicateRequest ( body , context ) ; const contents = { name : "DuplicateRequest" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InstanceNotFoundResponse = async ( parsedOutput , context ) : Promise < InstanceNotFound > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InstanceNotFound ( body , context ) ; const contents = { name : "InstanceNotFound" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1InvalidInputResponse = async ( parsedOutput , context ) : Promise < InvalidInput > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1InvalidInput ( body , context ) ; const contents = { name : "InvalidInput" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1NamespaceAlreadyExistsResponse = async ( parsedOutput , context ) : Promise < NamespaceAlreadyExists > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1NamespaceAlreadyExists ( body , context ) ; const contents = { name : "NamespaceAlreadyExists" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1NamespaceNotFoundResponse = async ( parsedOutput , context ) : Promise < NamespaceNotFound > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1NamespaceNotFound ( body , context ) ; const contents = { name : "NamespaceNotFound" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1OperationNotFoundResponse = async ( parsedOutput , context ) : Promise < OperationNotFound > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1OperationNotFound ( body , context ) ; const contents = { name : "OperationNotFound" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1RequestLimitExceededResponse = async ( parsedOutput , context ) : Promise < RequestLimitExceeded > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1RequestLimitExceeded ( body , context ) ; const contents = { name : "RequestLimitExceeded" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceInUseResponse = async ( parsedOutput , context ) : Promise < ResourceInUse > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceInUse ( body , context ) ; const contents = { name : "ResourceInUse" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceLimitExceededResponse = async ( parsedOutput , context ) : Promise < ResourceLimitExceeded > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceLimitExceeded ( body , context ) ; const contents = { name : "ResourceLimitExceeded" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ResourceNotFoundException ( body , context ) ; const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ServiceAlreadyExistsResponse = async ( parsedOutput , context ) : Promise < ServiceAlreadyExists > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ServiceAlreadyExists ( body , context ) ; const contents = { name : "ServiceAlreadyExists" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1ServiceNotFoundResponse = async ( parsedOutput , context ) : Promise < ServiceNotFound > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1ServiceNotFound ( body , context ) ; const contents = { name : "ServiceNotFound" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const deserializeAws_json1_1TooManyTagsExceptionResponse = async ( parsedOutput , context ) : Promise < TooManyTagsException > => { const body = parsedOutput . body ; const deserialized = deserializeAws_json1_1TooManyTagsException ( body , context ) ; const contents = { name : "TooManyTagsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , ... deserialized , } ; return contents ; } ; const serializeAws_json1_1Attributes = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_json1_1CreateHttpNamespaceRequest = ( input , context ) : any => { return { CreatorRequestId : input . CreatorRequestId ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1CreatePrivateDnsNamespaceRequest = ( input , context ) : any => { return { CreatorRequestId : input . CreatorRequestId ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Properties !== undefined && input . Properties !== null && { Properties : serializeAws_json1_1PrivateDnsNamespaceProperties ( input . Properties , context ) , } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , ... ( input . Vpc !== undefined && input . Vpc !== null && { Vpc : input . Vpc } ) , } ; } ; const serializeAws_json1_1CreatePublicDnsNamespaceRequest = ( input , context ) : any => { return { CreatorRequestId : input . CreatorRequestId ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Properties !== undefined && input . Properties !== null && { Properties : serializeAws_json1_1PublicDnsNamespaceProperties ( input . Properties , context ) , } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1CreateServiceRequest = ( input , context ) : any => { return { CreatorRequestId : input . CreatorRequestId ?? generateIdempotencyToken ( ) , ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . DnsConfig !== undefined && input . DnsConfig !== null && { DnsConfig : serializeAws_json1_1DnsConfig ( input . DnsConfig , context ) } ) , ... ( input . HealthCheckConfig !== undefined && input . HealthCheckConfig !== null && { HealthCheckConfig : serializeAws_json1_1HealthCheckConfig ( input . HealthCheckConfig , context ) , } ) , ... ( input . HealthCheckCustomConfig !== undefined && input . HealthCheckCustomConfig !== null && { HealthCheckCustomConfig : serializeAws_json1_1HealthCheckCustomConfig ( input . HealthCheckCustomConfig , context ) , } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . NamespaceId !== undefined && input . NamespaceId !== null && { NamespaceId : input . NamespaceId } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , ... ( input . Type !== undefined && input . Type !== null && { Type : input . Type } ) , } ; } ; const serializeAws_json1_1DeleteNamespaceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , } ; } ; const serializeAws_json1_1DeleteServiceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , } ; } ; const serializeAws_json1_1DeregisterInstanceRequest = ( input , context ) : any => { return { ... ( input . InstanceId !== undefined && input . InstanceId !== null && { InstanceId : input . InstanceId } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , } ; } ; const serializeAws_json1_1DiscoverInstancesRequest = ( input , context ) : any => { return { ... ( input . HealthStatus !== undefined && input . HealthStatus !== null && { HealthStatus : input . HealthStatus } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NamespaceName !== undefined && input . NamespaceName !== null && { NamespaceName : input . NamespaceName } ) , ... ( input . OptionalParameters !== undefined && input . OptionalParameters !== null && { OptionalParameters : serializeAws_json1_1Attributes ( input . OptionalParameters , context ) , } ) , ... ( input . QueryParameters !== undefined && input . QueryParameters !== null && { QueryParameters : serializeAws_json1_1Attributes ( input . QueryParameters , context ) , } ) , ... ( input . ServiceName !== undefined && input . ServiceName !== null && { ServiceName : input . ServiceName } ) , } ; } ; const serializeAws_json1_1DnsConfig = ( input , context ) : any => { return { ... ( input . DnsRecords !== undefined && input . DnsRecords !== null && { DnsRecords : serializeAws_json1_1DnsRecordList ( input . DnsRecords , context ) } ) , ... ( input . NamespaceId !== undefined && input . NamespaceId !== null && { NamespaceId : input . NamespaceId } ) , ... ( input . RoutingPolicy !== undefined && input . RoutingPolicy !== null && { RoutingPolicy : input . RoutingPolicy } ) , } ; } ; const serializeAws_json1_1DnsConfigChange = ( input , context ) : any => { return { ... ( input . DnsRecords !== undefined && input . DnsRecords !== null && { DnsRecords : serializeAws_json1_1DnsRecordList ( input . DnsRecords , context ) } ) , } ; } ; const serializeAws_json1_1DnsRecord = ( input , context ) : any => { return { ... ( input . TTL !== undefined && input . TTL !== null && { TTL : input . TTL } ) , ... ( input . Type !== undefined && input . Type !== null && { Type : input . Type } ) , } ; } ; const serializeAws_json1_1DnsRecordList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1DnsRecord ( entry , context ) ; } ) ; } ; const serializeAws_json1_1FilterValues = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1GetInstanceRequest = ( input , context ) : any => { return { ... ( input . InstanceId !== undefined && input . InstanceId !== null && { InstanceId : input . InstanceId } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , } ; } ; const serializeAws_json1_1GetInstancesHealthStatusRequest = ( input , context ) : any => { return { ... ( input . Instances !== undefined && input . Instances !== null && { Instances : serializeAws_json1_1InstanceIdList ( input . Instances , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , } ; } ; const serializeAws_json1_1GetNamespaceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , } ; } ; const serializeAws_json1_1GetOperationRequest = ( input , context ) : any => { return { ... ( input . OperationId !== undefined && input . OperationId !== null && { OperationId : input . OperationId } ) , } ; } ; const serializeAws_json1_1GetServiceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , } ; } ; const serializeAws_json1_1HealthCheckConfig = ( input , context ) : any => { return { ... ( input . FailureThreshold !== undefined && input . FailureThreshold !== null && { FailureThreshold : input . FailureThreshold } ) , ... ( input . ResourcePath !== undefined && input . ResourcePath !== null && { ResourcePath : input . ResourcePath } ) , ... ( input . Type !== undefined && input . Type !== null && { Type : input . Type } ) , } ; } ; const serializeAws_json1_1HealthCheckCustomConfig = ( input , context ) : any => { return { ... ( input . FailureThreshold !== undefined && input . FailureThreshold !== null && { FailureThreshold : input . FailureThreshold } ) , } ; } ; const serializeAws_json1_1HttpNamespaceChange = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , } ; } ; const serializeAws_json1_1InstanceIdList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1ListInstancesRequest = ( input , context ) : any => { return { ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , } ; } ; const serializeAws_json1_1ListNamespacesRequest = ( input , context ) : any => { return { ... ( input . Filters !== undefined && input . Filters !== null && { Filters : serializeAws_json1_1NamespaceFilters ( input . Filters , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1ListOperationsRequest = ( input , context ) : any => { return { ... ( input . Filters !== undefined && input . Filters !== null && { Filters : serializeAws_json1_1OperationFilters ( input . Filters , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1ListServicesRequest = ( input , context ) : any => { return { ... ( input . Filters !== undefined && input . Filters !== null && { Filters : serializeAws_json1_1ServiceFilters ( input . Filters , context ) } ) , ... ( input . MaxResults !== undefined && input . MaxResults !== null && { MaxResults : input . MaxResults } ) , ... ( input . NextToken !== undefined && input . NextToken !== null && { NextToken : input . NextToken } ) , } ; } ; const serializeAws_json1_1ListTagsForResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , } ; } ; const serializeAws_json1_1NamespaceFilter = ( input , context ) : any => { return { ... ( input . Condition !== undefined && input . Condition !== null && { Condition : input . Condition } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Values !== undefined && input . Values !== null && { Values : serializeAws_json1_1FilterValues ( input . Values , context ) } ) , } ; } ; const serializeAws_json1_1NamespaceFilters = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1NamespaceFilter ( entry , context ) ; } ) ; } ; const serializeAws_json1_1OperationFilter = ( input , context ) : any => { return { ... ( input . Condition !== undefined && input . Condition !== null && { Condition : input . Condition } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Values !== undefined && input . Values !== null && { Values : serializeAws_json1_1FilterValues ( input . Values , context ) } ) , } ; } ; const serializeAws_json1_1OperationFilters = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1OperationFilter ( entry , context ) ; } ) ; } ; const serializeAws_json1_1PrivateDnsNamespaceChange = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . Properties !== undefined && input . Properties !== null && { Properties : serializeAws_json1_1PrivateDnsNamespacePropertiesChange ( input . Properties , context ) , } ) , } ; } ; const serializeAws_json1_1PrivateDnsNamespaceProperties = ( input , context ) : any => { return { ... ( input . DnsProperties !== undefined && input . DnsProperties !== null && { DnsProperties : serializeAws_json1_1PrivateDnsPropertiesMutable ( input . DnsProperties , context ) , } ) , } ; } ; const serializeAws_json1_1PrivateDnsNamespacePropertiesChange = ( input , context ) : any => { return { ... ( input . DnsProperties !== undefined && input . DnsProperties !== null && { DnsProperties : serializeAws_json1_1PrivateDnsPropertiesMutableChange ( input . DnsProperties , context ) , } ) , } ; } ; const serializeAws_json1_1PrivateDnsPropertiesMutable = ( input , context ) : any => { return { ... ( input . SOA !== undefined && input . SOA !== null && { SOA : serializeAws_json1_1SOA ( input . SOA , context ) } ) , } ; } ; const serializeAws_json1_1PrivateDnsPropertiesMutableChange = ( input , context ) : any => { return { ... ( input . SOA !== undefined && input . SOA !== null && { SOA : serializeAws_json1_1SOAChange ( input . SOA , context ) } ) , } ; } ; const serializeAws_json1_1PublicDnsNamespaceChange = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . Properties !== undefined && input . Properties !== null && { Properties : serializeAws_json1_1PublicDnsNamespacePropertiesChange ( input . Properties , context ) , } ) , } ; } ; const serializeAws_json1_1PublicDnsNamespaceProperties = ( input , context ) : any => { return { ... ( input . DnsProperties !== undefined && input . DnsProperties !== null && { DnsProperties : serializeAws_json1_1PublicDnsPropertiesMutable ( input . DnsProperties , context ) , } ) , } ; } ; const serializeAws_json1_1PublicDnsNamespacePropertiesChange = ( input , context ) : any => { return { ... ( input . DnsProperties !== undefined && input . DnsProperties !== null && { DnsProperties : serializeAws_json1_1PublicDnsPropertiesMutableChange ( input . DnsProperties , context ) , } ) , } ; } ; const serializeAws_json1_1PublicDnsPropertiesMutable = ( input , context ) : any => { return { ... ( input . SOA !== undefined && input . SOA !== null && { SOA : serializeAws_json1_1SOA ( input . SOA , context ) } ) , } ; } ; const serializeAws_json1_1PublicDnsPropertiesMutableChange = ( input , context ) : any => { return { ... ( input . SOA !== undefined && input . SOA !== null && { SOA : serializeAws_json1_1SOAChange ( input . SOA , context ) } ) , } ; } ; const serializeAws_json1_1RegisterInstanceRequest = ( input , context ) : any => { return { ... ( input . Attributes !== undefined && input . Attributes !== null && { Attributes : serializeAws_json1_1Attributes ( input . Attributes , context ) } ) , CreatorRequestId : input . CreatorRequestId ?? generateIdempotencyToken ( ) , ... ( input . InstanceId !== undefined && input . InstanceId !== null && { InstanceId : input . InstanceId } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , } ; } ; const serializeAws_json1_1ServiceChange = ( input , context ) : any => { return { ... ( input . Description !== undefined && input . Description !== null && { Description : input . Description } ) , ... ( input . DnsConfig !== undefined && input . DnsConfig !== null && { DnsConfig : serializeAws_json1_1DnsConfigChange ( input . DnsConfig , context ) } ) , ... ( input . HealthCheckConfig !== undefined && input . HealthCheckConfig !== null && { HealthCheckConfig : serializeAws_json1_1HealthCheckConfig ( input . HealthCheckConfig , context ) , } ) , } ; } ; const serializeAws_json1_1ServiceFilter = ( input , context ) : any => { return { ... ( input . Condition !== undefined && input . Condition !== null && { Condition : input . Condition } ) , ... ( input . Name !== undefined && input . Name !== null && { Name : input . Name } ) , ... ( input . Values !== undefined && input . Values !== null && { Values : serializeAws_json1_1FilterValues ( input . Values , context ) } ) , } ; } ; const serializeAws_json1_1ServiceFilters = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1ServiceFilter ( entry , context ) ; } ) ; } ; const serializeAws_json1_1SOA = ( input , context ) : any => { return { ... ( input . TTL !== undefined && input . TTL !== null && { TTL : input . TTL } ) , } ; } ; const serializeAws_json1_1SOAChange = ( input , context ) : any => { return { ... ( input . TTL !== undefined && input . TTL !== null && { TTL : input . TTL } ) , } ; } ; const serializeAws_json1_1Tag = ( input , context ) : any => { return { ... ( input . Key !== undefined && input . Key !== null && { Key : input . Key } ) , ... ( input . Value !== undefined && input . Value !== null && { Value : input . Value } ) , } ; } ; const serializeAws_json1_1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_json1_1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const serializeAws_json1_1TagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . Tags !== undefined && input . Tags !== null && { Tags : serializeAws_json1_1TagList ( input . Tags , context ) } ) , } ; } ; const serializeAws_json1_1UntagResourceRequest = ( input , context ) : any => { return { ... ( input . ResourceARN !== undefined && input . ResourceARN !== null && { ResourceARN : input . ResourceARN } ) , ... ( input . TagKeys !== undefined && input . TagKeys !== null && { TagKeys : serializeAws_json1_1TagKeyList ( input . TagKeys , context ) } ) , } ; } ; const serializeAws_json1_1UpdateHttpNamespaceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , ... ( input . Namespace !== undefined && input . Namespace !== null && { Namespace : serializeAws_json1_1HttpNamespaceChange ( input . Namespace , context ) } ) , UpdaterRequestId : input . UpdaterRequestId ?? generateIdempotencyToken ( ) , } ; } ; const serializeAws_json1_1UpdateInstanceCustomHealthStatusRequest = ( input , context ) : any => { return { ... ( input . InstanceId !== undefined && input . InstanceId !== null && { InstanceId : input . InstanceId } ) , ... ( input . ServiceId !== undefined && input . ServiceId !== null && { ServiceId : input . ServiceId } ) , ... ( input . Status !== undefined && input . Status !== null && { Status : input . Status } ) , } ; } ; const serializeAws_json1_1UpdatePrivateDnsNamespaceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , ... ( input . Namespace !== undefined && input . Namespace !== null && { Namespace : serializeAws_json1_1PrivateDnsNamespaceChange ( input . Namespace , context ) , } ) , UpdaterRequestId : input . UpdaterRequestId ?? generateIdempotencyToken ( ) , } ; } ; const serializeAws_json1_1UpdatePublicDnsNamespaceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , ... ( input . Namespace !== undefined && input . Namespace !== null && { Namespace : serializeAws_json1_1PublicDnsNamespaceChange ( input . Namespace , context ) , } ) , UpdaterRequestId : input . UpdaterRequestId ?? generateIdempotencyToken ( ) , } ; } ; const serializeAws_json1_1UpdateServiceRequest = ( input , context ) : any => { return { ... ( input . Id !== undefined && input . Id !== null && { Id : input . Id } ) , ... ( input . Service !== undefined && input . Service !== null && { Service : serializeAws_json1_1ServiceChange ( input . Service , context ) } ) , } ; } ; const deserializeAws_json1_1Attributes = ( 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_1CreateHttpNamespaceResponse = ( output , context ) : CreateHttpNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1CreatePrivateDnsNamespaceResponse = ( output , context ) : CreatePrivateDnsNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1CreatePublicDnsNamespaceResponse = ( output , context ) : CreatePublicDnsNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1CreateServiceResponse = ( output , context ) : CreateServiceResponse => { return { Service : output . Service !== undefined && output . Service !== null ? deserializeAws_json1_1Service ( output . Service , context ) : undefined , } as any ; } ; const deserializeAws_json1_1CustomHealthNotFound = ( output , context ) : CustomHealthNotFound => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1DeleteNamespaceResponse = ( output , context ) : DeleteNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1DeleteServiceResponse = ( output , context ) : DeleteServiceResponse => { return { } as any ; } ; const deserializeAws_json1_1DeregisterInstanceResponse = ( output , context ) : DeregisterInstanceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1DiscoverInstancesResponse = ( output , context ) : DiscoverInstancesResponse => { return { Instances : output . Instances !== undefined && output . Instances !== null ? deserializeAws_json1_1HttpInstanceSummaryList ( output . Instances , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DnsConfig = ( output , context ) : DnsConfig => { return { DnsRecords : output . DnsRecords !== undefined && output . DnsRecords !== null ? deserializeAws_json1_1DnsRecordList ( output . DnsRecords , context ) : undefined , NamespaceId : __expectString ( output . NamespaceId ) , RoutingPolicy : __expectString ( output . RoutingPolicy ) , } as any ; } ; const deserializeAws_json1_1DnsProperties = ( output , context ) : DnsProperties => { return { HostedZoneId : __expectString ( output . HostedZoneId ) , SOA : output . SOA !== undefined && output . SOA !== null ? deserializeAws_json1_1SOA ( output . SOA , context ) : undefined , } as any ; } ; const deserializeAws_json1_1DnsRecord = ( output , context ) : DnsRecord => { return { TTL : __expectLong ( output . TTL ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1DnsRecordList = ( output , context ) : DnsRecord [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1DnsRecord ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1DuplicateRequest = ( output , context ) : DuplicateRequest => { return { DuplicateOperationId : __expectString ( output . DuplicateOperationId ) , Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1GetInstanceResponse = ( output , context ) : GetInstanceResponse => { return { Instance : output . Instance !== undefined && output . Instance !== null ? deserializeAws_json1_1Instance ( output . Instance , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetInstancesHealthStatusResponse = ( output , context ) : GetInstancesHealthStatusResponse => { return { NextToken : __expectString ( output . NextToken ) , Status : output . Status !== undefined && output . Status !== null ? deserializeAws_json1_1InstanceHealthStatusMap ( output . Status , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetNamespaceResponse = ( output , context ) : GetNamespaceResponse => { return { Namespace : output . Namespace !== undefined && output . Namespace !== null ? deserializeAws_json1_1Namespace ( output . Namespace , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetOperationResponse = ( output , context ) : GetOperationResponse => { return { Operation : output . Operation !== undefined && output . Operation !== null ? deserializeAws_json1_1Operation ( output . Operation , context ) : undefined , } as any ; } ; const deserializeAws_json1_1GetServiceResponse = ( output , context ) : GetServiceResponse => { return { Service : output . Service !== undefined && output . Service !== null ? deserializeAws_json1_1Service ( output . Service , context ) : undefined , } as any ; } ; const deserializeAws_json1_1HealthCheckConfig = ( output , context ) : HealthCheckConfig => { return { FailureThreshold : __expectInt32 ( output . FailureThreshold ) , ResourcePath : __expectString ( output . ResourcePath ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1HealthCheckCustomConfig = ( output , context ) : HealthCheckCustomConfig => { return { FailureThreshold : __expectInt32 ( output . FailureThreshold ) , } as any ; } ; const deserializeAws_json1_1HttpInstanceSummary = ( output , context ) : HttpInstanceSummary => { return { Attributes : output . Attributes !== undefined && output . Attributes !== null ? deserializeAws_json1_1Attributes ( output . Attributes , context ) : undefined , HealthStatus : __expectString ( output . HealthStatus ) , InstanceId : __expectString ( output . InstanceId ) , NamespaceName : __expectString ( output . NamespaceName ) , ServiceName : __expectString ( output . ServiceName ) , } as any ; } ; const deserializeAws_json1_1HttpInstanceSummaryList = ( output , context ) : HttpInstanceSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1HttpInstanceSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1HttpProperties = ( output , context ) : HttpProperties => { return { HttpName : __expectString ( output . HttpName ) , } as any ; } ; const deserializeAws_json1_1Instance = ( output , context ) : Instance => { return { Attributes : output . Attributes !== undefined && output . Attributes !== null ? deserializeAws_json1_1Attributes ( output . Attributes , context ) : undefined , CreatorRequestId : __expectString ( output . CreatorRequestId ) , Id : __expectString ( output . Id ) , } as any ; } ; const deserializeAws_json1_1InstanceHealthStatusMap = ( output , context ) : { [ key ] : HealthStatus | string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_json1_1InstanceNotFound = ( output , context ) : InstanceNotFound => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1InstanceSummary = ( output , context ) : InstanceSummary => { return { Attributes : output . Attributes !== undefined && output . Attributes !== null ? deserializeAws_json1_1Attributes ( output . Attributes , context ) : undefined , Id : __expectString ( output . Id ) , } as any ; } ; const deserializeAws_json1_1InstanceSummaryList = ( output , context ) : InstanceSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1InstanceSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1InvalidInput = ( output , context ) : InvalidInput => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ListInstancesResponse = ( output , context ) : ListInstancesResponse => { return { Instances : output . Instances !== undefined && output . Instances !== null ? deserializeAws_json1_1InstanceSummaryList ( output . Instances , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_1ListNamespacesResponse = ( output , context ) : ListNamespacesResponse => { return { Namespaces : output . Namespaces !== undefined && output . Namespaces !== null ? deserializeAws_json1_1NamespaceSummariesList ( output . Namespaces , context ) : undefined , NextToken : __expectString ( output . NextToken ) , } as any ; } ; const deserializeAws_json1_1ListOperationsResponse = ( output , context ) : ListOperationsResponse => { return { NextToken : __expectString ( output . NextToken ) , Operations : output . Operations !== undefined && output . Operations !== null ? deserializeAws_json1_1OperationSummaryList ( output . Operations , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ListServicesResponse = ( output , context ) : ListServicesResponse => { return { NextToken : __expectString ( output . NextToken ) , Services : output . Services !== undefined && output . Services !== null ? deserializeAws_json1_1ServiceSummariesList ( output . Services , context ) : undefined , } as any ; } ; const deserializeAws_json1_1ListTagsForResourceResponse = ( output , context ) : ListTagsForResourceResponse => { return { Tags : output . Tags !== undefined && output . Tags !== null ? deserializeAws_json1_1TagList ( output . Tags , context ) : undefined , } as any ; } ; const deserializeAws_json1_1Namespace = ( output , context ) : Namespace => { return { Arn : __expectString ( output . Arn ) , CreateDate : output . CreateDate !== undefined && output . CreateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreateDate ) ) ) : undefined , CreatorRequestId : __expectString ( output . CreatorRequestId ) , Description : __expectString ( output . Description ) , Id : __expectString ( output . Id ) , Name : __expectString ( output . Name ) , Properties : output . Properties !== undefined && output . Properties !== null ? deserializeAws_json1_1NamespaceProperties ( output . Properties , context ) : undefined , ServiceCount : __expectInt32 ( output . ServiceCount ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1NamespaceAlreadyExists = ( output , context ) : NamespaceAlreadyExists => { return { CreatorRequestId : __expectString ( output . CreatorRequestId ) , Message : __expectString ( output . Message ) , NamespaceId : __expectString ( output . NamespaceId ) , } as any ; } ; const deserializeAws_json1_1NamespaceNotFound = ( output , context ) : NamespaceNotFound => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1NamespaceProperties = ( output , context ) : NamespaceProperties => { return { DnsProperties : output . DnsProperties !== undefined && output . DnsProperties !== null ? deserializeAws_json1_1DnsProperties ( output . DnsProperties , context ) : undefined , HttpProperties : output . HttpProperties !== undefined && output . HttpProperties !== null ? deserializeAws_json1_1HttpProperties ( output . HttpProperties , context ) : undefined , } as any ; } ; const deserializeAws_json1_1NamespaceSummariesList = ( output , context ) : NamespaceSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1NamespaceSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1NamespaceSummary = ( output , context ) : NamespaceSummary => { return { Arn : __expectString ( output . Arn ) , CreateDate : output . CreateDate !== undefined && output . CreateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreateDate ) ) ) : undefined , Description : __expectString ( output . Description ) , Id : __expectString ( output . Id ) , Name : __expectString ( output . Name ) , Properties : output . Properties !== undefined && output . Properties !== null ? deserializeAws_json1_1NamespaceProperties ( output . Properties , context ) : undefined , ServiceCount : __expectInt32 ( output . ServiceCount ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1Operation = ( output , context ) : Operation => { return { CreateDate : output . CreateDate !== undefined && output . CreateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreateDate ) ) ) : undefined , ErrorCode : __expectString ( output . ErrorCode ) , ErrorMessage : __expectString ( output . ErrorMessage ) , Id : __expectString ( output . Id ) , Status : __expectString ( output . Status ) , Targets : output . Targets !== undefined && output . Targets !== null ? deserializeAws_json1_1OperationTargetsMap ( output . Targets , context ) : undefined , Type : __expectString ( output . Type ) , UpdateDate : output . UpdateDate !== undefined && output . UpdateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . UpdateDate ) ) ) : undefined , } as any ; } ; const deserializeAws_json1_1OperationNotFound = ( output , context ) : OperationNotFound => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1OperationSummary = ( output , context ) : OperationSummary => { return { Id : __expectString ( output . Id ) , Status : __expectString ( output . Status ) , } as any ; } ; const deserializeAws_json1_1OperationSummaryList = ( output , context ) : OperationSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1OperationSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1OperationTargetsMap = ( 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_1RegisterInstanceResponse = ( output , context ) : RegisterInstanceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1RequestLimitExceeded = ( output , context ) : RequestLimitExceeded => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ResourceInUse = ( output , context ) : ResourceInUse => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ResourceLimitExceeded = ( output , context ) : ResourceLimitExceeded => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ResourceNotFoundException = ( output , context ) : ResourceNotFoundException => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1Service = ( output , context ) : Service => { return { Arn : __expectString ( output . Arn ) , CreateDate : output . CreateDate !== undefined && output . CreateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreateDate ) ) ) : undefined , CreatorRequestId : __expectString ( output . CreatorRequestId ) , Description : __expectString ( output . Description ) , DnsConfig : output . DnsConfig !== undefined && output . DnsConfig !== null ? deserializeAws_json1_1DnsConfig ( output . DnsConfig , context ) : undefined , HealthCheckConfig : output . HealthCheckConfig !== undefined && output . HealthCheckConfig !== null ? deserializeAws_json1_1HealthCheckConfig ( output . HealthCheckConfig , context ) : undefined , HealthCheckCustomConfig : output . HealthCheckCustomConfig !== undefined && output . HealthCheckCustomConfig !== null ? deserializeAws_json1_1HealthCheckCustomConfig ( output . HealthCheckCustomConfig , context ) : undefined , Id : __expectString ( output . Id ) , InstanceCount : __expectInt32 ( output . InstanceCount ) , Name : __expectString ( output . Name ) , NamespaceId : __expectString ( output . NamespaceId ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1ServiceAlreadyExists = ( output , context ) : ServiceAlreadyExists => { return { CreatorRequestId : __expectString ( output . CreatorRequestId ) , Message : __expectString ( output . Message ) , ServiceId : __expectString ( output . ServiceId ) , } as any ; } ; const deserializeAws_json1_1ServiceNotFound = ( output , context ) : ServiceNotFound => { return { Message : __expectString ( output . Message ) , } as any ; } ; const deserializeAws_json1_1ServiceSummariesList = ( output , context ) : ServiceSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1ServiceSummary ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1ServiceSummary = ( output , context ) : ServiceSummary => { return { Arn : __expectString ( output . Arn ) , CreateDate : output . CreateDate !== undefined && output . CreateDate !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . CreateDate ) ) ) : undefined , Description : __expectString ( output . Description ) , DnsConfig : output . DnsConfig !== undefined && output . DnsConfig !== null ? deserializeAws_json1_1DnsConfig ( output . DnsConfig , context ) : undefined , HealthCheckConfig : output . HealthCheckConfig !== undefined && output . HealthCheckConfig !== null ? deserializeAws_json1_1HealthCheckConfig ( output . HealthCheckConfig , context ) : undefined , HealthCheckCustomConfig : output . HealthCheckCustomConfig !== undefined && output . HealthCheckCustomConfig !== null ? deserializeAws_json1_1HealthCheckCustomConfig ( output . HealthCheckCustomConfig , context ) : undefined , Id : __expectString ( output . Id ) , InstanceCount : __expectInt32 ( output . InstanceCount ) , Name : __expectString ( output . Name ) , Type : __expectString ( output . Type ) , } as any ; } ; const deserializeAws_json1_1SOA = ( output , context ) : SOA => { return { TTL : __expectLong ( output . TTL ) , } as any ; } ; const deserializeAws_json1_1Tag = ( output , context ) : Tag => { return { Key : __expectString ( output . Key ) , Value : __expectString ( output . Value ) , } as any ; } ; const deserializeAws_json1_1TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_json1_1Tag ( entry , context ) ; } ) ; } ; const deserializeAws_json1_1TagResourceResponse = ( output , context ) : TagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_1TooManyTagsException = ( output , context ) : TooManyTagsException => { return { Message : __expectString ( output . Message ) , ResourceName : __expectString ( output . ResourceName ) , } as any ; } ; const deserializeAws_json1_1UntagResourceResponse = ( output , context ) : UntagResourceResponse => { return { } as any ; } ; const deserializeAws_json1_1UpdateHttpNamespaceResponse = ( output , context ) : UpdateHttpNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1UpdatePrivateDnsNamespaceResponse = ( output , context ) : UpdatePrivateDnsNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1UpdatePublicDnsNamespaceResponse = ( output , context ) : UpdatePublicDnsNamespaceResponse => { return { OperationId : __expectString ( output . OperationId ) , } as any ; } ; const deserializeAws_json1_1UpdateServiceResponse = ( output , context ) : UpdateServiceResponse => { return { OperationId : __expectString ( output . OperationId ) , } 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 "" ; } ;