import { HttpRequest as __HttpRequest , HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http" ; import { expectInt32 as __expectInt32 , expectNonNull as __expectNonNull , expectNumber as __expectNumber , expectObject as __expectObject , expectString as __expectString , expectUnion as __expectUnion , extendedEncodeURIComponent as __extendedEncodeURIComponent , limitedParseDouble as __limitedParseDouble , 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 { v4 as generateIdempotencyToken } from "uuid" ; import { CreateAssistantAssociationCommandInput , CreateAssistantAssociationCommandOutput , } from "../commands/CreateAssistantAssociationCommand" ; import { CreateAssistantCommandInput , CreateAssistantCommandOutput } from "../commands/CreateAssistantCommand" ; import { CreateContentCommandInput , CreateContentCommandOutput } from "../commands/CreateContentCommand" ; import { CreateKnowledgeBaseCommandInput , CreateKnowledgeBaseCommandOutput , } from "../commands/CreateKnowledgeBaseCommand" ; import { CreateSessionCommandInput , CreateSessionCommandOutput } from "../commands/CreateSessionCommand" ; import { DeleteAssistantAssociationCommandInput , DeleteAssistantAssociationCommandOutput , } from "../commands/DeleteAssistantAssociationCommand" ; import { DeleteAssistantCommandInput , DeleteAssistantCommandOutput } from "../commands/DeleteAssistantCommand" ; import { DeleteContentCommandInput , DeleteContentCommandOutput } from "../commands/DeleteContentCommand" ; import { DeleteKnowledgeBaseCommandInput , DeleteKnowledgeBaseCommandOutput , } from "../commands/DeleteKnowledgeBaseCommand" ; import { GetAssistantAssociationCommandInput , GetAssistantAssociationCommandOutput , } from "../commands/GetAssistantAssociationCommand" ; import { GetAssistantCommandInput , GetAssistantCommandOutput } from "../commands/GetAssistantCommand" ; import { GetContentCommandInput , GetContentCommandOutput } from "../commands/GetContentCommand" ; import { GetContentSummaryCommandInput , GetContentSummaryCommandOutput } from "../commands/GetContentSummaryCommand" ; import { GetKnowledgeBaseCommandInput , GetKnowledgeBaseCommandOutput } from "../commands/GetKnowledgeBaseCommand" ; import { GetRecommendationsCommandInput , GetRecommendationsCommandOutput } from "../commands/GetRecommendationsCommand" ; import { GetSessionCommandInput , GetSessionCommandOutput } from "../commands/GetSessionCommand" ; import { ListAssistantAssociationsCommandInput , ListAssistantAssociationsCommandOutput , } from "../commands/ListAssistantAssociationsCommand" ; import { ListAssistantsCommandInput , ListAssistantsCommandOutput } from "../commands/ListAssistantsCommand" ; import { ListContentsCommandInput , ListContentsCommandOutput } from "../commands/ListContentsCommand" ; import { ListKnowledgeBasesCommandInput , ListKnowledgeBasesCommandOutput } from "../commands/ListKnowledgeBasesCommand" ; import { ListTagsForResourceCommandInput , ListTagsForResourceCommandOutput , } from "../commands/ListTagsForResourceCommand" ; import { NotifyRecommendationsReceivedCommandInput , NotifyRecommendationsReceivedCommandOutput , } from "../commands/NotifyRecommendationsReceivedCommand" ; import { QueryAssistantCommandInput , QueryAssistantCommandOutput } from "../commands/QueryAssistantCommand" ; import { RemoveKnowledgeBaseTemplateUriCommandInput , RemoveKnowledgeBaseTemplateUriCommandOutput , } from "../commands/RemoveKnowledgeBaseTemplateUriCommand" ; import { SearchContentCommandInput , SearchContentCommandOutput } from "../commands/SearchContentCommand" ; import { SearchSessionsCommandInput , SearchSessionsCommandOutput } from "../commands/SearchSessionsCommand" ; import { StartContentUploadCommandInput , StartContentUploadCommandOutput } from "../commands/StartContentUploadCommand" ; import { TagResourceCommandInput , TagResourceCommandOutput } from "../commands/TagResourceCommand" ; import { UntagResourceCommandInput , UntagResourceCommandOutput } from "../commands/UntagResourceCommand" ; import { UpdateContentCommandInput , UpdateContentCommandOutput } from "../commands/UpdateContentCommand" ; import { UpdateKnowledgeBaseTemplateUriCommandInput , UpdateKnowledgeBaseTemplateUriCommandOutput , } from "../commands/UpdateKnowledgeBaseTemplateUriCommand" ; import { AccessDeniedException , AppIntegrationsConfiguration , AssistantAssociationData , AssistantAssociationInputData , AssistantAssociationOutputData , AssistantAssociationSummary , AssistantData , AssistantSummary , ConflictException , ContentData , ContentReference , ContentSummary , Document , DocumentText , Filter , Highlight , KnowledgeBaseAssociationData , KnowledgeBaseData , KnowledgeBaseSummary , NotifyRecommendationsReceivedError , PreconditionFailedException , RecommendationData , RenderingConfiguration , ResourceNotFoundException , ResultData , SearchExpression , ServerSideEncryptionConfiguration , ServiceQuotaExceededException , SessionData , SessionSummary , SourceConfiguration , TooManyTagsException , ValidationException , } from "../models/models_0" ; export const serializeAws_restJson1CreateAssistantCommand = 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 || "" }` + "/assistants" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . description !== undefined && input . description !== null && { description : input . description } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . serverSideEncryptionConfiguration !== undefined && input . serverSideEncryptionConfiguration !== null && { serverSideEncryptionConfiguration : serializeAws_restJson1ServerSideEncryptionConfiguration ( input . serverSideEncryptionConfiguration , context ) , } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , ... ( input . type !== undefined && input . type !== null && { type : input . type } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateAssistantAssociationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/associations" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; body = JSON . stringify ( { ... ( input . association !== undefined && input . association !== null && { association : serializeAws_restJson1AssistantAssociationInputData ( input . association , context ) , } ) , ... ( input . associationType !== undefined && input . associationType !== null && { associationType : input . associationType } ) , clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateContentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . metadata !== undefined && input . metadata !== null && { metadata : serializeAws_restJson1ContentMetadata ( input . metadata , context ) } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . overrideLinkOutUri !== undefined && input . overrideLinkOutUri !== null && { overrideLinkOutUri : input . overrideLinkOutUri } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , ... ( input . uploadId !== undefined && input . uploadId !== null && { uploadId : input . uploadId } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateKnowledgeBaseCommand = 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 || "" }` + "/knowledgeBases" ; let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . description !== undefined && input . description !== null && { description : input . description } ) , ... ( input . knowledgeBaseType !== undefined && input . knowledgeBaseType !== null && { knowledgeBaseType : input . knowledgeBaseType } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . renderingConfiguration !== undefined && input . renderingConfiguration !== null && { renderingConfiguration : serializeAws_restJson1RenderingConfiguration ( input . renderingConfiguration , context ) , } ) , ... ( input . serverSideEncryptionConfiguration !== undefined && input . serverSideEncryptionConfiguration !== null && { serverSideEncryptionConfiguration : serializeAws_restJson1ServerSideEncryptionConfiguration ( input . serverSideEncryptionConfiguration , context ) , } ) , ... ( input . sourceConfiguration !== undefined && input . sourceConfiguration !== null && { sourceConfiguration : serializeAws_restJson1SourceConfiguration ( input . sourceConfiguration , context ) , } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1CreateSessionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/sessions" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; body = JSON . stringify ( { clientToken : input . clientToken ?? generateIdempotencyToken ( ) , ... ( input . description !== undefined && input . description !== null && { description : input . description } ) , ... ( input . name !== undefined && input . name !== null && { name : input . name } ) , ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( input . tags , context ) } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteAssistantCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteAssistantAssociationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/associations/{assistantAssociationId}" ; if ( input . assistantAssociationId !== undefined ) { const labelValue = input . assistantAssociationId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantAssociationId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantAssociationId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantAssociationId." ) ; } if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteContentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents/{contentId}" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } if ( input . contentId !== undefined ) { const labelValue = input . contentId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: contentId." ) ; } resolvedPath = resolvedPath . replace ( "{contentId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: contentId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1DeleteKnowledgeBaseCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetAssistantCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetAssistantAssociationCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/associations/{assistantAssociationId}" ; if ( input . assistantAssociationId !== undefined ) { const labelValue = input . assistantAssociationId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantAssociationId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantAssociationId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantAssociationId." ) ; } if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetContentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents/{contentId}" ; if ( input . contentId !== undefined ) { const labelValue = input . contentId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: contentId." ) ; } resolvedPath = resolvedPath . replace ( "{contentId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: contentId." ) ; } if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetContentSummaryCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents/{contentId}/summary" ; if ( input . contentId !== undefined ) { const labelValue = input . contentId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: contentId." ) ; } resolvedPath = resolvedPath . replace ( "{contentId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: contentId." ) ; } if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetKnowledgeBaseCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1GetRecommendationsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/sessions/{sessionId}/recommendations" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } if ( input . sessionId !== undefined ) { const labelValue = input . sessionId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: sessionId." ) ; } resolvedPath = resolvedPath . replace ( "{sessionId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: sessionId." ) ; } const query = { ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , ... ( input . waitTimeSeconds !== undefined && { waitTimeSeconds : input . waitTimeSeconds . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1GetSessionCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/sessions/{sessionId}" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } if ( input . sessionId !== undefined ) { const labelValue = input . sessionId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: sessionId." ) ; } resolvedPath = resolvedPath . replace ( "{sessionId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: sessionId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1ListAssistantAssociationsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/associations" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListAssistantsCommand = 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 || "" }` + "/assistants" ; const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListContentsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListKnowledgeBasesCommand = 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 || "" }` + "/knowledgeBases" ; const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1ListTagsForResourceCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "GET" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1NotifyRecommendationsReceivedCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/sessions/{sessionId}/recommendations/notify" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } if ( input . sessionId !== undefined ) { const labelValue = input . sessionId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: sessionId." ) ; } resolvedPath = resolvedPath . replace ( "{sessionId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: sessionId." ) ; } let body ; body = JSON . stringify ( { ... ( input . recommendationIds !== undefined && input . recommendationIds !== null && { recommendationIds : serializeAws_restJson1RecommendationIdList ( input . recommendationIds , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1QueryAssistantCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/query" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } let body ; body = JSON . stringify ( { ... ( input . maxResults !== undefined && input . maxResults !== null && { maxResults : input . maxResults } ) , ... ( input . nextToken !== undefined && input . nextToken !== null && { nextToken : input . nextToken } ) , ... ( input . queryText !== undefined && input . queryText !== null && { queryText : input . queryText } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1RemoveKnowledgeBaseTemplateUriCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/templateUri" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1SearchContentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/search" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; body = JSON . stringify ( { ... ( input . searchExpression !== undefined && input . searchExpression !== null && { searchExpression : serializeAws_restJson1SearchExpression ( input . searchExpression , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1SearchSessionsCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/assistants/{assistantId}/searchSessions" ; if ( input . assistantId !== undefined ) { const labelValue = input . assistantId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: assistantId." ) ; } resolvedPath = resolvedPath . replace ( "{assistantId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: assistantId." ) ; } const query = { ... ( input . nextToken !== undefined && { nextToken : input . nextToken } ) , ... ( input . maxResults !== undefined && { maxResults : input . maxResults . toString ( ) } ) , } ; let body ; body = JSON . stringify ( { ... ( input . searchExpression !== undefined && input . searchExpression !== null && { searchExpression : serializeAws_restJson1SearchExpression ( input . searchExpression , context ) , } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1StartContentUploadCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/upload" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; body = JSON . stringify ( { ... ( input . contentType !== undefined && input . contentType !== null && { contentType : input . contentType } ) , } ) ; 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" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } let body ; body = JSON . stringify ( { ... ( input . tags !== undefined && input . tags !== null && { tags : serializeAws_restJson1Tags ( 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 = { } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/tags/{resourceArn}" ; if ( input . resourceArn !== undefined ) { const labelValue = input . resourceArn ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: resourceArn." ) ; } resolvedPath = resolvedPath . replace ( "{resourceArn}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: resourceArn." ) ; } const query = { ... ( input . tagKeys !== undefined && { tagKeys : ( input . tagKeys || [ ] ) . map ( ( _entry ) => _entry as any ) } ) , } ; let body ; return new __HttpRequest ( { protocol , hostname , port , method : "DELETE" , headers , path : resolvedPath , query , body , } ) ; } ; export const serializeAws_restJson1UpdateContentCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/contents/{contentId}" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } if ( input . contentId !== undefined ) { const labelValue = input . contentId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: contentId." ) ; } resolvedPath = resolvedPath . replace ( "{contentId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: contentId." ) ; } let body ; body = JSON . stringify ( { ... ( input . metadata !== undefined && input . metadata !== null && { metadata : serializeAws_restJson1ContentMetadata ( input . metadata , context ) } ) , ... ( input . overrideLinkOutUri !== undefined && input . overrideLinkOutUri !== null && { overrideLinkOutUri : input . overrideLinkOutUri } ) , ... ( input . removeOverrideLinkOutUri !== undefined && input . removeOverrideLinkOutUri !== null && { removeOverrideLinkOutUri : input . removeOverrideLinkOutUri } ) , ... ( input . revisionId !== undefined && input . revisionId !== null && { revisionId : input . revisionId } ) , ... ( input . title !== undefined && input . title !== null && { title : input . title } ) , ... ( input . uploadId !== undefined && input . uploadId !== null && { uploadId : input . uploadId } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const serializeAws_restJson1UpdateKnowledgeBaseTemplateUriCommand = async ( input , context ) : Promise < __HttpRequest > => { const { hostname , protocol = "https" , port , path : basePath } = await context . endpoint ( ) ; const headers = { "content-type" : "application/json" , } ; let resolvedPath = `${ basePath ?. endsWith ( "/" ) ? basePath . slice ( 0 , - 1 ) : basePath || "" }` + "/knowledgeBases/{knowledgeBaseId}/templateUri" ; if ( input . knowledgeBaseId !== undefined ) { const labelValue = input . knowledgeBaseId ; if ( labelValue . length <= 0 ) { throw new Error ( "Empty value provided for input HTTP label: knowledgeBaseId." ) ; } resolvedPath = resolvedPath . replace ( "{knowledgeBaseId}" , __extendedEncodeURIComponent ( labelValue ) ) ; } else { throw new Error ( "No value provided for input HTTP label: knowledgeBaseId." ) ; } let body ; body = JSON . stringify ( { ... ( input . templateUri !== undefined && input . templateUri !== null && { templateUri : input . templateUri } ) , } ) ; return new __HttpRequest ( { protocol , hostname , port , method : "POST" , headers , path : resolvedPath , body , } ) ; } ; export const deserializeAws_restJson1CreateAssistantCommand = async ( output , context ) : Promise < CreateAssistantCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateAssistantCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistant : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistant !== undefined && data . assistant !== null ) { contents . assistant = deserializeAws_restJson1AssistantData ( data . assistant , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateAssistantCommandError = async ( output , context ) : Promise < CreateAssistantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.wisdom#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateAssistantAssociationCommand = async ( output , context ) : Promise < CreateAssistantAssociationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateAssistantAssociationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistantAssociation : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistantAssociation !== undefined && data . assistantAssociation !== null ) { contents . assistantAssociation = deserializeAws_restJson1AssistantAssociationData ( data . assistantAssociation , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateAssistantAssociationCommandError = async ( output , context ) : Promise < CreateAssistantAssociationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.wisdom#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateContentCommand = async ( output , context ) : Promise < CreateContentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateContentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , content : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . content !== undefined && data . content !== null ) { contents . content = deserializeAws_restJson1ContentData ( data . content , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateContentCommandError = async ( output , context ) : Promise < CreateContentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.wisdom#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateKnowledgeBaseCommand = async ( output , context ) : Promise < CreateKnowledgeBaseCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateKnowledgeBaseCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , knowledgeBase : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . knowledgeBase !== undefined && data . knowledgeBase !== null ) { contents . knowledgeBase = deserializeAws_restJson1KnowledgeBaseData ( data . knowledgeBase , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateKnowledgeBaseCommandError = async ( output , context ) : Promise < CreateKnowledgeBaseCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ServiceQuotaExceededException" : case "com.amazonaws.wisdom#ServiceQuotaExceededException" : response = { ... ( await deserializeAws_restJson1ServiceQuotaExceededExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1CreateSessionCommand = async ( output , context ) : Promise < CreateSessionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1CreateSessionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , session : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . session !== undefined && data . session !== null ) { contents . session = deserializeAws_restJson1SessionData ( data . session , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1CreateSessionCommandError = async ( output , context ) : Promise < CreateSessionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteAssistantCommand = async ( output , context ) : Promise < DeleteAssistantCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteAssistantCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteAssistantCommandError = async ( output , context ) : Promise < DeleteAssistantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteAssistantAssociationCommand = async ( output , context ) : Promise < DeleteAssistantAssociationCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteAssistantAssociationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteAssistantAssociationCommandError = async ( output , context ) : Promise < DeleteAssistantAssociationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteContentCommand = async ( output , context ) : Promise < DeleteContentCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteContentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteContentCommandError = async ( output , context ) : Promise < DeleteContentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1DeleteKnowledgeBaseCommand = async ( output , context ) : Promise < DeleteKnowledgeBaseCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1DeleteKnowledgeBaseCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1DeleteKnowledgeBaseCommandError = async ( output , context ) : Promise < DeleteKnowledgeBaseCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ConflictException" : case "com.amazonaws.wisdom#ConflictException" : response = { ... ( await deserializeAws_restJson1ConflictExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1GetAssistantCommand = async ( output , context ) : Promise < GetAssistantCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetAssistantCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistant : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistant !== undefined && data . assistant !== null ) { contents . assistant = deserializeAws_restJson1AssistantData ( data . assistant , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetAssistantCommandError = async ( output , context ) : Promise < GetAssistantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetAssistantAssociationCommand = async ( output , context ) : Promise < GetAssistantAssociationCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetAssistantAssociationCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistantAssociation : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistantAssociation !== undefined && data . assistantAssociation !== null ) { contents . assistantAssociation = deserializeAws_restJson1AssistantAssociationData ( data . assistantAssociation , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetAssistantAssociationCommandError = async ( output , context ) : Promise < GetAssistantAssociationCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetContentCommand = async ( output , context ) : Promise < GetContentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetContentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , content : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . content !== undefined && data . content !== null ) { contents . content = deserializeAws_restJson1ContentData ( data . content , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetContentCommandError = async ( output , context ) : Promise < GetContentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetContentSummaryCommand = async ( output , context ) : Promise < GetContentSummaryCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetContentSummaryCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , contentSummary : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . contentSummary !== undefined && data . contentSummary !== null ) { contents . contentSummary = deserializeAws_restJson1ContentSummary ( data . contentSummary , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetContentSummaryCommandError = async ( output , context ) : Promise < GetContentSummaryCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetKnowledgeBaseCommand = async ( output , context ) : Promise < GetKnowledgeBaseCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetKnowledgeBaseCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , knowledgeBase : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . knowledgeBase !== undefined && data . knowledgeBase !== null ) { contents . knowledgeBase = deserializeAws_restJson1KnowledgeBaseData ( data . knowledgeBase , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetKnowledgeBaseCommandError = async ( output , context ) : Promise < GetKnowledgeBaseCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetRecommendationsCommand = async ( output , context ) : Promise < GetRecommendationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetRecommendationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , recommendations : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . recommendations !== undefined && data . recommendations !== null ) { contents . recommendations = deserializeAws_restJson1RecommendationList ( data . recommendations , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetRecommendationsCommandError = async ( output , context ) : Promise < GetRecommendationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1GetSessionCommand = async ( output , context ) : Promise < GetSessionCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1GetSessionCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , session : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . session !== undefined && data . session !== null ) { contents . session = deserializeAws_restJson1SessionData ( data . session , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1GetSessionCommandError = async ( output , context ) : Promise < GetSessionCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListAssistantAssociationsCommand = async ( output , context ) : Promise < ListAssistantAssociationsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListAssistantAssociationsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistantAssociationSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistantAssociationSummaries !== undefined && data . assistantAssociationSummaries !== null ) { contents . assistantAssociationSummaries = deserializeAws_restJson1AssistantAssociationSummaryList ( data . assistantAssociationSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListAssistantAssociationsCommandError = async ( output , context ) : Promise < ListAssistantAssociationsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListAssistantsCommand = async ( output , context ) : Promise < ListAssistantsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListAssistantsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , assistantSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . assistantSummaries !== undefined && data . assistantSummaries !== null ) { contents . assistantSummaries = deserializeAws_restJson1AssistantList ( data . assistantSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListAssistantsCommandError = async ( output , context ) : Promise < ListAssistantsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListContentsCommand = async ( output , context ) : Promise < ListContentsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListContentsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , contentSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . contentSummaries !== undefined && data . contentSummaries !== null ) { contents . contentSummaries = deserializeAws_restJson1ContentSummaryList ( data . contentSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListContentsCommandError = async ( output , context ) : Promise < ListContentsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListKnowledgeBasesCommand = async ( output , context ) : Promise < ListKnowledgeBasesCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListKnowledgeBasesCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , knowledgeBaseSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . knowledgeBaseSummaries !== undefined && data . knowledgeBaseSummaries !== null ) { contents . knowledgeBaseSummaries = deserializeAws_restJson1KnowledgeBaseList ( data . knowledgeBaseSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListKnowledgeBasesCommandError = async ( output , context ) : Promise < ListKnowledgeBasesCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1ListTagsForResourceCommand = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1ListTagsForResourceCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , tags : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . tags !== undefined && data . tags !== null ) { contents . tags = deserializeAws_restJson1Tags ( data . tags , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1ListTagsForResourceCommandError = async ( output , context ) : Promise < ListTagsForResourceCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1NotifyRecommendationsReceivedCommand = async ( output , context ) : Promise < NotifyRecommendationsReceivedCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1NotifyRecommendationsReceivedCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , errors : undefined , recommendationIds : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . errors !== undefined && data . errors !== null ) { contents . errors = deserializeAws_restJson1NotifyRecommendationsReceivedErrorList ( data . errors , context ) ; } if ( data . recommendationIds !== undefined && data . recommendationIds !== null ) { contents . recommendationIds = deserializeAws_restJson1RecommendationIdList ( data . recommendationIds , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1NotifyRecommendationsReceivedCommandError = async ( output , context ) : Promise < NotifyRecommendationsReceivedCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1QueryAssistantCommand = async ( output , context ) : Promise < QueryAssistantCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1QueryAssistantCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , results : 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 . results !== undefined && data . results !== null ) { contents . results = deserializeAws_restJson1QueryResultsList ( data . results , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1QueryAssistantCommandError = async ( output , context ) : Promise < QueryAssistantCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1RemoveKnowledgeBaseTemplateUriCommand = async ( output , context ) : Promise < RemoveKnowledgeBaseTemplateUriCommandOutput > => { if ( output . statusCode !== 204 && output . statusCode >= 300 ) { return deserializeAws_restJson1RemoveKnowledgeBaseTemplateUriCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , } ; await collectBody ( output . body , context ) ; return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1RemoveKnowledgeBaseTemplateUriCommandError = async ( output , context ) : Promise < RemoveKnowledgeBaseTemplateUriCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1SearchContentCommand = async ( output , context ) : Promise < SearchContentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1SearchContentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , contentSummaries : undefined , nextToken : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . contentSummaries !== undefined && data . contentSummaries !== null ) { contents . contentSummaries = deserializeAws_restJson1ContentSummaryList ( data . contentSummaries , context ) ; } if ( data . nextToken !== undefined && data . nextToken !== null ) { contents . nextToken = __expectString ( data . nextToken ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1SearchContentCommandError = async ( output , context ) : Promise < SearchContentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1SearchSessionsCommand = async ( output , context ) : Promise < SearchSessionsCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1SearchSessionsCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , nextToken : undefined , sessionSummaries : 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 . sessionSummaries !== undefined && data . sessionSummaries !== null ) { contents . sessionSummaries = deserializeAws_restJson1SessionSummaries ( data . sessionSummaries , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1SearchSessionsCommandError = async ( output , context ) : Promise < SearchSessionsCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1StartContentUploadCommand = async ( output , context ) : Promise < StartContentUploadCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1StartContentUploadCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , headersToInclude : undefined , uploadId : undefined , url : undefined , urlExpiry : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . headersToInclude !== undefined && data . headersToInclude !== null ) { contents . headersToInclude = deserializeAws_restJson1Headers ( data . headersToInclude , context ) ; } if ( data . uploadId !== undefined && data . uploadId !== null ) { contents . uploadId = __expectString ( data . uploadId ) ; } if ( data . url !== undefined && data . url !== null ) { contents . url = __expectString ( data . url ) ; } if ( data . urlExpiry !== undefined && data . urlExpiry !== null ) { contents . urlExpiry = __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( data . urlExpiry ) ) ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1StartContentUploadCommandError = async ( output , context ) : Promise < StartContentUploadCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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 "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "TooManyTagsException" : case "com.amazonaws.wisdom#TooManyTagsException" : response = { ... ( await deserializeAws_restJson1TooManyTagsExceptionResponse ( 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 "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( 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_restJson1UpdateContentCommand = async ( output , context ) : Promise < UpdateContentCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateContentCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , content : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . content !== undefined && data . content !== null ) { contents . content = deserializeAws_restJson1ContentData ( data . content , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateContentCommandError = async ( output , context ) : Promise < UpdateContentCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "PreconditionFailedException" : case "com.amazonaws.wisdom#PreconditionFailedException" : response = { ... ( await deserializeAws_restJson1PreconditionFailedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1UpdateKnowledgeBaseTemplateUriCommand = async ( output , context ) : Promise < UpdateKnowledgeBaseTemplateUriCommandOutput > => { if ( output . statusCode !== 200 && output . statusCode >= 300 ) { return deserializeAws_restJson1UpdateKnowledgeBaseTemplateUriCommandError ( output , context ) ; } const contents = { $metadata : deserializeMetadata ( output ) , knowledgeBase : undefined , } ; const data = __expectNonNull ( __expectObject ( await parseBody ( output . body , context ) ) , "body" ) ; if ( data . knowledgeBase !== undefined && data . knowledgeBase !== null ) { contents . knowledgeBase = deserializeAws_restJson1KnowledgeBaseData ( data . knowledgeBase , context ) ; } return Promise . resolve ( contents ) ; } ; const deserializeAws_restJson1UpdateKnowledgeBaseTemplateUriCommandError = async ( output , context ) : Promise < UpdateKnowledgeBaseTemplateUriCommandOutput > => { const parsedOutput = { ... output , body : await parseBody ( output . body , context ) , } ; let response ; let errorCode = "UnknownError" ; errorCode = loadRestJsonErrorCode ( output , parsedOutput . body ) ; switch ( errorCode ) { case "AccessDeniedException" : case "com.amazonaws.wisdom#AccessDeniedException" : response = { ... ( await deserializeAws_restJson1AccessDeniedExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ResourceNotFoundException" : case "com.amazonaws.wisdom#ResourceNotFoundException" : response = { ... ( await deserializeAws_restJson1ResourceNotFoundExceptionResponse ( parsedOutput , context ) ) , name : errorCode , $metadata : deserializeMetadata ( output ) , } ; break ; case "ValidationException" : case "com.amazonaws.wisdom#ValidationException" : response = { ... ( await deserializeAws_restJson1ValidationExceptionResponse ( 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_restJson1AccessDeniedExceptionResponse = async ( parsedOutput , context ) : Promise < AccessDeniedException > => { const contents = { name : "AccessDeniedException" , $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_restJson1ConflictExceptionResponse = async ( parsedOutput , context ) : Promise < ConflictException > => { const contents = { name : "ConflictException" , $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_restJson1PreconditionFailedExceptionResponse = async ( parsedOutput , context ) : Promise < PreconditionFailedException > => { const contents = { name : "PreconditionFailedException" , $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_restJson1ResourceNotFoundExceptionResponse = async ( parsedOutput , context ) : Promise < ResourceNotFoundException > => { const contents = { name : "ResourceNotFoundException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , resourceName : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . resourceName !== undefined && data . resourceName !== null ) { contents . resourceName = __expectString ( data . resourceName ) ; } return contents ; } ; const deserializeAws_restJson1ServiceQuotaExceededExceptionResponse = async ( parsedOutput , context ) : Promise < ServiceQuotaExceededException > => { const contents = { name : "ServiceQuotaExceededException" , $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_restJson1TooManyTagsExceptionResponse = async ( parsedOutput , context ) : Promise < TooManyTagsException > => { const contents = { name : "TooManyTagsException" , $fault : "client" , $metadata : deserializeMetadata ( parsedOutput ) , message : undefined , resourceName : undefined , } ; const data = parsedOutput . body ; if ( data . message !== undefined && data . message !== null ) { contents . message = __expectString ( data . message ) ; } if ( data . resourceName !== undefined && data . resourceName !== null ) { contents . resourceName = __expectString ( data . resourceName ) ; } return contents ; } ; const deserializeAws_restJson1ValidationExceptionResponse = async ( parsedOutput , context ) : Promise < ValidationException > => { const contents = { name : "ValidationException" , $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_restJson1AppIntegrationsConfiguration = ( input , context ) : any => { return { ... ( input . appIntegrationArn !== undefined && input . appIntegrationArn !== null && { appIntegrationArn : input . appIntegrationArn } ) , ... ( input . objectFields !== undefined && input . objectFields !== null && { objectFields : serializeAws_restJson1ObjectFieldsList ( input . objectFields , context ) , } ) , } ; } ; const serializeAws_restJson1AssistantAssociationInputData = ( input , context ) : any => { return AssistantAssociationInputData . visit ( input , { knowledgeBaseId : ( value ) => ( { knowledgeBaseId : value } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1ContentMetadata = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const serializeAws_restJson1Filter = ( input , context ) : any => { return { ... ( input . field !== undefined && input . field !== null && { field : input . field } ) , ... ( input . operator !== undefined && input . operator !== null && { operator : input . operator } ) , ... ( input . value !== undefined && input . value !== null && { value : input . value } ) , } ; } ; const serializeAws_restJson1FilterList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return serializeAws_restJson1Filter ( entry , context ) ; } ) ; } ; const serializeAws_restJson1ObjectFieldsList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1RecommendationIdList = ( input , context ) : any => { return input . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return entry ; } ) ; } ; const serializeAws_restJson1RenderingConfiguration = ( input , context ) : any => { return { ... ( input . templateUri !== undefined && input . templateUri !== null && { templateUri : input . templateUri } ) , } ; } ; const serializeAws_restJson1SearchExpression = ( input , context ) : any => { return { ... ( input . filters !== undefined && input . filters !== null && { filters : serializeAws_restJson1FilterList ( input . filters , context ) } ) , } ; } ; const serializeAws_restJson1ServerSideEncryptionConfiguration = ( input , context ) : any => { return { ... ( input . kmsKeyId !== undefined && input . kmsKeyId !== null && { kmsKeyId : input . kmsKeyId } ) , } ; } ; const serializeAws_restJson1SourceConfiguration = ( input , context ) : any => { return SourceConfiguration . visit ( input , { appIntegrations : ( value ) => ( { appIntegrations : serializeAws_restJson1AppIntegrationsConfiguration ( value , context ) , } ) , _ : ( name , value ) => ( { name : value } as any ) , } ) ; } ; const serializeAws_restJson1Tags = ( input , context ) : any => { return Object . entries ( input ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : value , } ; } , { } ) ; } ; const deserializeAws_restJson1AppIntegrationsConfiguration = ( output , context ) : AppIntegrationsConfiguration => { return { appIntegrationArn : __expectString ( output . appIntegrationArn ) , objectFields : output . objectFields !== undefined && output . objectFields !== null ? deserializeAws_restJson1ObjectFieldsList ( output . objectFields , context ) : undefined , } as any ; } ; const deserializeAws_restJson1AssistantAssociationData = ( output , context ) : AssistantAssociationData => { return { assistantArn : __expectString ( output . assistantArn ) , assistantAssociationArn : __expectString ( output . assistantAssociationArn ) , assistantAssociationId : __expectString ( output . assistantAssociationId ) , assistantId : __expectString ( output . assistantId ) , associationData : output . associationData !== undefined && output . associationData !== null ? deserializeAws_restJson1AssistantAssociationOutputData ( __expectUnion ( output . associationData ) , context ) : undefined , associationType : __expectString ( output . associationType ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1AssistantAssociationOutputData = ( output , context ) : AssistantAssociationOutputData => { if ( output . knowledgeBaseAssociation !== undefined && output . knowledgeBaseAssociation !== null ) { return { knowledgeBaseAssociation : deserializeAws_restJson1KnowledgeBaseAssociationData ( output . knowledgeBaseAssociation , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1AssistantAssociationSummary = ( output , context ) : AssistantAssociationSummary => { return { assistantArn : __expectString ( output . assistantArn ) , assistantAssociationArn : __expectString ( output . assistantAssociationArn ) , assistantAssociationId : __expectString ( output . assistantAssociationId ) , assistantId : __expectString ( output . assistantId ) , associationData : output . associationData !== undefined && output . associationData !== null ? deserializeAws_restJson1AssistantAssociationOutputData ( __expectUnion ( output . associationData ) , context ) : undefined , associationType : __expectString ( output . associationType ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1AssistantAssociationSummaryList = ( output , context ) : AssistantAssociationSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1AssistantAssociationSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1AssistantData = ( output , context ) : AssistantData => { return { assistantArn : __expectString ( output . assistantArn ) , assistantId : __expectString ( output . assistantId ) , description : __expectString ( output . description ) , name : __expectString ( output . name ) , serverSideEncryptionConfiguration : output . serverSideEncryptionConfiguration !== undefined && output . serverSideEncryptionConfiguration !== null ? deserializeAws_restJson1ServerSideEncryptionConfiguration ( output . serverSideEncryptionConfiguration , context ) : undefined , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1AssistantList = ( output , context ) : AssistantSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1AssistantSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1AssistantSummary = ( output , context ) : AssistantSummary => { return { assistantArn : __expectString ( output . assistantArn ) , assistantId : __expectString ( output . assistantId ) , description : __expectString ( output . description ) , name : __expectString ( output . name ) , serverSideEncryptionConfiguration : output . serverSideEncryptionConfiguration !== undefined && output . serverSideEncryptionConfiguration !== null ? deserializeAws_restJson1ServerSideEncryptionConfiguration ( output . serverSideEncryptionConfiguration , context ) : undefined , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , type : __expectString ( output . type ) , } as any ; } ; const deserializeAws_restJson1ContentData = ( output , context ) : ContentData => { return { contentArn : __expectString ( output . contentArn ) , contentId : __expectString ( output . contentId ) , contentType : __expectString ( output . contentType ) , knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , linkOutUri : __expectString ( output . linkOutUri ) , metadata : output . metadata !== undefined && output . metadata !== null ? deserializeAws_restJson1ContentMetadata ( output . metadata , context ) : undefined , name : __expectString ( output . name ) , revisionId : __expectString ( output . revisionId ) , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , title : __expectString ( output . title ) , url : __expectString ( output . url ) , urlExpiry : output . urlExpiry !== undefined && output . urlExpiry !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . urlExpiry ) ) ) : undefined , } as any ; } ; const deserializeAws_restJson1ContentMetadata = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1ContentReference = ( output , context ) : ContentReference => { return { contentArn : __expectString ( output . contentArn ) , contentId : __expectString ( output . contentId ) , knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , } as any ; } ; const deserializeAws_restJson1ContentSummary = ( output , context ) : ContentSummary => { return { contentArn : __expectString ( output . contentArn ) , contentId : __expectString ( output . contentId ) , contentType : __expectString ( output . contentType ) , knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , metadata : output . metadata !== undefined && output . metadata !== null ? deserializeAws_restJson1ContentMetadata ( output . metadata , context ) : undefined , name : __expectString ( output . name ) , revisionId : __expectString ( output . revisionId ) , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , title : __expectString ( output . title ) , } as any ; } ; const deserializeAws_restJson1ContentSummaryList = ( output , context ) : ContentSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ContentSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1Document = ( output , context ) : Document => { return { contentReference : output . contentReference !== undefined && output . contentReference !== null ? deserializeAws_restJson1ContentReference ( output . contentReference , context ) : undefined , excerpt : output . excerpt !== undefined && output . excerpt !== null ? deserializeAws_restJson1DocumentText ( output . excerpt , context ) : undefined , title : output . title !== undefined && output . title !== null ? deserializeAws_restJson1DocumentText ( output . title , context ) : undefined , } as any ; } ; const deserializeAws_restJson1DocumentText = ( output , context ) : DocumentText => { return { highlights : output . highlights !== undefined && output . highlights !== null ? deserializeAws_restJson1Highlights ( output . highlights , context ) : undefined , text : __expectString ( output . text ) , } as any ; } ; const deserializeAws_restJson1Headers = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const deserializeAws_restJson1Highlight = ( output , context ) : Highlight => { return { beginOffsetInclusive : __expectInt32 ( output . beginOffsetInclusive ) , endOffsetExclusive : __expectInt32 ( output . endOffsetExclusive ) , } as any ; } ; const deserializeAws_restJson1Highlights = ( output , context ) : Highlight [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1Highlight ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1KnowledgeBaseAssociationData = ( output , context ) : KnowledgeBaseAssociationData => { return { knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , } as any ; } ; const deserializeAws_restJson1KnowledgeBaseData = ( output , context ) : KnowledgeBaseData => { return { description : __expectString ( output . description ) , knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , knowledgeBaseType : __expectString ( output . knowledgeBaseType ) , lastContentModificationTime : output . lastContentModificationTime !== undefined && output . lastContentModificationTime !== null ? __expectNonNull ( __parseEpochTimestamp ( __expectNumber ( output . lastContentModificationTime ) ) ) : undefined , name : __expectString ( output . name ) , renderingConfiguration : output . renderingConfiguration !== undefined && output . renderingConfiguration !== null ? deserializeAws_restJson1RenderingConfiguration ( output . renderingConfiguration , context ) : undefined , serverSideEncryptionConfiguration : output . serverSideEncryptionConfiguration !== undefined && output . serverSideEncryptionConfiguration !== null ? deserializeAws_restJson1ServerSideEncryptionConfiguration ( output . serverSideEncryptionConfiguration , context ) : undefined , sourceConfiguration : output . sourceConfiguration !== undefined && output . sourceConfiguration !== null ? deserializeAws_restJson1SourceConfiguration ( __expectUnion ( output . sourceConfiguration ) , context ) : undefined , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1KnowledgeBaseList = ( output , context ) : KnowledgeBaseSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1KnowledgeBaseSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1KnowledgeBaseSummary = ( output , context ) : KnowledgeBaseSummary => { return { description : __expectString ( output . description ) , knowledgeBaseArn : __expectString ( output . knowledgeBaseArn ) , knowledgeBaseId : __expectString ( output . knowledgeBaseId ) , knowledgeBaseType : __expectString ( output . knowledgeBaseType ) , name : __expectString ( output . name ) , renderingConfiguration : output . renderingConfiguration !== undefined && output . renderingConfiguration !== null ? deserializeAws_restJson1RenderingConfiguration ( output . renderingConfiguration , context ) : undefined , serverSideEncryptionConfiguration : output . serverSideEncryptionConfiguration !== undefined && output . serverSideEncryptionConfiguration !== null ? deserializeAws_restJson1ServerSideEncryptionConfiguration ( output . serverSideEncryptionConfiguration , context ) : undefined , sourceConfiguration : output . sourceConfiguration !== undefined && output . sourceConfiguration !== null ? deserializeAws_restJson1SourceConfiguration ( __expectUnion ( output . sourceConfiguration ) , context ) : undefined , status : __expectString ( output . status ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1NotifyRecommendationsReceivedError = ( output , context ) : NotifyRecommendationsReceivedError => { return { message : __expectString ( output . message ) , recommendationId : __expectString ( output . recommendationId ) , } as any ; } ; const deserializeAws_restJson1NotifyRecommendationsReceivedErrorList = ( output , context ) : NotifyRecommendationsReceivedError [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1NotifyRecommendationsReceivedError ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1ObjectFieldsList = ( 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_restJson1QueryResultsList = ( output , context ) : ResultData [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1ResultData ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1RecommendationData = ( output , context ) : RecommendationData => { return { document : output . document !== undefined && output . document !== null ? deserializeAws_restJson1Document ( output . document , context ) : undefined , recommendationId : __expectString ( output . recommendationId ) , relevanceLevel : __expectString ( output . relevanceLevel ) , relevanceScore : __limitedParseDouble ( output . relevanceScore ) , } as any ; } ; const deserializeAws_restJson1RecommendationIdList = ( 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_restJson1RecommendationList = ( output , context ) : RecommendationData [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1RecommendationData ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1RenderingConfiguration = ( output , context ) : RenderingConfiguration => { return { templateUri : __expectString ( output . templateUri ) , } as any ; } ; const deserializeAws_restJson1ResultData = ( output , context ) : ResultData => { return { document : output . document !== undefined && output . document !== null ? deserializeAws_restJson1Document ( output . document , context ) : undefined , relevanceScore : __limitedParseDouble ( output . relevanceScore ) , resultId : __expectString ( output . resultId ) , } as any ; } ; const deserializeAws_restJson1ServerSideEncryptionConfiguration = ( output , context ) : ServerSideEncryptionConfiguration => { return { kmsKeyId : __expectString ( output . kmsKeyId ) , } as any ; } ; const deserializeAws_restJson1SessionData = ( output , context ) : SessionData => { return { description : __expectString ( output . description ) , name : __expectString ( output . name ) , sessionArn : __expectString ( output . sessionArn ) , sessionId : __expectString ( output . sessionId ) , tags : output . tags !== undefined && output . tags !== null ? deserializeAws_restJson1Tags ( output . tags , context ) : undefined , } as any ; } ; const deserializeAws_restJson1SessionSummaries = ( output , context ) : SessionSummary [ ] => { return ( output || [ ] ) . filter ( ( e ) => e != null ) . map ( ( entry ) => { if ( entry === null ) { return null as any ; } return deserializeAws_restJson1SessionSummary ( entry , context ) ; } ) ; } ; const deserializeAws_restJson1SessionSummary = ( output , context ) : SessionSummary => { return { assistantArn : __expectString ( output . assistantArn ) , assistantId : __expectString ( output . assistantId ) , sessionArn : __expectString ( output . sessionArn ) , sessionId : __expectString ( output . sessionId ) , } as any ; } ; const deserializeAws_restJson1SourceConfiguration = ( output , context ) : SourceConfiguration => { if ( output . appIntegrations !== undefined && output . appIntegrations !== null ) { return { appIntegrations : deserializeAws_restJson1AppIntegrationsConfiguration ( output . appIntegrations , context ) , } ; } return { $unknown : Object . entries ( output ) [ 0 ] } ; } ; const deserializeAws_restJson1Tags = ( output , context ) : { [ key ] : string ; } => { return Object . entries ( output ) . reduce ( ( acc , [ key , value ] ) => { if ( value === null ) { return acc ; } return { ... acc , [ key ] : __expectString ( value ) as any , } ; } , { } ) ; } ; const 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 "" ; } ;