import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectBoolean as __expectBoolean , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectObject as __expectObject , expectString as __expectString , extendedEncodeURIComponent as __extendedEncodeURIComponent , parseEpochTimestamp as __parseEpochTimestamp , } from "@aws-sdk/smithy-client" ; import { Endpoint as __Endpoint , MetadataBearer as __MetadataBearer , ResponseMetadata as __ResponseMetadata , SerdeContext as __SerdeContext , SmithyException as __SmithyException , } from "@aws-sdk/types" ; import { AcceptResourceShareInvitationCommandInput , AcceptResourceShareInvitationCommandOutput , } from "../commands/AcceptResourceShareInvitationCommand" ; import { AssociateResourceShareCommandInput , AssociateResourceShareCommandOutput , } from "../commands/AssociateResourceShareCommand" ; import { AssociateResourceSharePermissionCommandInput , AssociateResourceSharePermissionCommandOutput , } from "../commands/AssociateResourceSharePermissionCommand" ; import { CreateResourceShareCommandInput , CreateResourceShareCommandOutput , } from "../commands/CreateResourceShareCommand" ; import { DeleteResourceShareCommandInput , DeleteResourceShareCommandOutput , } from "../commands/DeleteResourceShareCommand" ; import { DisassociateResourceShareCommandInput , DisassociateResourceShareCommandOutput , } from "../commands/DisassociateResourceShareCommand" ; import { DisassociateResourceSharePermissionCommandInput , DisassociateResourceSharePermissionCommandOutput , } from "../commands/DisassociateResourceSharePermissionCommand" ; import { EnableSharingWithAwsOrganizationCommandInput , EnableSharingWithAwsOrganizationCommandOutput , } from "../commands/EnableSharingWithAwsOrganizationCommand" ; import { GetPermissionCommandInput , GetPermissionCommandOutput } from "../commands/GetPermissionCommand" ; import { GetResourcePoliciesCommandInput , GetResourcePoliciesCommandOutput , } from "../commands/GetResourcePoliciesCommand" ; import { GetResourceShareAssociationsCommandInput , GetResourceShareAssociationsCommandOutput , } from "../commands/GetResourceShareAssociationsCommand" ; import { GetResourceShareInvitationsCommandInput , GetResourceShareInvitationsCommandOutput , } from "../commands/GetResourceShareInvitationsCommand" ; import { GetResourceSharesCommandInput , GetResourceSharesCommandOutput } from "../commands/GetResourceSharesCommand" ; import { ListPendingInvitationResourcesCommandInput , ListPendingInvitationResourcesCommandOutput , } from "../commands/ListPendingInvitationResourcesCommand" ; import { ListPermissionsCommandInput , ListPermissionsCommandOutput } from "../commands/ListPermissionsCommand" ; import { ListPrincipalsCommandInput , ListPrincipalsCommandOutput } from "../commands/ListPrincipalsCommand" ; import { ListResourcesCommandInput , ListResourcesCommandOutput } from "../commands/ListResourcesCommand" ; import { ListResourceSharePermissionsCommandInput , ListResourceSharePermissionsCommandOutput , } from "../commands/ListResourceSharePermissionsCommand" ; import { ListResourceTypesCommandInput , ListResourceTypesCommandOutput } from "../commands/ListResourceTypesCommand" ; import { PromoteResourceShareCreatedFromPolicyCommandInput , PromoteResourceShareCreatedFromPolicyCommandOutput , } from "../commands/PromoteResourceShareCreatedFromPolicyCommand" ; import { RejectResourceShareInvitationCommandInput , RejectResourceShareInvitationCommandOutput , } from "../commands/RejectResourceShareInvitationCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateResourceShareCommandInput , UpdateResourceShareCommandOutput , } from "../commands/UpdateResourceShareCommand" ; import { IdempotentParameterMismatchException , InvalidClientTokenException , InvalidMaxResultsException , InvalidNextTokenException , InvalidParameterException , InvalidResourceTypeException , InvalidStateTransitionException , MalformedArnException , MissingRequiredParameterException , OperationNotPermittedException , Principal , Resource , ResourceArnNotFoundException , ResourceShare , ResourceShareAssociation , ResourceShareInvitation , ResourceShareInvitationAlreadyAcceptedException , ResourceShareInvitationAlreadyRejectedException , ResourceShareInvitationArnNotFoundException , ResourceShareInvitationExpiredException , ResourceShareLimitExceededException , ResourceSharePermissionDetail , ResourceSharePermissionSummary , ServerInternalException , ServiceNameAndResourceType , ServiceUnavailableException , Tag , TagFilter , TagLimitExceededException , TagPolicyViolationException , ThrottlingException , UnknownResourceException , } from "../models/models_0" ; export const serializeAws_restJson1AcceptResourceShareInvitationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/acceptresourceshareinvitation" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . resourceShareInvitationArn !== undefined && input . resourceShareInvitationArn !== null && { resourceShareInvitationArn : input . resourceShareInvitationArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1AssociateResourceShareCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/associateresourceshare" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . principals !== undefined && input . principals !== null && { principals : serializeAws_restJson1PrincipalArnOrIdList ( input . principals , context ) , } ) , ... ( input . resourceArns !== undefined && input . resourceArns !== null && { resourceArns : serializeAws_restJson1ResourceArnList ( input . resourceArns , context ) , } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1AssociateResourceSharePermissionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/associateresourcesharepermission" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . permissionArn !== undefined && input . permissionArn !== null && { permissionArn : input . permissionArn } ) , ... ( input . permissionVersion !== undefined && input . permissionVersion !== null && { permissionVersion : input . permissionVersion } ) , ... ( input . replace !== undefined && input . replace !== null && { replace : input . replace } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateResourceShareCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/createresourceshare" ; let body ; body = JSON . stringify ( { ... ( input . allowExternalPrincipals !== undefined && input . allowExternalPrincipals !== null && { allowExternalPrincipals : input . allowExternalPrincipals } ) , ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . permissionArns !== undefined && input . permissionArns !== null && { permissionArns : serializeAws_restJson1PermissionArnList ( input . permissionArns , context ) , } ) , ... ( input . principals !== undefined && input . principals !== null && { principals : serializeAws_restJson1PrincipalArnOrIdList ( input . principals , context ) , } ) , ... ( input . resourceArns !== undefined && input . resourceArns !== null && { resourceArns : serializeAws_restJson1ResourceArnList ( input . resourceArns , context ) , } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1TagList ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteResourceShareCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/deleteresourceshare" ; const query = { ... ( input . resourceShareArn !== undefined && { resourceShareArn : input . resourceShareArn } ) , ... ( input . clientToken !== undefined && { clientToken : input . clientToken } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1DisassociateResourceShareCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/disassociateresourceshare" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . principals !== undefined && input . principals !== null && { principals : serializeAws_restJson1PrincipalArnOrIdList ( input . principals , context ) , } ) , ... ( input . resourceArns !== undefined && input . resourceArns !== null && { resourceArns : serializeAws_restJson1ResourceArnList ( input . resourceArns , context ) , } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DisassociateResourceSharePermissionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/disassociateresourcesharepermission" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . permissionArn !== undefined && input . permissionArn !== null && { permissionArn : input . permissionArn } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1EnableSharingWithAwsOrganizationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/enablesharingwithawsorganization" ; let body ; body = "" ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetPermissionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getpermission" ; let body ; body = JSON . stringify ( { ... ( input . permissionArn !== undefined && input . permissionArn !== null && { permissionArn : input . permissionArn } ) , ... ( input . permissionVersion !== undefined && input . permissionVersion !== null && { permissionVersion : input . permissionVersion } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetResourcePoliciesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getresourcepolicies" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . principal !== undefined && input . principal !== null && { principal : input . principal } ) , ... ( input . resourceArns !== undefined && input . resourceArns !== null && { resourceArns : serializeAws_restJson1ResourceArnList ( input . resourceArns , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetResourceShareAssociationsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getresourceshareassociations" ; let body ; body = JSON . stringify ( { ... ( input . associationStatus !== undefined && input . associationStatus !== null && { associationStatus : input . associationStatus } ) , ... ( input . associationType !== undefined && input . associationType !== null && { associationType : input . associationType } ) , ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . principal !== undefined && input . principal !== null && { principal : input . principal } ) , ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , ... ( input . resourceShareArns !== undefined && input . resourceShareArns !== null && { resourceShareArns : serializeAws_restJson1ResourceShareArnList ( input . resourceShareArns , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetResourceShareInvitationsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getresourceshareinvitations" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . resourceShareArns !== undefined && input . resourceShareArns !== null && { resourceShareArns : serializeAws_restJson1ResourceShareArnList ( input . resourceShareArns , context ) , } ) , ... ( input . resourceShareInvitationArns !== undefined && input . resourceShareInvitationArns !== null && { resourceShareInvitationArns : serializeAws_restJson1ResourceShareInvitationArnList ( input . resourceShareInvitationArns , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetResourceSharesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/getresourceshares" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . permissionArn !== undefined && input . permissionArn !== null && { permissionArn : input . permissionArn } ) , ... ( input . resourceOwner !== undefined && input . resourceOwner !== null && { resourceOwner : input . resourceOwner } ) , ... ( input . resourceShareArns !== undefined && input . resourceShareArns !== null && { resourceShareArns : serializeAws_restJson1ResourceShareArnList ( input . resourceShareArns , context ) , } ) , ... ( input . resourceShareStatus !== undefined && input . resourceShareStatus !== null && { resourceShareStatus : input . resourceShareStatus } ) , ... ( input . tagFilters !== undefined && input . tagFilters !== null && { tagFilters : serializeAws_restJson1TagFilters ( input . tagFilters , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListPendingInvitationResourcesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listpendinginvitationresources" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . resourceRegionScope !== undefined && input . resourceRegionScope !== null && { resourceRegionScope : input . resourceRegionScope } ) , ... ( input . resourceShareInvitationArn !== undefined && input . resourceShareInvitationArn !== null && { resourceShareInvitationArn : input . resourceShareInvitationArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListPermissionsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listpermissions" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . resourceType !== undefined && input . resourceType !== null && { resourceType : input . resourceType } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListPrincipalsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listprincipals" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . principals !== undefined && input . principals !== null && { principals : serializeAws_restJson1PrincipalArnOrIdList ( input . principals , context ) , } ) , ... ( input . resourceArn !== undefined && input . resourceArn !== null && { resourceArn : input . resourceArn } ) , ... ( input . resourceOwner !== undefined && input . resourceOwner !== null && { resourceOwner : input . resourceOwner } ) , ... ( input . resourceShareArns !== undefined && input . resourceShareArns !== null && { resourceShareArns : serializeAws_restJson1ResourceShareArnList ( input . resourceShareArns , context ) , } ) , ... ( input . resourceType !== undefined && input . resourceType !== null && { resourceType : input . resourceType } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListResourcesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listresources" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . principal !== undefined && input . principal !== null && { principal : input . principal } ) , ... ( input . resourceArns !== undefined && input . resourceArns !== null && { resourceArns : serializeAws_restJson1ResourceArnList ( input . resourceArns , context ) , } ) , ... ( input . resourceOwner !== undefined && input . resourceOwner !== null && { resourceOwner : input . resourceOwner } ) , ... ( input . resourceRegionScope !== undefined && input . resourceRegionScope !== null && { resourceRegionScope : input . resourceRegionScope } ) , ... ( input . resourceShareArns !== undefined && input . resourceShareArns !== null && { resourceShareArns : serializeAws_restJson1ResourceShareArnList ( input . resourceShareArns , context ) , } ) , ... ( input . resourceType !== undefined && input . resourceType !== null && { resourceType : input . resourceType } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListResourceSharePermissionsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listresourcesharepermissions" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListResourceTypesCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/listresourcetypes" ; let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . resourceRegionScope !== undefined && input . resourceRegionScope !== null && { resourceRegionScope : input . resourceRegionScope } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1PromoteResourceShareCreatedFromPolicyCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/promoteresourcesharecreatedfrompolicy" ; const query = { ... ( input . resourceShareArn !== undefined && { resourceShareArn : input . resourceShareArn } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1RejectResourceShareInvitationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/rejectresourceshareinvitation" ; let body ; body = JSON . stringify ( { ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . resourceShareInvitationArn !== undefined && input . resourceShareInvitationArn !== null && { resourceShareInvitationArn : input . resourceShareInvitationArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1TagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tagresource" ; let body ; body = JSON . stringify ( { ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1TagList ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UntagResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/untagresource" ; let body ; body = JSON . stringify ( { ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , ... ( input . tagKeys !== undefined && input . tagKeys !== null && { tagKeys : serializeAws_restJson1TagKeyList ( input . tagKeys , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateResourceShareCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; const resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/updateresourceshare" ; let body ; body = JSON . stringify ( { ... ( input . allowExternalPrincipals !== undefined && input . allowExternalPrincipals !== null && { allowExternalPrincipals : input . allowExternalPrincipals } ) , ... ( input . clientToken !== undefined && input . clientToken !== null && { clientToken : input . clientToken } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . resourceShareArn !== undefined && input . resourceShareArn !== null && { resourceShareArn : input . resourceShareArn } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1AcceptResourceShareInvitationCommand = async ( output , context ) : Promise < AcceptResourceShareInvitationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1AcceptResourceShareInvitationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShareInvitation : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShareInvitation !== undefined && data . resourceShareInvitation !== null ) { contents . resourceShareInvitation = deserializeAws_restJson1ResourceShareInvitation ( data . resourceShareInvitation , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1AcceptResourceShareInvitationCommandError = async ( output , context ) : Promise < AcceptResourceShareInvitationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationAlreadyAcceptedException" : case "com.amazonaws.ram#ResourceShareInvitationAlreadyAcceptedException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationAlreadyAcceptedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationAlreadyRejectedException" : case "com.amazonaws.ram#ResourceShareInvitationAlreadyRejectedException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationAlreadyRejectedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationArnNotFoundException" : case "com.amazonaws.ram#ResourceShareInvitationArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationExpiredException" : case "com.amazonaws.ram#ResourceShareInvitationExpiredException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationExpiredExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1AssociateResourceShareCommand = async ( output , context ) : Promise < AssociateResourceShareCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1AssociateResourceShareCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShareAssociations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShareAssociations !== undefined && data . resourceShareAssociations !== null ) { contents . resourceShareAssociations = deserializeAws_restJson1ResourceShareAssociationList ( data . resourceShareAssociations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1AssociateResourceShareCommandError = async ( output , context ) : Promise < AssociateResourceShareCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidStateTransitionException" : case "com.amazonaws.ram#InvalidStateTransitionException" : response = { ... ( await deserializeAws_restJson1InvalidStateTransitionExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareLimitExceededException" : case "com.amazonaws.ram#ResourceShareLimitExceededException" : response = { ... ( await deserializeAws_restJson1ResourceShareLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ThrottlingException" : case "com.amazonaws.ram#ThrottlingException" : response = { ... ( await deserializeAws_restJson1ThrottlingExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1AssociateResourceSharePermissionCommand = async ( output , context ) : Promise < AssociateResourceSharePermissionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1AssociateResourceSharePermissionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , returnValue : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . returnValue !== undefined && data . returnValue !== null ) { contents . returnValue = __expectBoolean ( data . returnValue ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1AssociateResourceSharePermissionCommandError = async ( output , context ) : Promise < AssociateResourceSharePermissionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1CreateResourceShareCommand = async ( output , context ) : Promise < CreateResourceShareCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateResourceShareCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShare : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShare !== undefined && data . resourceShare !== null ) { contents . resourceShare = deserializeAws_restJson1ResourceShare ( data . resourceShare , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateResourceShareCommandError = async ( output , context ) : Promise < CreateResourceShareCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidStateTransitionException" : case "com.amazonaws.ram#InvalidStateTransitionException" : response = { ... ( await deserializeAws_restJson1InvalidStateTransitionExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareLimitExceededException" : case "com.amazonaws.ram#ResourceShareLimitExceededException" : response = { ... ( await deserializeAws_restJson1ResourceShareLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagPolicyViolationException" : case "com.amazonaws.ram#TagPolicyViolationException" : response = { ... ( await deserializeAws_restJson1TagPolicyViolationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1DeleteResourceShareCommand = async ( output , context ) : Promise < DeleteResourceShareCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteResourceShareCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , returnValue : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . returnValue !== undefined && data . returnValue !== null ) { contents . returnValue = __expectBoolean ( data . returnValue ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteResourceShareCommandError = async ( output , context ) : Promise < DeleteResourceShareCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidStateTransitionException" : case "com.amazonaws.ram#InvalidStateTransitionException" : response = { ... ( await deserializeAws_restJson1InvalidStateTransitionExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1DisassociateResourceShareCommand = async ( output , context ) : Promise < DisassociateResourceShareCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DisassociateResourceShareCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShareAssociations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShareAssociations !== undefined && data . resourceShareAssociations !== null ) { contents . resourceShareAssociations = deserializeAws_restJson1ResourceShareAssociationList ( data . resourceShareAssociations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DisassociateResourceShareCommandError = async ( output , context ) : Promise < DisassociateResourceShareCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidStateTransitionException" : case "com.amazonaws.ram#InvalidStateTransitionException" : response = { ... ( await deserializeAws_restJson1InvalidStateTransitionExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareLimitExceededException" : case "com.amazonaws.ram#ResourceShareLimitExceededException" : response = { ... ( await deserializeAws_restJson1ResourceShareLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1DisassociateResourceSharePermissionCommand = async ( output , context ) : Promise < DisassociateResourceSharePermissionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1DisassociateResourceSharePermissionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , returnValue : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . returnValue !== undefined && data . returnValue !== null ) { contents . returnValue = __expectBoolean ( data . returnValue ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DisassociateResourceSharePermissionCommandError = async ( output , context ) : Promise < DisassociateResourceSharePermissionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidStateTransitionException" : case "com.amazonaws.ram#InvalidStateTransitionException" : response = { ... ( await deserializeAws_restJson1InvalidStateTransitionExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1EnableSharingWithAwsOrganizationCommand = async ( output , context ) : Promise < EnableSharingWithAwsOrganizationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1EnableSharingWithAwsOrganizationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , returnValue : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . returnValue !== undefined && data . returnValue !== null ) { contents . returnValue = __expectBoolean ( data . returnValue ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1EnableSharingWithAwsOrganizationCommandError = async ( output , context ) : Promise < EnableSharingWithAwsOrganizationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1GetPermissionCommand = async ( output , context ) : Promise < GetPermissionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetPermissionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , permission : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . permission !== undefined && data . permission !== null ) { contents . permission = deserializeAws_restJson1ResourceSharePermissionDetail ( data . permission , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetPermissionCommandError = async ( output , context ) : Promise < GetPermissionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1GetResourcePoliciesCommand = async ( output , context ) : Promise < GetResourcePoliciesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResourcePoliciesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , policies : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . policies !== undefined && data . policies !== null ) { contents . policies = deserializeAws_restJson1PolicyList ( data . policies , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResourcePoliciesCommandError = async ( output , context ) : Promise < GetResourcePoliciesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceArnNotFoundException" : case "com.amazonaws.ram#ResourceArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1GetResourceShareAssociationsCommand = async ( output , context ) : Promise < GetResourceShareAssociationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResourceShareAssociationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resourceShareAssociations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resourceShareAssociations !== undefined && data . resourceShareAssociations !== null ) { contents . resourceShareAssociations = deserializeAws_restJson1ResourceShareAssociationList ( data . resourceShareAssociations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResourceShareAssociationsCommandError = async ( output , context ) : Promise < GetResourceShareAssociationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1GetResourceShareInvitationsCommand = async ( output , context ) : Promise < GetResourceShareInvitationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResourceShareInvitationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resourceShareInvitations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resourceShareInvitations !== undefined && data . resourceShareInvitations !== null ) { contents . resourceShareInvitations = deserializeAws_restJson1ResourceShareInvitationList ( data . resourceShareInvitations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResourceShareInvitationsCommandError = async ( output , context ) : Promise < GetResourceShareInvitationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidMaxResultsException" : case "com.amazonaws.ram#InvalidMaxResultsException" : response = { ... ( await deserializeAws_restJson1InvalidMaxResultsExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationArnNotFoundException" : case "com.amazonaws.ram#ResourceShareInvitationArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1GetResourceSharesCommand = async ( output , context ) : Promise < GetResourceSharesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetResourceSharesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resourceShares : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resourceShares !== undefined && data . resourceShares !== null ) { contents . resourceShares = deserializeAws_restJson1ResourceShareList ( data . resourceShares , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetResourceSharesCommandError = async ( output , context ) : Promise < GetResourceSharesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1ListPendingInvitationResourcesCommand = async ( output , context ) : Promise < ListPendingInvitationResourcesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListPendingInvitationResourcesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resources : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resources !== undefined && data . resources !== null ) { contents . resources = deserializeAws_restJson1ResourceList ( data . resources , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListPendingInvitationResourcesCommandError = async ( output , context ) : Promise < ListPendingInvitationResourcesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MissingRequiredParameterException" : case "com.amazonaws.ram#MissingRequiredParameterException" : response = { ... ( await deserializeAws_restJson1MissingRequiredParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationAlreadyRejectedException" : case "com.amazonaws.ram#ResourceShareInvitationAlreadyRejectedException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationAlreadyRejectedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationArnNotFoundException" : case "com.amazonaws.ram#ResourceShareInvitationArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationExpiredException" : case "com.amazonaws.ram#ResourceShareInvitationExpiredException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationExpiredExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1ListPermissionsCommand = async ( output , context ) : Promise < ListPermissionsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListPermissionsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , permissions : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . permissions !== undefined && data . permissions !== null ) { contents . permissions = deserializeAws_restJson1ResourceSharePermissionList ( data . permissions , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListPermissionsCommandError = async ( output , context ) : Promise < ListPermissionsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1ListPrincipalsCommand = async ( output , context ) : Promise < ListPrincipalsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListPrincipalsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , principals : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . principals !== undefined && data . principals !== null ) { contents . principals = deserializeAws_restJson1PrincipalList ( data . principals , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListPrincipalsCommandError = async ( output , context ) : Promise < ListPrincipalsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1ListResourcesCommand = async ( output , context ) : Promise < ListResourcesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListResourcesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resources : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resources !== undefined && data . resources !== null ) { contents . resources = deserializeAws_restJson1ResourceList ( data . resources , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListResourcesCommandError = async ( output , context ) : Promise < ListResourcesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidResourceTypeException" : case "com.amazonaws.ram#InvalidResourceTypeException" : response = { ... ( await deserializeAws_restJson1InvalidResourceTypeExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1ListResourceSharePermissionsCommand = async ( output , context ) : Promise < ListResourceSharePermissionsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListResourceSharePermissionsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , permissions : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . permissions !== undefined && data . permissions !== null ) { contents . permissions = deserializeAws_restJson1ResourceSharePermissionList ( data . permissions , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListResourceSharePermissionsCommandError = async ( output , context ) : Promise < ListResourceSharePermissionsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1ListResourceTypesCommand = async ( output , context ) : Promise < ListResourceTypesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListResourceTypesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , resourceTypes : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } if ( data . resourceTypes !== undefined && data . resourceTypes !== null ) { contents . resourceTypes = deserializeAws_restJson1ServiceNameAndResourceTypeList ( data . resourceTypes , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListResourceTypesCommandError = async ( output , context ) : Promise < ListResourceTypesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidNextTokenException" : case "com.amazonaws.ram#InvalidNextTokenException" : response = { ... ( await deserializeAws_restJson1InvalidNextTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1PromoteResourceShareCreatedFromPolicyCommand = async ( output , context ) : Promise < PromoteResourceShareCreatedFromPolicyCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1PromoteResourceShareCreatedFromPolicyCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , returnValue : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . returnValue !== undefined && data . returnValue !== null ) { contents . returnValue = __expectBoolean ( data . returnValue ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1PromoteResourceShareCreatedFromPolicyCommandError = async ( output , context ) : Promise < PromoteResourceShareCreatedFromPolicyCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MissingRequiredParameterException" : case "com.amazonaws.ram#MissingRequiredParameterException" : response = { ... ( await deserializeAws_restJson1MissingRequiredParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareLimitExceededException" : case "com.amazonaws.ram#ResourceShareLimitExceededException" : response = { ... ( await deserializeAws_restJson1ResourceShareLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1RejectResourceShareInvitationCommand = async ( output , context ) : Promise < RejectResourceShareInvitationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1RejectResourceShareInvitationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShareInvitation : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShareInvitation !== undefined && data . resourceShareInvitation !== null ) { contents . resourceShareInvitation = deserializeAws_restJson1ResourceShareInvitation ( data . resourceShareInvitation , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1RejectResourceShareInvitationCommandError = async ( output , context ) : Promise < RejectResourceShareInvitationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationAlreadyAcceptedException" : case "com.amazonaws.ram#ResourceShareInvitationAlreadyAcceptedException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationAlreadyAcceptedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationAlreadyRejectedException" : case "com.amazonaws.ram#ResourceShareInvitationAlreadyRejectedException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationAlreadyRejectedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationArnNotFoundException" : case "com.amazonaws.ram#ResourceShareInvitationArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceShareInvitationExpiredException" : case "com.amazonaws.ram#ResourceShareInvitationExpiredException" : response = { ... ( await deserializeAws_restJson1ResourceShareInvitationExpiredExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_restJson1TagResourceCommand = async ( output , context ) : Promise < TagResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1TagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1TagResourceCommandError = async ( output , context ) : Promise < TagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceArnNotFoundException" : case "com.amazonaws.ram#ResourceArnNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceArnNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagLimitExceededException" : case "com.amazonaws.ram#TagLimitExceededException" : response = { ... ( await deserializeAws_restJson1TagLimitExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TagPolicyViolationException" : case "com.amazonaws.ram#TagPolicyViolationException" : response = { ... ( await deserializeAws_restJson1TagPolicyViolationExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; default : const parsedBody = parsedOutput . body ; errorCode = parsedBody . code || parsedBody . Code || errorCode ; response = { ... parsedBody , name : `${ errorCode }` , message : parsedBody . message || parsedBody . Message || errorCode , $fault : "client" , $metadata : deserializeMetadata ( output ) , } as any ; } const message = response . message || response . Message || errorCode ; response . message = message ; delete response . Message ; return Promise . reject ( Object . assign ( new Error ( message ) , response ) ) ; } ; export const deserializeAws_restJson1UntagResourceCommand = async ( output , context ) : Promise < UntagResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UntagResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UntagResourceCommandError = async ( output , context ) : Promise < UntagResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( 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_restJson1UpdateResourceShareCommand = async ( output , context ) : Promise < UpdateResourceShareCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateResourceShareCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , clientToken : undefined , resourceShare : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . clientToken !== undefined && data . clientToken !== null ) { contents . clientToken = __expectString ( data . clientToken ) ; } if ( data . resourceShare !== undefined && data . resourceShare !== null ) { contents . resourceShare = deserializeAws_restJson1ResourceShare ( data . resourceShare , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateResourceShareCommandError = async ( output , context ) : Promise < UpdateResourceShareCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "IdempotentParameterMismatchException" : case "com.amazonaws.ram#IdempotentParameterMismatchException" : response = { ... ( await deserializeAws_restJson1IdempotentParameterMismatchExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidClientTokenException" : case "com.amazonaws.ram#InvalidClientTokenException" : response = { ... ( await deserializeAws_restJson1InvalidClientTokenExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "InvalidParameterException" : case "com.amazonaws.ram#InvalidParameterException" : response = { ... ( await deserializeAws_restJson1InvalidParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MalformedArnException" : case "com.amazonaws.ram#MalformedArnException" : response = { ... ( await deserializeAws_restJson1MalformedArnExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "MissingRequiredParameterException" : case "com.amazonaws.ram#MissingRequiredParameterException" : response = { ... ( await deserializeAws_restJson1MissingRequiredParameterExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "OperationNotPermittedException" : case "com.amazonaws.ram#OperationNotPermittedException" : response = { ... ( await deserializeAws_restJson1OperationNotPermittedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServerInternalException" : case "com.amazonaws.ram#ServerInternalException" : response = { ... ( await deserializeAws_restJson1ServerInternalExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceUnavailableException" : case "com.amazonaws.ram#ServiceUnavailableException" : response = { ... ( await deserializeAws_restJson1ServiceUnavailableExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "UnknownResourceException" : case "com.amazonaws.ram#UnknownResourceException" : response = { ... ( await deserializeAws_restJson1UnknownResourceExceptionResponse ( 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_restJson1IdempotentParameterMismatchExceptionResponse = async ( parsedOutput , context ) : Promise < IdempotentParameterMismatchException > => { const contents = { name : "IdempotentParameterMismatchException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidClientTokenExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidClientTokenException > => { const contents = { name : "InvalidClientTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidMaxResultsExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidMaxResultsException > => { const contents = { name : "InvalidMaxResultsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidNextTokenExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidNextTokenException > => { const contents = { name : "InvalidNextTokenException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidParameterExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidParameterException > => { const contents = { name : "InvalidParameterException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidResourceTypeExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidResourceTypeException > => { const contents = { name : "InvalidResourceTypeException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1InvalidStateTransitionExceptionResponse = async ( parsedOutput , context ) : Promise < InvalidStateTransitionException > => { const contents = { name : "InvalidStateTransitionException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1MalformedArnExceptionResponse = async ( parsedOutput , context ) : Promise < MalformedArnException > => { const contents = { name : "MalformedArnException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1MissingRequiredParameterExceptionResponse = async ( parsedOutput , context ) : Promise < MissingRequiredParameterException > => { const contents = { name : "MissingRequiredParameterException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1OperationNotPermittedExceptionResponse = async ( parsedOutput , context ) : Promise < OperationNotPermittedException > => { const contents = { name : "OperationNotPermittedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceArnNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceArnNotFoundException > => { const contents = { name : "ResourceArnNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceShareInvitationAlreadyAcceptedExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceShareInvitationAlreadyAcceptedException > => { const contents = { name : "ResourceShareInvitationAlreadyAcceptedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceShareInvitationAlreadyRejectedExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceShareInvitationAlreadyRejectedException > => { const contents = { name : "ResourceShareInvitationAlreadyRejectedException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceShareInvitationArnNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceShareInvitationArnNotFoundException > => { const contents = { name : "ResourceShareInvitationArnNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceShareInvitationExpiredExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceShareInvitationExpiredException > => { const contents = { name : "ResourceShareInvitationExpiredException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ResourceShareLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceShareLimitExceededException > => { const contents = { name : "ResourceShareLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ServerInternalExceptionResponse = async ( parsedOutput , context ) : Promise < ServerInternalException > => { const contents = { name : "ServerInternalException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ServiceUnavailableExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceUnavailableException > => { const contents = { name : "ServiceUnavailableException" , $fault : "server" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1TagLimitExceededExceptionResponse = async ( parsedOutput , context ) : Promise < TagLimitExceededException > => { const contents = { name : "TagLimitExceededException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1TagPolicyViolationExceptionResponse = async ( parsedOutput , context ) : Promise < TagPolicyViolationException > => { const contents = { name : "TagPolicyViolationException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1ThrottlingExceptionResponse = async ( parsedOutput , context ) : Promise < ThrottlingException > => { const contents = { name : "ThrottlingException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const deserializeAws_restJson1UnknownResourceExceptionResponse = async ( parsedOutput , context ) : Promise < UnknownResourceException > => { const contents = { name : "UnknownResourceException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } return contents ; } ; const serializeAws_restJson1PermissionArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1PrincipalArnOrIdList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ResourceArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ResourceShareArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1ResourceShareInvitationArnList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1Tag = ( input , context ) : any => { return { ... ( input . key !== undefined && input . key !== null && { key : input . key } ) , ... ( input . value !== undefined && input . value !== null && { value : input . value } ) , } ; } ; const serializeAws_restJson1TagFilter = ( input , context ) : any => { return { ... ( input . tagKey !== undefined && input . tagKey !== null && { tagKey : input . tagKey } ) , ... ( input . tagValues !== undefined && input . tagValues !== null && { tagValues : serializeAws_restJson1TagValueList ( input . tagValues , context ) } ) , } ; } ; const serializeAws_restJson1TagFilters = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1TagFilter ( entry , context ) ; } ) ; } ; const serializeAws_restJson1TagKeyList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1TagList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Tag ( entry , context ) ; } ) ; } ; const serializeAws_restJson1TagValueList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const deserializeAws_restJson1PolicyList = ( output , context ) : string [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return __expectString ( entry ) as any ; } ) ; } ; const deserializeAws_restJson1Principal = ( output , context ) : Principal => { return { creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , external : __expectBoolean ( output . external ) , id : __expectString ( output . id ) , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , resourceShareArn : __expectString ( output . resourceShareArn ) , } as any ; } ; const deserializeAws_restJson1PrincipalList = ( output , context ) : Principal [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Principal ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Resource = ( output , context ) : Resource => { return { arn : __expectString ( output . arn ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , resourceGroupArn : __expectString ( output . resourceGroupArn ) , resourceRegionScope : __expectString ( output . resourceRegionScope ) , resourceShareArn : __expectString ( output . resourceShareArn ) , status : __expectString ( output . status ) , statusMessage : __expectString ( output . statusMessage ) , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1ResourceList = ( output , context ) : Resource [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Resource ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceShare = ( output , context ) : ResourceShare => { return { allowExternalPrincipals : __expectBoolean ( output . allowExternalPrincipals ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , featureSet : __expectString ( output . featureSet ) , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , name : __expectString ( output . name ) , owningAccountId : __expectString ( output . owningAccountId ) , resourceShareArn : __expectString ( output . resourceShareArn ) , status : __expectString ( output . status ) , statusMessage : __expectString ( output . statusMessage ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1TagList ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1ResourceShareAssociation = ( output , context ) : ResourceShareAssociation => { return { associatedEntity : __expectString ( output . associatedEntity ) , associationType : __expectString ( output . associationType ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , external : __expectBoolean ( output . external ) , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , resourceShareArn : __expectString ( output . resourceShareArn ) , resourceShareName : __expectString ( output . resourceShareName ) , status : __expectString ( output . status ) , statusMessage : __expectString ( output . statusMessage ) , } as any ; } ; const deserializeAws_restJson1ResourceShareAssociationList = ( output , context ) : ResourceShareAssociation [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourceShareAssociation ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceShareInvitation = ( output , context ) : ResourceShareInvitation => { return { invitationTimestamp : output . invitationTimestamp !== undefined && output . invitationTimestamp !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . invitationTimestamp ) ) ) : undefined , receiverAccountId : __expectString ( output . receiverAccountId ) , receiverArn : __expectString ( output . receiverArn ) , resourceShareArn : __expectString ( output . resourceShareArn ) , resourceShareAssociations : output . resourceShareAssociations !== undefined && output . resourceShareAssociations !== null ? deserializeAws_restJson1ResourceShareAssociationList ( output . resourceShareAssociations , context ) : undefined , resourceShareInvitationArn : __expectString ( output . resourceShareInvitationArn ) , resourceShareName : __expectString ( output . resourceShareName ) , senderAccountId : __expectString ( output . senderAccountId ) , status : __expectString ( output . status ) , } as any ; } ; const deserializeAws_restJson1ResourceShareInvitationList = ( output , context ) : ResourceShareInvitation [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourceShareInvitation ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceShareList = ( output , context ) : ResourceShare [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourceShare ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceSharePermissionDetail = ( output , context ) : ResourceSharePermissionDetail => { return { arn : __expectString ( output . arn ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , defaultVersion : __expectBoolean ( output . defaultVersion ) , isResourceTypeDefault : __expectBoolean ( output . isResourceTypeDefault ) , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , name : __expectString ( output . name ) , permission : __expectString ( output . permission ) , resourceType : __expectString ( output . resourceType ) , version : __expectString ( output . version ) , } as any ; } ; const deserializeAws_restJson1ResourceSharePermissionList = ( output , context ) : ResourceSharePermissionSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResourceSharePermissionSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ResourceSharePermissionSummary = ( output , context ) : ResourceSharePermissionSummary => { return { arn : __expectString ( output . arn ) , creationTime : output . creationTime !== undefined && output . creationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . creationTime ) ) ) : undefined , defaultVersion : __expectBoolean ( output . defaultVersion ) , isResourceTypeDefault : __expectBoolean ( output . isResourceTypeDefault ) , lastUpdatedTime : output . lastUpdatedTime !== undefined && output . lastUpdatedTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastUpdatedTime ) ) ) : undefined , name : __expectString ( output . name ) , resourceType : __expectString ( output . resourceType ) , status : __expectString ( output . status ) , version : __expectString ( output . version ) , } as any ; } ; const deserializeAws_restJson1ServiceNameAndResourceType = ( output , context ) : ServiceNameAndResourceType => { return { resourceRegionScope : __expectString ( output . resourceRegionScope ) , resourceType : __expectString ( output . resourceType ) , serviceName : __expectString ( output . serviceName ) , } as any ; } ; const deserializeAws_restJson1ServiceNameAndResourceTypeList = ( output , context ) : ServiceNameAndResourceType [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ServiceNameAndResourceType ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Tag = ( output , context ) : Tag => { return { key : __expectString ( output . key ) , value : __expectString ( output . value ) , } as any ; } ; const deserializeAws_restJson1TagList = ( output , context ) : Tag [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Tag ( entry , context ) ; } ) ; } ; const deserializeMetadata = ( output ) : __ResponseMetadata => ( { httpStatusCode : output . statusCode , requestId : output . headers [ "x-amzn-requestid" ] ?? output . headers [ "x-amzn-request-id" ] , extendedRequestId : output . headers [ "x-amz-id-2" ] , cfId : output . headers [ "x-amz-cf-id" ] , } ) ; const collectBody = ( streamBody = new Uint8Array ( ) , context ) : Promise < Uint8Array > => { if ( streamBody instanceof Uint8Array ) { return Promise . resolve ( streamBody ) ; } return context . streamCollector ( streamBody ) || Promise . resolve ( new Uint8Array ( ) ) ; } ; const collectBodyString = ( streamBody , context ) : Promise < string > => collectBody ( streamBody , context ) . then ( ( body ) => context . utf8Encoder ( body ) ) ; const isSerializableHeaderValue = ( value ) : boolean => value !== undefined && value !== null && value !== "" && ( ! Object . getOwnPropertyNames ( value ) . includes ( "length" ) || value . length != 0 ) && ( ! Object . getOwnPropertyNames ( value ) . includes ( "size" ) || value . size != 0 ) ; const parseBody = ( streamBody , context ) : any => collectBodyString ( streamBody , context ) . then ( ( encoded ) => { if ( encoded . length ) { return JSON . parse ( encoded ) ; } return { } ; } ) ; /**
 * Load an error code for the aws.rest-json-1.1 protocol.
 */ const loadRestJsonErrorCode = ( output , data ) : string => { const findKey = ( object , key ) => Object . keys ( object ) . find ( ( k ) => k . toLowerCase ( ) === key . toLowerCase ( ) ) ; const sanitizeErrorCode = ( rawValue ) : string => { let cleanValue = rawValue ; if ( cleanValue . indexOf ( ":" ) >= 0 ) { cleanValue = cleanValue . split ( ":" ) [ 0 ] ; } if ( cleanValue . indexOf ( "#" ) >= 0 ) { cleanValue = cleanValue . split ( "#" ) [ 1 ] ; } return cleanValue ; } ; const headerKey = findKey ( output . headers , "x-amzn-errortype" ) ; if ( headerKey !== undefined ) { return sanitizeErrorCode ( output . headers [ headerKey ] ) ; } if ( data . code !== undefined ) { return sanitizeErrorCode ( data . code ) ; } if ( data [ "__type" ] !== undefined ) { return sanitizeErrorCode ( data [ "__type" ] ) ; } return "" ; } ;