// Code generated by smithy-go-codegen DO NOT EDIT. package lexruntimeservice import ( "bytes" "context" "encoding/base64" "encoding/json" "fmt" "github.com/aws/aws-sdk-go-v2/aws/protocol/restjson" "github.com/aws/aws-sdk-go-v2/service/lexruntimeservice/types" smithy "github.com/aws/smithy-go" smithyio "github.com/aws/smithy-go/io" "github.com/aws/smithy-go/middleware" "github.com/aws/smithy-go/ptr" smithyhttp "github.com/aws/smithy-go/transport/http" "io" "math" "strings" ) type awsRestjson1_deserializeOpDeleteSession struct { } func (*awsRestjson1_deserializeOpDeleteSession) ID() string { return "OperationDeserializer" } func (m *awsRestjson1_deserializeOpDeleteSession) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) if err != nil { return out, metadata, err } response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorDeleteSession(response, &metadata) } output := &DeleteSessionOutput{} out.Result = output var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(response.Body, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return out, metadata, err } err = awsRestjson1_deserializeOpDocumentDeleteSessionOutput(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) return out, metadata, &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), Snapshot: snapshot.Bytes(), } } return out, metadata, err } func awsRestjson1_deserializeOpErrorDeleteSession(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} } errorBody := bytes.NewReader(errorBuffer.Bytes()) errorCode := "UnknownError" errorMessage := errorCode headerCode := response.Header.Get("X-Amzn-ErrorType") if len(headerCode) != 0 { errorCode = restjson.SanitizeErrorCode(headerCode) } var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() jsonCode, message, err := restjson.GetErrorInfo(decoder) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if len(headerCode) == 0 && len(jsonCode) != 0 { errorCode = restjson.SanitizeErrorCode(jsonCode) } if len(message) != 0 { errorMessage = message } switch { case strings.EqualFold("BadRequestException", errorCode): return awsRestjson1_deserializeErrorBadRequestException(response, errorBody) case strings.EqualFold("ConflictException", errorCode): return awsRestjson1_deserializeErrorConflictException(response, errorBody) case strings.EqualFold("InternalFailureException", errorCode): return awsRestjson1_deserializeErrorInternalFailureException(response, errorBody) case strings.EqualFold("LimitExceededException", errorCode): return awsRestjson1_deserializeErrorLimitExceededException(response, errorBody) case strings.EqualFold("NotFoundException", errorCode): return awsRestjson1_deserializeErrorNotFoundException(response, errorBody) default: genericError := &smithy.GenericAPIError{ Code: errorCode, Message: errorMessage, } return genericError } } func awsRestjson1_deserializeOpDocumentDeleteSessionOutput(v **DeleteSessionOutput, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *DeleteSessionOutput if *v == nil { sv = &DeleteSessionOutput{} } else { sv = *v } for key, value := range shape { switch key { case "botAlias": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected BotAlias to be of type string, got %T instead", value) } sv.BotAlias = ptr.String(jtv) } case "botName": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected BotName to be of type string, got %T instead", value) } sv.BotName = ptr.String(jtv) } case "sessionId": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SessionId = ptr.String(jtv) } case "userId": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected UserId to be of type string, got %T instead", value) } sv.UserId = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } type awsRestjson1_deserializeOpGetSession struct { } func (*awsRestjson1_deserializeOpGetSession) ID() string { return "OperationDeserializer" } func (m *awsRestjson1_deserializeOpGetSession) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) if err != nil { return out, metadata, err } response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorGetSession(response, &metadata) } output := &GetSessionOutput{} out.Result = output var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(response.Body, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return out, metadata, err } err = awsRestjson1_deserializeOpDocumentGetSessionOutput(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) return out, metadata, &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), Snapshot: snapshot.Bytes(), } } return out, metadata, err } func awsRestjson1_deserializeOpErrorGetSession(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} } errorBody := bytes.NewReader(errorBuffer.Bytes()) errorCode := "UnknownError" errorMessage := errorCode headerCode := response.Header.Get("X-Amzn-ErrorType") if len(headerCode) != 0 { errorCode = restjson.SanitizeErrorCode(headerCode) } var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() jsonCode, message, err := restjson.GetErrorInfo(decoder) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if len(headerCode) == 0 && len(jsonCode) != 0 { errorCode = restjson.SanitizeErrorCode(jsonCode) } if len(message) != 0 { errorMessage = message } switch { case strings.EqualFold("BadRequestException", errorCode): return awsRestjson1_deserializeErrorBadRequestException(response, errorBody) case strings.EqualFold("InternalFailureException", errorCode): return awsRestjson1_deserializeErrorInternalFailureException(response, errorBody) case strings.EqualFold("LimitExceededException", errorCode): return awsRestjson1_deserializeErrorLimitExceededException(response, errorBody) case strings.EqualFold("NotFoundException", errorCode): return awsRestjson1_deserializeErrorNotFoundException(response, errorBody) default: genericError := &smithy.GenericAPIError{ Code: errorCode, Message: errorMessage, } return genericError } } func awsRestjson1_deserializeOpDocumentGetSessionOutput(v **GetSessionOutput, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *GetSessionOutput if *v == nil { sv = &GetSessionOutput{} } else { sv = *v } for key, value := range shape { switch key { case "activeContexts": if err := awsRestjson1_deserializeDocumentActiveContextsList(&sv.ActiveContexts, value); err != nil { return err } case "dialogAction": if err := awsRestjson1_deserializeDocumentDialogAction(&sv.DialogAction, value); err != nil { return err } case "recentIntentSummaryView": if err := awsRestjson1_deserializeDocumentIntentSummaryList(&sv.RecentIntentSummaryView, value); err != nil { return err } case "sessionAttributes": if err := awsRestjson1_deserializeDocumentStringMap(&sv.SessionAttributes, value); err != nil { return err } case "sessionId": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SessionId = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } type awsRestjson1_deserializeOpPostContent struct { } func (*awsRestjson1_deserializeOpPostContent) ID() string { return "OperationDeserializer" } func (m *awsRestjson1_deserializeOpPostContent) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) if err != nil { return out, metadata, err } response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorPostContent(response, &metadata) } output := &PostContentOutput{} out.Result = output err = awsRestjson1_deserializeOpHttpBindingsPostContentOutput(output, response) if err != nil { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to decode response with invalid Http bindings, %w", err)} } err = awsRestjson1_deserializeOpDocumentPostContentOutput(output, response.Body) if err != nil { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to deserialize response payload, %w", err)} } return out, metadata, err } func awsRestjson1_deserializeOpErrorPostContent(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} } errorBody := bytes.NewReader(errorBuffer.Bytes()) errorCode := "UnknownError" errorMessage := errorCode headerCode := response.Header.Get("X-Amzn-ErrorType") if len(headerCode) != 0 { errorCode = restjson.SanitizeErrorCode(headerCode) } var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() jsonCode, message, err := restjson.GetErrorInfo(decoder) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if len(headerCode) == 0 && len(jsonCode) != 0 { errorCode = restjson.SanitizeErrorCode(jsonCode) } if len(message) != 0 { errorMessage = message } switch { case strings.EqualFold("BadGatewayException", errorCode): return awsRestjson1_deserializeErrorBadGatewayException(response, errorBody) case strings.EqualFold("BadRequestException", errorCode): return awsRestjson1_deserializeErrorBadRequestException(response, errorBody) case strings.EqualFold("ConflictException", errorCode): return awsRestjson1_deserializeErrorConflictException(response, errorBody) case strings.EqualFold("DependencyFailedException", errorCode): return awsRestjson1_deserializeErrorDependencyFailedException(response, errorBody) case strings.EqualFold("InternalFailureException", errorCode): return awsRestjson1_deserializeErrorInternalFailureException(response, errorBody) case strings.EqualFold("LimitExceededException", errorCode): return awsRestjson1_deserializeErrorLimitExceededException(response, errorBody) case strings.EqualFold("LoopDetectedException", errorCode): return awsRestjson1_deserializeErrorLoopDetectedException(response, errorBody) case strings.EqualFold("NotAcceptableException", errorCode): return awsRestjson1_deserializeErrorNotAcceptableException(response, errorBody) case strings.EqualFold("NotFoundException", errorCode): return awsRestjson1_deserializeErrorNotFoundException(response, errorBody) case strings.EqualFold("RequestTimeoutException", errorCode): return awsRestjson1_deserializeErrorRequestTimeoutException(response, errorBody) case strings.EqualFold("UnsupportedMediaTypeException", errorCode): return awsRestjson1_deserializeErrorUnsupportedMediaTypeException(response, errorBody) default: genericError := &smithy.GenericAPIError{ Code: errorCode, Message: errorMessage, } return genericError } } func awsRestjson1_deserializeOpHttpBindingsPostContentOutput(v *PostContentOutput, response *smithyhttp.Response) error { if v == nil { return fmt.Errorf("unsupported deserialization for nil %T", v) } if headerValues := response.Header.Values("x-amz-lex-active-contexts"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.ActiveContexts = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-alternative-intents"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.AlternativeIntents = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-bot-version"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.BotVersion = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("Content-Type"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.ContentType = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-dialog-state"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.DialogState = types.DialogState(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-encoded-input-transcript"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.EncodedInputTranscript = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-encoded-message"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.EncodedMessage = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-input-transcript"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.InputTranscript = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-intent-name"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.IntentName = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-message"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.Message = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-message-format"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.MessageFormat = types.MessageFormatType(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-nlu-intent-confidence"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.NluIntentConfidence = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-sentiment"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.SentimentResponse = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-session-attributes"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.SessionAttributes = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-session-id"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.SessionId = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-slots"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.Slots = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-slot-to-elicit"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.SlotToElicit = ptr.String(headerValues[0]) } return nil } func awsRestjson1_deserializeOpDocumentPostContentOutput(v *PostContentOutput, body io.ReadCloser) error { if v == nil { return fmt.Errorf("unsupported deserialization of nil %T", v) } v.AudioStream = body return nil } type awsRestjson1_deserializeOpPostText struct { } func (*awsRestjson1_deserializeOpPostText) ID() string { return "OperationDeserializer" } func (m *awsRestjson1_deserializeOpPostText) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) if err != nil { return out, metadata, err } response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorPostText(response, &metadata) } output := &PostTextOutput{} out.Result = output var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(response.Body, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return out, metadata, err } err = awsRestjson1_deserializeOpDocumentPostTextOutput(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) return out, metadata, &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body with invalid JSON, %w", err), Snapshot: snapshot.Bytes(), } } return out, metadata, err } func awsRestjson1_deserializeOpErrorPostText(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} } errorBody := bytes.NewReader(errorBuffer.Bytes()) errorCode := "UnknownError" errorMessage := errorCode headerCode := response.Header.Get("X-Amzn-ErrorType") if len(headerCode) != 0 { errorCode = restjson.SanitizeErrorCode(headerCode) } var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() jsonCode, message, err := restjson.GetErrorInfo(decoder) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if len(headerCode) == 0 && len(jsonCode) != 0 { errorCode = restjson.SanitizeErrorCode(jsonCode) } if len(message) != 0 { errorMessage = message } switch { case strings.EqualFold("BadGatewayException", errorCode): return awsRestjson1_deserializeErrorBadGatewayException(response, errorBody) case strings.EqualFold("BadRequestException", errorCode): return awsRestjson1_deserializeErrorBadRequestException(response, errorBody) case strings.EqualFold("ConflictException", errorCode): return awsRestjson1_deserializeErrorConflictException(response, errorBody) case strings.EqualFold("DependencyFailedException", errorCode): return awsRestjson1_deserializeErrorDependencyFailedException(response, errorBody) case strings.EqualFold("InternalFailureException", errorCode): return awsRestjson1_deserializeErrorInternalFailureException(response, errorBody) case strings.EqualFold("LimitExceededException", errorCode): return awsRestjson1_deserializeErrorLimitExceededException(response, errorBody) case strings.EqualFold("LoopDetectedException", errorCode): return awsRestjson1_deserializeErrorLoopDetectedException(response, errorBody) case strings.EqualFold("NotFoundException", errorCode): return awsRestjson1_deserializeErrorNotFoundException(response, errorBody) default: genericError := &smithy.GenericAPIError{ Code: errorCode, Message: errorMessage, } return genericError } } func awsRestjson1_deserializeOpDocumentPostTextOutput(v **PostTextOutput, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *PostTextOutput if *v == nil { sv = &PostTextOutput{} } else { sv = *v } for key, value := range shape { switch key { case "activeContexts": if err := awsRestjson1_deserializeDocumentActiveContextsList(&sv.ActiveContexts, value); err != nil { return err } case "alternativeIntents": if err := awsRestjson1_deserializeDocumentIntentList(&sv.AlternativeIntents, value); err != nil { return err } case "botVersion": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected BotVersion to be of type string, got %T instead", value) } sv.BotVersion = ptr.String(jtv) } case "dialogState": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected DialogState to be of type string, got %T instead", value) } sv.DialogState = types.DialogState(jtv) } case "intentName": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected IntentName to be of type string, got %T instead", value) } sv.IntentName = ptr.String(jtv) } case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected Text to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } case "messageFormat": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected MessageFormatType to be of type string, got %T instead", value) } sv.MessageFormat = types.MessageFormatType(jtv) } case "nluIntentConfidence": if err := awsRestjson1_deserializeDocumentIntentConfidence(&sv.NluIntentConfidence, value); err != nil { return err } case "responseCard": if err := awsRestjson1_deserializeDocumentResponseCard(&sv.ResponseCard, value); err != nil { return err } case "sentimentResponse": if err := awsRestjson1_deserializeDocumentSentimentResponse(&sv.SentimentResponse, value); err != nil { return err } case "sessionAttributes": if err := awsRestjson1_deserializeDocumentStringMap(&sv.SessionAttributes, value); err != nil { return err } case "sessionId": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SessionId = ptr.String(jtv) } case "slots": if err := awsRestjson1_deserializeDocumentStringMap(&sv.Slots, value); err != nil { return err } case "slotToElicit": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SlotToElicit = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } type awsRestjson1_deserializeOpPutSession struct { } func (*awsRestjson1_deserializeOpPutSession) ID() string { return "OperationDeserializer" } func (m *awsRestjson1_deserializeOpPutSession) HandleDeserialize(ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler) ( out middleware.DeserializeOutput, metadata middleware.Metadata, err error, ) { out, metadata, err = next.HandleDeserialize(ctx, in) if err != nil { return out, metadata, err } response, ok := out.RawResponse.(*smithyhttp.Response) if !ok { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("unknown transport type %T", out.RawResponse)} } if response.StatusCode < 200 || response.StatusCode >= 300 { return out, metadata, awsRestjson1_deserializeOpErrorPutSession(response, &metadata) } output := &PutSessionOutput{} out.Result = output err = awsRestjson1_deserializeOpHttpBindingsPutSessionOutput(output, response) if err != nil { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to decode response with invalid Http bindings, %w", err)} } err = awsRestjson1_deserializeOpDocumentPutSessionOutput(output, response.Body) if err != nil { return out, metadata, &smithy.DeserializationError{Err: fmt.Errorf("failed to deserialize response payload, %w", err)} } return out, metadata, err } func awsRestjson1_deserializeOpErrorPutSession(response *smithyhttp.Response, metadata *middleware.Metadata) error { var errorBuffer bytes.Buffer if _, err := io.Copy(&errorBuffer, response.Body); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to copy error response body, %w", err)} } errorBody := bytes.NewReader(errorBuffer.Bytes()) errorCode := "UnknownError" errorMessage := errorCode headerCode := response.Header.Get("X-Amzn-ErrorType") if len(headerCode) != 0 { errorCode = restjson.SanitizeErrorCode(headerCode) } var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() jsonCode, message, err := restjson.GetErrorInfo(decoder) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if len(headerCode) == 0 && len(jsonCode) != 0 { errorCode = restjson.SanitizeErrorCode(jsonCode) } if len(message) != 0 { errorMessage = message } switch { case strings.EqualFold("BadGatewayException", errorCode): return awsRestjson1_deserializeErrorBadGatewayException(response, errorBody) case strings.EqualFold("BadRequestException", errorCode): return awsRestjson1_deserializeErrorBadRequestException(response, errorBody) case strings.EqualFold("ConflictException", errorCode): return awsRestjson1_deserializeErrorConflictException(response, errorBody) case strings.EqualFold("DependencyFailedException", errorCode): return awsRestjson1_deserializeErrorDependencyFailedException(response, errorBody) case strings.EqualFold("InternalFailureException", errorCode): return awsRestjson1_deserializeErrorInternalFailureException(response, errorBody) case strings.EqualFold("LimitExceededException", errorCode): return awsRestjson1_deserializeErrorLimitExceededException(response, errorBody) case strings.EqualFold("NotAcceptableException", errorCode): return awsRestjson1_deserializeErrorNotAcceptableException(response, errorBody) case strings.EqualFold("NotFoundException", errorCode): return awsRestjson1_deserializeErrorNotFoundException(response, errorBody) default: genericError := &smithy.GenericAPIError{ Code: errorCode, Message: errorMessage, } return genericError } } func awsRestjson1_deserializeOpHttpBindingsPutSessionOutput(v *PutSessionOutput, response *smithyhttp.Response) error { if v == nil { return fmt.Errorf("unsupported deserialization for nil %T", v) } if headerValues := response.Header.Values("x-amz-lex-active-contexts"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.ActiveContexts = ptr.String(string(b)) } if headerValues := response.Header.Values("Content-Type"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.ContentType = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-dialog-state"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.DialogState = types.DialogState(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-encoded-message"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.EncodedMessage = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-intent-name"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.IntentName = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-message"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.Message = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-message-format"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.MessageFormat = types.MessageFormatType(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-session-attributes"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.SessionAttributes = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-session-id"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.SessionId = ptr.String(headerValues[0]) } if headerValues := response.Header.Values("x-amz-lex-slots"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) b, err := base64.StdEncoding.DecodeString(headerValues[0]) if err != nil { return err } v.Slots = ptr.String(string(b)) } if headerValues := response.Header.Values("x-amz-lex-slot-to-elicit"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.SlotToElicit = ptr.String(headerValues[0]) } return nil } func awsRestjson1_deserializeOpDocumentPutSessionOutput(v *PutSessionOutput, body io.ReadCloser) error { if v == nil { return fmt.Errorf("unsupported deserialization of nil %T", v) } v.AudioStream = body return nil } func awsRestjson1_deserializeOpHttpBindingsLimitExceededException(v *types.LimitExceededException, response *smithyhttp.Response) error { if v == nil { return fmt.Errorf("unsupported deserialization for nil %T", v) } if headerValues := response.Header.Values("Retry-After"); len(headerValues) != 0 { headerValues[0] = strings.TrimSpace(headerValues[0]) v.RetryAfterSeconds = ptr.String(headerValues[0]) } return nil } func awsRestjson1_deserializeErrorBadGatewayException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.BadGatewayException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentBadGatewayException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorBadRequestException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.BadRequestException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentBadRequestException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorConflictException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.ConflictException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentConflictException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorDependencyFailedException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.DependencyFailedException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentDependencyFailedException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorInternalFailureException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.InternalFailureException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentInternalFailureException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorLimitExceededException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.LimitExceededException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentLimitExceededException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) if err := awsRestjson1_deserializeOpHttpBindingsLimitExceededException(output, response); err != nil { return &smithy.DeserializationError{Err: fmt.Errorf("failed to decode response error with invalid HTTP bindings, %w", err)} } return output } func awsRestjson1_deserializeErrorLoopDetectedException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.LoopDetectedException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentLoopDetectedException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorNotAcceptableException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.NotAcceptableException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentNotAcceptableException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorNotFoundException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.NotFoundException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentNotFoundException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorRequestTimeoutException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.RequestTimeoutException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentRequestTimeoutException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeErrorUnsupportedMediaTypeException(response *smithyhttp.Response, errorBody *bytes.Reader) error { output := &types.UnsupportedMediaTypeException{} var buff [1024]byte ringBuffer := smithyio.NewRingBuffer(buff[:]) body := io.TeeReader(errorBody, ringBuffer) decoder := json.NewDecoder(body) decoder.UseNumber() var shape interface{} if err := decoder.Decode(&shape); err != nil && err != io.EOF { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } err := awsRestjson1_deserializeDocumentUnsupportedMediaTypeException(&output, shape) if err != nil { var snapshot bytes.Buffer io.Copy(&snapshot, ringBuffer) err = &smithy.DeserializationError{ Err: fmt.Errorf("failed to decode response body, %w", err), Snapshot: snapshot.Bytes(), } return err } errorBody.Seek(0, io.SeekStart) return output } func awsRestjson1_deserializeDocumentActiveContext(v **types.ActiveContext, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.ActiveContext if *v == nil { sv = &types.ActiveContext{} } else { sv = *v } for key, value := range shape { switch key { case "name": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ActiveContextName to be of type string, got %T instead", value) } sv.Name = ptr.String(jtv) } case "parameters": if err := awsRestjson1_deserializeDocumentActiveContextParametersMap(&sv.Parameters, value); err != nil { return err } case "timeToLive": if err := awsRestjson1_deserializeDocumentActiveContextTimeToLive(&sv.TimeToLive, value); err != nil { return err } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentActiveContextParametersMap(v *map[string]string, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var mv map[string]string if *v == nil { mv = map[string]string{} } else { mv = *v } for key, value := range shape { var parsedVal string if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected Text to be of type string, got %T instead", value) } parsedVal = jtv } mv[key] = parsedVal } *v = mv return nil } func awsRestjson1_deserializeDocumentActiveContextsList(v *[]types.ActiveContext, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var cv []types.ActiveContext if *v == nil { cv = []types.ActiveContext{} } else { cv = *v } for _, value := range shape { var col types.ActiveContext destAddr := &col if err := awsRestjson1_deserializeDocumentActiveContext(&destAddr, value); err != nil { return err } col = *destAddr cv = append(cv, col) } *v = cv return nil } func awsRestjson1_deserializeDocumentActiveContextTimeToLive(v **types.ActiveContextTimeToLive, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.ActiveContextTimeToLive if *v == nil { sv = &types.ActiveContextTimeToLive{} } else { sv = *v } for key, value := range shape { switch key { case "timeToLiveInSeconds": if value != nil { jtv, ok := value.(json.Number) if !ok { return fmt.Errorf("expected ActiveContextTimeToLiveInSeconds to be json.Number, got %T instead", value) } i64, err := jtv.Int64() if err != nil { return err } sv.TimeToLiveInSeconds = ptr.Int32(int32(i64)) } case "turnsToLive": if value != nil { jtv, ok := value.(json.Number) if !ok { return fmt.Errorf("expected ActiveContextTurnsToLive to be json.Number, got %T instead", value) } i64, err := jtv.Int64() if err != nil { return err } sv.TurnsToLive = ptr.Int32(int32(i64)) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentBadGatewayException(v **types.BadGatewayException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.BadGatewayException if *v == nil { sv = &types.BadGatewayException{} } else { sv = *v } for key, value := range shape { switch key { case "Message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentBadRequestException(v **types.BadRequestException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.BadRequestException if *v == nil { sv = &types.BadRequestException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentButton(v **types.Button, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.Button if *v == nil { sv = &types.Button{} } else { sv = *v } for key, value := range shape { switch key { case "text": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ButtonTextStringWithLength to be of type string, got %T instead", value) } sv.Text = ptr.String(jtv) } case "value": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ButtonValueStringWithLength to be of type string, got %T instead", value) } sv.Value = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentConflictException(v **types.ConflictException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.ConflictException if *v == nil { sv = &types.ConflictException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentDependencyFailedException(v **types.DependencyFailedException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.DependencyFailedException if *v == nil { sv = &types.DependencyFailedException{} } else { sv = *v } for key, value := range shape { switch key { case "Message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentDialogAction(v **types.DialogAction, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.DialogAction if *v == nil { sv = &types.DialogAction{} } else { sv = *v } for key, value := range shape { switch key { case "fulfillmentState": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected FulfillmentState to be of type string, got %T instead", value) } sv.FulfillmentState = types.FulfillmentState(jtv) } case "intentName": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected IntentName to be of type string, got %T instead", value) } sv.IntentName = ptr.String(jtv) } case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected Text to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } case "messageFormat": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected MessageFormatType to be of type string, got %T instead", value) } sv.MessageFormat = types.MessageFormatType(jtv) } case "slots": if err := awsRestjson1_deserializeDocumentStringMap(&sv.Slots, value); err != nil { return err } case "slotToElicit": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SlotToElicit = ptr.String(jtv) } case "type": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected DialogActionType to be of type string, got %T instead", value) } sv.Type = types.DialogActionType(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentGenericAttachment(v **types.GenericAttachment, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.GenericAttachment if *v == nil { sv = &types.GenericAttachment{} } else { sv = *v } for key, value := range shape { switch key { case "attachmentLinkUrl": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected StringUrlWithLength to be of type string, got %T instead", value) } sv.AttachmentLinkUrl = ptr.String(jtv) } case "buttons": if err := awsRestjson1_deserializeDocumentListOfButtons(&sv.Buttons, value); err != nil { return err } case "imageUrl": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected StringUrlWithLength to be of type string, got %T instead", value) } sv.ImageUrl = ptr.String(jtv) } case "subTitle": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected StringWithLength to be of type string, got %T instead", value) } sv.SubTitle = ptr.String(jtv) } case "title": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected StringWithLength to be of type string, got %T instead", value) } sv.Title = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentGenericAttachmentList(v *[]types.GenericAttachment, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var cv []types.GenericAttachment if *v == nil { cv = []types.GenericAttachment{} } else { cv = *v } for _, value := range shape { var col types.GenericAttachment destAddr := &col if err := awsRestjson1_deserializeDocumentGenericAttachment(&destAddr, value); err != nil { return err } col = *destAddr cv = append(cv, col) } *v = cv return nil } func awsRestjson1_deserializeDocumentIntentConfidence(v **types.IntentConfidence, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.IntentConfidence if *v == nil { sv = &types.IntentConfidence{} } else { sv = *v } for key, value := range shape { switch key { case "score": if value != nil { switch jtv := value.(type) { case json.Number: f64, err := jtv.Float64() if err != nil { return err } sv.Score = f64 case string: var f64 float64 switch { case strings.EqualFold(jtv, "NaN"): f64 = math.NaN() case strings.EqualFold(jtv, "Infinity"): f64 = math.Inf(1) case strings.EqualFold(jtv, "-Infinity"): f64 = math.Inf(-1) default: return fmt.Errorf("unknown JSON number value: %s", jtv) } sv.Score = f64 default: return fmt.Errorf("expected Double to be a JSON Number, got %T instead", value) } } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentIntentList(v *[]types.PredictedIntent, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var cv []types.PredictedIntent if *v == nil { cv = []types.PredictedIntent{} } else { cv = *v } for _, value := range shape { var col types.PredictedIntent destAddr := &col if err := awsRestjson1_deserializeDocumentPredictedIntent(&destAddr, value); err != nil { return err } col = *destAddr cv = append(cv, col) } *v = cv return nil } func awsRestjson1_deserializeDocumentIntentSummary(v **types.IntentSummary, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.IntentSummary if *v == nil { sv = &types.IntentSummary{} } else { sv = *v } for key, value := range shape { switch key { case "checkpointLabel": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected IntentSummaryCheckpointLabel to be of type string, got %T instead", value) } sv.CheckpointLabel = ptr.String(jtv) } case "confirmationStatus": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ConfirmationStatus to be of type string, got %T instead", value) } sv.ConfirmationStatus = types.ConfirmationStatus(jtv) } case "dialogActionType": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected DialogActionType to be of type string, got %T instead", value) } sv.DialogActionType = types.DialogActionType(jtv) } case "fulfillmentState": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected FulfillmentState to be of type string, got %T instead", value) } sv.FulfillmentState = types.FulfillmentState(jtv) } case "intentName": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected IntentName to be of type string, got %T instead", value) } sv.IntentName = ptr.String(jtv) } case "slots": if err := awsRestjson1_deserializeDocumentStringMap(&sv.Slots, value); err != nil { return err } case "slotToElicit": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.SlotToElicit = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentIntentSummaryList(v *[]types.IntentSummary, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var cv []types.IntentSummary if *v == nil { cv = []types.IntentSummary{} } else { cv = *v } for _, value := range shape { var col types.IntentSummary destAddr := &col if err := awsRestjson1_deserializeDocumentIntentSummary(&destAddr, value); err != nil { return err } col = *destAddr cv = append(cv, col) } *v = cv return nil } func awsRestjson1_deserializeDocumentInternalFailureException(v **types.InternalFailureException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.InternalFailureException if *v == nil { sv = &types.InternalFailureException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentLimitExceededException(v **types.LimitExceededException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.LimitExceededException if *v == nil { sv = &types.LimitExceededException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } case "retryAfterSeconds": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.RetryAfterSeconds = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentListOfButtons(v *[]types.Button, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.([]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var cv []types.Button if *v == nil { cv = []types.Button{} } else { cv = *v } for _, value := range shape { var col types.Button destAddr := &col if err := awsRestjson1_deserializeDocumentButton(&destAddr, value); err != nil { return err } col = *destAddr cv = append(cv, col) } *v = cv return nil } func awsRestjson1_deserializeDocumentLoopDetectedException(v **types.LoopDetectedException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.LoopDetectedException if *v == nil { sv = &types.LoopDetectedException{} } else { sv = *v } for key, value := range shape { switch key { case "Message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ErrorMessage to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentNotAcceptableException(v **types.NotAcceptableException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.NotAcceptableException if *v == nil { sv = &types.NotAcceptableException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentNotFoundException(v **types.NotFoundException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.NotFoundException if *v == nil { sv = &types.NotFoundException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentPredictedIntent(v **types.PredictedIntent, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.PredictedIntent if *v == nil { sv = &types.PredictedIntent{} } else { sv = *v } for key, value := range shape { switch key { case "intentName": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected IntentName to be of type string, got %T instead", value) } sv.IntentName = ptr.String(jtv) } case "nluIntentConfidence": if err := awsRestjson1_deserializeDocumentIntentConfidence(&sv.NluIntentConfidence, value); err != nil { return err } case "slots": if err := awsRestjson1_deserializeDocumentStringMap(&sv.Slots, value); err != nil { return err } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentRequestTimeoutException(v **types.RequestTimeoutException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.RequestTimeoutException if *v == nil { sv = &types.RequestTimeoutException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentResponseCard(v **types.ResponseCard, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.ResponseCard if *v == nil { sv = &types.ResponseCard{} } else { sv = *v } for key, value := range shape { switch key { case "contentType": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected ContentType to be of type string, got %T instead", value) } sv.ContentType = types.ContentType(jtv) } case "genericAttachments": if err := awsRestjson1_deserializeDocumentGenericAttachmentList(&sv.GenericAttachments, value); err != nil { return err } case "version": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Version = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentSentimentResponse(v **types.SentimentResponse, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.SentimentResponse if *v == nil { sv = &types.SentimentResponse{} } else { sv = *v } for key, value := range shape { switch key { case "sentimentLabel": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected SentimentLabel to be of type string, got %T instead", value) } sv.SentimentLabel = ptr.String(jtv) } case "sentimentScore": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected SentimentScore to be of type string, got %T instead", value) } sv.SentimentScore = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil } func awsRestjson1_deserializeDocumentStringMap(v *map[string]string, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var mv map[string]string if *v == nil { mv = map[string]string{} } else { mv = *v } for key, value := range shape { var parsedVal string if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } parsedVal = jtv } mv[key] = parsedVal } *v = mv return nil } func awsRestjson1_deserializeDocumentUnsupportedMediaTypeException(v **types.UnsupportedMediaTypeException, value interface{}) error { if v == nil { return fmt.Errorf("unexpected nil of type %T", v) } if value == nil { return nil } shape, ok := value.(map[string]interface{}) if !ok { return fmt.Errorf("unexpected JSON type %v", value) } var sv *types.UnsupportedMediaTypeException if *v == nil { sv = &types.UnsupportedMediaTypeException{} } else { sv = *v } for key, value := range shape { switch key { case "message": if value != nil { jtv, ok := value.(string) if !ok { return fmt.Errorf("expected String to be of type string, got %T instead", value) } sv.Message = ptr.String(jtv) } default: _, _ = key, value } } *v = sv return nil }