diff --git a/clients/aws-sdk-lex-runtime-v2/.changes/next-release/aws-sdk-lex-runtime-v2-api-change-fa23e4248cb149cfacb71f203f455e83.json b/clients/aws-sdk-lex-runtime-v2/.changes/next-release/aws-sdk-lex-runtime-v2-api-change-fa23e4248cb149cfacb71f203f455e83.json new file mode 100644 index 0000000..11b706e --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/.changes/next-release/aws-sdk-lex-runtime-v2-api-change-fa23e4248cb149cfacb71f203f455e83.json @@ -0,0 +1,4 @@ +{ + "type": "api-change", + "description": "Initial client release with support for current Amazon Lex Runtime V2 operations." +} \ No newline at end of file diff --git a/clients/aws-sdk-lex-runtime-v2/CHANGELOG.md b/clients/aws-sdk-lex-runtime-v2/CHANGELOG.md new file mode 100644 index 0000000..b7e4a1d --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/CHANGELOG.md @@ -0,0 +1,6 @@ +# Changelog + +## v0.4.0 + +### Features +* Initial client release with support for current Amazon Lex Runtime V2 operations. diff --git a/clients/aws-sdk-lex-runtime-v2/README.md b/clients/aws-sdk-lex-runtime-v2/README.md new file mode 100644 index 0000000..63753c9 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/README.md @@ -0,0 +1,10 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +## Amazon Lex Runtime V2 Client + +aws_sdk_lex_runtime_v2 client + +### Documentation + +This section contains documentation for the Amazon Lex V2 Runtime V2 API +operations. diff --git a/clients/aws-sdk-lex-runtime-v2/pyproject.toml b/clients/aws-sdk-lex-runtime-v2/pyproject.toml new file mode 100644 index 0000000..d0f5765 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/pyproject.toml @@ -0,0 +1,61 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +[project] +name = "aws_sdk_lex_runtime_v2" +version = "0.4.0" +description = "aws_sdk_lex_runtime_v2 client" +readme = "README.md" +requires-python = ">=3.12" +keywords = ["smithy", "aws_sdk_lex_runtime_v2"] +license = {text = "Apache-2.0"} +classifiers = [ + "Development Status :: 2 - Pre-Alpha", + "Intended Audience :: Developers", + "Intended Audience :: System Administrators", + "Natural Language :: English", + "License :: OSI Approved :: Apache Software License", + "Programming Language :: Python", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3 :: Only", + "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", + "Programming Language :: Python :: 3.14" +] + +dependencies = [ + "smithy_aws_core[eventstream, json]~=0.4.0", + "smithy_core~=0.3.0", + "smithy_http[awscrt]~=0.3.0" +] + +[dependency-groups] +test = [ + "pytest>=9.0.1,<10.0.0", + "pytest-asyncio>=1.3.0,<1.4.0" +] + +[build-system] +requires = ["hatchling"] +build-backend = "hatchling.build" + +[tool.pyright] +typeCheckingMode = "strict" +reportPrivateUsage = false +reportUnusedFunction = false +reportUnusedVariable = false +reportUnnecessaryComparison = false +reportUnusedClass = false +enableExperimentalFeatures = true + +[tool.ruff] +target-version = "py312" + +[tool.ruff.lint] +ignore = ["F841"] + +[tool.ruff.format] +skip-magic-trailing-comma = true + +[tool.pytest.ini_options] +python_classes = ["!Test"] +asyncio_mode = "auto" diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/__init__.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/__init__.py new file mode 100644 index 0000000..99433b7 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/__init__.py @@ -0,0 +1,3 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +__version__: str = "0.4.0" diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/__init__.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/__init__.py new file mode 100644 index 0000000..247be3e --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/__init__.py @@ -0,0 +1 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/schemas.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/schemas.py new file mode 100644 index 0000000..6aa4e7d --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/_private/schemas.py @@ -0,0 +1,2922 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from types import MappingProxyType + +from smithy_core.prelude import UNIT +from smithy_core.schemas import Schema +from smithy_core.shapes import ShapeID, ShapeType +from smithy_core.traits import Trait + + +STRING = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#String"), shape_type=ShapeType.STRING +) + +ACCESS_DENIED_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#AccessDeniedException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=403), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +PARAMETER_NAME = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ParameterName"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 100}), + ) + ], +) + +TEXT = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#Text"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 1024}), + ), + Trait.new(id=ShapeID("smithy.api#sensitive")), + ], +) + +ACTIVE_CONTEXT_PARAMETERS_MAP = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextParametersMap"), + shape_type=ShapeType.MAP, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 0, "max": 10}), + ) + ], + members={"key": {"target": PARAMETER_NAME}, "value": {"target": TEXT}}, +) + +ACTIVE_CONTEXT_NAME = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextName"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 100}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^([A-Za-z0-9]_?)+$"), + ], +) + +ACTIVE_CONTEXT_TIME_TO_LIVE_IN_SECONDS = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextTimeToLiveInSeconds"), + shape_type=ShapeType.INTEGER, + traits=[ + Trait.new(id=ShapeID("smithy.api#box")), + Trait.new( + id=ShapeID("smithy.api#range"), + value=MappingProxyType({"min": 5, "max": 86400}), + ), + ], +) + +ACTIVE_CONTEXT_TURNS_TO_LIVE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextTurnsToLive"), + shape_type=ShapeType.INTEGER, + traits=[ + Trait.new(id=ShapeID("smithy.api#box")), + Trait.new( + id=ShapeID("smithy.api#range"), + value=MappingProxyType({"min": 1, "max": 20}), + ), + ], +) + +ACTIVE_CONTEXT_TIME_TO_LIVE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextTimeToLive"), + members={ + "timeToLiveInSeconds": { + "target": ACTIVE_CONTEXT_TIME_TO_LIVE_IN_SECONDS, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "turnsToLive": { + "target": ACTIVE_CONTEXT_TURNS_TO_LIVE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + }, +) + +ACTIVE_CONTEXT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContext"), + members={ + "name": { + "target": ACTIVE_CONTEXT_NAME, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "timeToLive": { + "target": ACTIVE_CONTEXT_TIME_TO_LIVE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "contextAttributes": { + "target": ACTIVE_CONTEXT_PARAMETERS_MAP, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + }, +) + +ACTIVE_CONTEXTS_LIST = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ActiveContextsList"), + shape_type=ShapeType.LIST, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 0, "max": 20}), + ) + ], + members={"member": {"target": ACTIVE_CONTEXT}}, +) + +ATTACHMENT_TITLE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#AttachmentTitle"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 250}), + ) + ], +) + +ATTACHMENT_URL = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#AttachmentUrl"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 250}), + ) + ], +) + +AUDIO_CHUNK = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#AudioChunk"), shape_type=ShapeType.BLOB +) + +EPOCH_MILLIS = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#EpochMillis"), + shape_type=ShapeType.LONG, + traits=[Trait.new(id=ShapeID("smithy.api#default"), value=0)], +) + +NON_EMPTY_STRING = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#NonEmptyString"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new(id=ShapeID("smithy.api#length"), value=MappingProxyType({"min": 1})) + ], +) + +EVENT_ID = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#EventId"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 2, "max": 100}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^[0-9a-zA-Z._:-]+$"), + ], +) + +AUDIO_INPUT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#AudioInputEvent"), + members={ + "audioChunk": {"target": AUDIO_CHUNK}, + "contentType": { + "target": NON_EMPTY_STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +AUDIO_RESPONSE_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#AudioResponseEvent"), + members={ + "audioChunk": {"target": AUDIO_CHUNK}, + "contentType": {"target": NON_EMPTY_STRING}, + "eventId": {"target": EVENT_ID}, + }, +) + +CONFLICT_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ConflictException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=409), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +BOT_ALIAS_IDENTIFIER = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#BotAliasIdentifier"), + shape_type=ShapeType.STRING, +) + +BOT_IDENTIFIER = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#BotIdentifier"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 10, "max": 10}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^[0-9a-zA-Z]+$"), + ], +) + +LOCALE_ID = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#LocaleId"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new(id=ShapeID("smithy.api#length"), value=MappingProxyType({"min": 1})) + ], +) + +SESSION_ID = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#SessionId"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 2, "max": 100}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^[0-9a-zA-Z._:-]+$"), + ], +) + +DELETE_SESSION_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DeleteSessionInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#DeleteSessionRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + }, +) + +DELETE_SESSION_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DeleteSessionOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#DeleteSessionResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "botId": {"target": BOT_IDENTIFIER}, + "botAliasId": {"target": BOT_ALIAS_IDENTIFIER}, + "localeId": {"target": LOCALE_ID}, + "sessionId": {"target": SESSION_ID}, + }, +) + +INTERNAL_SERVER_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#InternalServerException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="server"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=500), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +RESOURCE_NOT_FOUND_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ResourceNotFoundException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=404), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +THROTTLING_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ThrottlingException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=429), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +VALIDATION_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ValidationException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=400), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +DELETE_SESSION = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#DeleteSession"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "DELETE", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200, + } + ), + ) + ], +) + +GET_SESSION_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#GetSessionInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#GetSessionRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + }, +) + +CONFIRMATION_STATE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ConfirmationState"), + shape_type=ShapeType.ENUM, + members={ + "CONFIRMED": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="Confirmed") + ], + }, + "DENIED": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Denied")], + }, + "NONE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="None")], + }, + }, +) + +SHAPE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Shape"), + shape_type=ShapeType.ENUM, + members={ + "SCALAR": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Scalar")], + }, + "LIST": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="List")], + }, + "COMPOSITE": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="Composite") + ], + }, + }, +) + +STRING_LIST = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StringList"), + shape_type=ShapeType.LIST, + members={"member": {"target": NON_EMPTY_STRING}}, +) + +VALUE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Value"), + members={ + "originalValue": {"target": NON_EMPTY_STRING}, + "interpretedValue": { + "target": NON_EMPTY_STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "resolvedValues": {"target": STRING_LIST}, + }, +) + +INTENT_STATE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#IntentState"), + shape_type=ShapeType.ENUM, + members={ + "FAILED": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Failed")], + }, + "FULFILLED": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="Fulfilled") + ], + }, + "IN_PROGRESS": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="InProgress") + ], + }, + "READY_FOR_FULFILLMENT": { + "target": UNIT, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#enumValue"), value="ReadyForFulfillment" + ) + ], + }, + "WAITING": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Waiting")], + }, + "FULFILLMENT_IN_PROGRESS": { + "target": UNIT, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#enumValue"), value="FulfillmentInProgress" + ) + ], + }, + }, +) + +INTERPRETATION_SOURCE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#InterpretationSource"), + shape_type=ShapeType.ENUM, + members={ + "BEDROCK": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Bedrock")], + }, + "LEX": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Lex")], + }, + }, +) + +DOUBLE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#Double"), + shape_type=ShapeType.DOUBLE, + traits=[Trait.new(id=ShapeID("smithy.api#default"), value=0)], +) + +CONFIDENCE_SCORE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ConfidenceScore"), + members={ + "score": { + "target": DOUBLE, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + } + }, +) + +SENTIMENT_TYPE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SentimentType"), + shape_type=ShapeType.ENUM, + members={ + "MIXED": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="MIXED")], + }, + "NEGATIVE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="NEGATIVE")], + }, + "NEUTRAL": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="NEUTRAL")], + }, + "POSITIVE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="POSITIVE")], + }, + }, +) + +SENTIMENT_SCORE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SentimentScore"), + members={ + "positive": { + "target": DOUBLE, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + "negative": { + "target": DOUBLE, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + "neutral": { + "target": DOUBLE, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + "mixed": { + "target": DOUBLE, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +SENTIMENT_RESPONSE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SentimentResponse"), + members={ + "sentiment": {"target": SENTIMENT_TYPE}, + "sentimentScore": {"target": SENTIMENT_SCORE}, + }, +) + +MESSAGE_CONTENT_TYPE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#MessageContentType"), + shape_type=ShapeType.ENUM, + members={ + "CUSTOM_PAYLOAD": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="CustomPayload") + ], + }, + "IMAGE_RESPONSE_CARD": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="ImageResponseCard") + ], + }, + "PLAIN_TEXT": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="PlainText") + ], + }, + "SSML": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="SSML")], + }, + }, +) + +BUTTON_TEXT = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ButtonText"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 50}), + ) + ], +) + +BUTTON_VALUE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#ButtonValue"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 50}), + ) + ], +) + +BUTTON = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Button"), + members={ + "text": { + "target": BUTTON_TEXT, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "value": { + "target": BUTTON_VALUE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + }, +) + +BUTTONS_LIST = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ButtonsList"), + shape_type=ShapeType.LIST, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 0, "max": 5}), + ) + ], + members={"member": {"target": BUTTON}}, +) + +IMAGE_RESPONSE_CARD = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ImageResponseCard"), + members={ + "title": { + "target": ATTACHMENT_TITLE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "subtitle": {"target": ATTACHMENT_TITLE}, + "imageUrl": {"target": ATTACHMENT_URL}, + "buttons": {"target": BUTTONS_LIST}, + }, +) + +MESSAGE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Message"), + members={ + "content": {"target": TEXT}, + "contentType": { + "target": MESSAGE_CONTENT_TYPE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "imageResponseCard": {"target": IMAGE_RESPONSE_CARD}, + }, +) + +MESSAGES = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Messages"), + shape_type=ShapeType.LIST, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 0, "max": 10}), + ) + ], + members={"member": {"target": MESSAGE}}, +) + +STYLE_TYPE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StyleType"), + shape_type=ShapeType.ENUM, + members={ + "DEFAULT": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Default")], + }, + "SPELL_BY_LETTER": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="SpellByLetter") + ], + }, + "SPELL_BY_WORD": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="SpellByWord") + ], + }, + }, +) + +DIALOG_ACTION_TYPE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DialogActionType"), + shape_type=ShapeType.ENUM, + members={ + "CLOSE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Close")], + }, + "CONFIRM_INTENT": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="ConfirmIntent") + ], + }, + "DELEGATE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Delegate")], + }, + "ELICIT_INTENT": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="ElicitIntent") + ], + }, + "ELICIT_SLOT": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="ElicitSlot") + ], + }, + "NONE": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="None")], + }, + }, +) + +NAME = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#Name"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 100}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^([0-9a-zA-Z][_-]?)+$"), + ], +) + +RUNTIME_HINT_PHRASE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#RuntimeHintPhrase"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 140}), + ) + ], +) + +RUNTIME_HINT_VALUE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RuntimeHintValue"), + members={ + "phrase": { + "target": RUNTIME_HINT_PHRASE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +RUNTIME_HINT_VALUES_LIST = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RuntimeHintValuesList"), + shape_type=ShapeType.LIST, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 100}), + ) + ], + members={"member": {"target": RUNTIME_HINT_VALUE}}, +) + +STRING_MAP = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StringMap"), + shape_type=ShapeType.MAP, + members={"key": {"target": NON_EMPTY_STRING}, "value": {"target": STRING}}, +) + +BAD_GATEWAY_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#BadGatewayException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="server"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=502), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +DEPENDENCY_FAILED_EXCEPTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DependencyFailedException"), + traits=[ + Trait.new(id=ShapeID("smithy.api#error"), value="client"), + Trait.new(id=ShapeID("smithy.api#httpError"), value=424), + ], + members={ + "message": { + "target": STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + } + }, +) + +BLOB_STREAM = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#BlobStream"), + shape_type=ShapeType.BLOB, + traits=[Trait.new(id=ShapeID("smithy.api#streaming"))], +) + +PUT_SESSION_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#PutSessionOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#PutSessionResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "contentType": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new(id=ShapeID("smithy.api#httpHeader"), value="Content-Type") + ], + }, + "messages": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-messages" + ) + ], + }, + "sessionState": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-session-state" + ) + ], + }, + "requestAttributes": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-request-attributes", + ) + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-session-id" + ) + ], + }, + "audioStream": { + "target": BLOB_STREAM, + "traits": [ + Trait.new(id=ShapeID("smithy.api#default"), value=""), + Trait.new(id=ShapeID("smithy.api#httpPayload")), + ], + }, + }, +) + +RECOGNIZED_BOT_MEMBER = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizedBotMember"), + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "botName": {"target": NAME}, + }, +) + +SENSITIVE_NON_EMPTY_STRING = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#SensitiveNonEmptyString"), + shape_type=ShapeType.STRING, + traits=[Trait.new(id=ShapeID("smithy.api#sensitive"))], +) + +RECOGNIZE_UTTERANCE_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeUtteranceInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#RecognizeUtteranceRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionState": { + "target": SENSITIVE_NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-session-state" + ) + ], + }, + "requestAttributes": { + "target": SENSITIVE_NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-request-attributes", + ) + ], + }, + "requestContentType": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new(id=ShapeID("smithy.api#httpHeader"), value="Content-Type"), + Trait.new(id=ShapeID("smithy.api#required")), + ], + }, + "responseContentType": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="Response-Content-Type" + ) + ], + }, + "inputStream": { + "target": BLOB_STREAM, + "traits": [ + Trait.new(id=ShapeID("smithy.api#default"), value=""), + Trait.new(id=ShapeID("smithy.api#httpPayload")), + ], + }, + }, +) + +RECOGNIZE_UTTERANCE_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeUtteranceOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#RecognizeUtteranceResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "inputMode": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-input-mode" + ) + ], + }, + "contentType": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new(id=ShapeID("smithy.api#httpHeader"), value="Content-Type") + ], + }, + "messages": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-messages" + ) + ], + }, + "interpretations": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-interpretations", + ) + ], + }, + "sessionState": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-session-state" + ) + ], + }, + "requestAttributes": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-request-attributes", + ) + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="x-amz-lex-session-id" + ) + ], + }, + "inputTranscript": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-input-transcript", + ) + ], + }, + "audioStream": { + "target": BLOB_STREAM, + "traits": [ + Trait.new(id=ShapeID("smithy.api#default"), value=""), + Trait.new(id=ShapeID("smithy.api#httpPayload")), + ], + }, + "recognizedBotMember": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-recognized-bot-member", + ) + ], + }, + }, +) + +RECOGNIZE_UTTERANCE = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeUtterance"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new(id=ShapeID("aws.auth#unsignedPayload")), + Trait.new(id=ShapeID("smithy.api#auth"), value=("aws.auth#sigv4",)), + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/utterance", + "code": 200, + } + ), + ), + ], +) + +CONVERSATION_MODE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ConversationMode"), + shape_type=ShapeType.ENUM, + members={ + "AUDIO": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="AUDIO")], + }, + "TEXT": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="TEXT")], + }, + }, +) + +BOOLEAN = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#Boolean"), + shape_type=ShapeType.BOOLEAN, + traits=[Trait.new(id=ShapeID("smithy.api#default"), value=False)], +) + +DISCONNECTION_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DisconnectionEvent"), + members={ + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +DTMF_REGEX = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#DTMFRegex"), + shape_type=ShapeType.STRING, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 1, "max": 1}), + ), + Trait.new(id=ShapeID("smithy.api#pattern"), value="^[A-D0-9#*]{1}$"), + Trait.new(id=ShapeID("smithy.api#sensitive")), + ], +) + +DTMF_INPUT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DTMFInputEvent"), + members={ + "inputCharacter": { + "target": DTMF_REGEX, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +PLAYBACK_COMPLETION_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#PlaybackCompletionEvent"), + members={ + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +TEXT_INPUT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#TextInputEvent"), + members={ + "text": { + "target": TEXT, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +HEARTBEAT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#HeartbeatEvent"), + members={"eventId": {"target": EVENT_ID}}, +) + +INPUT_MODE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#InputMode"), + shape_type=ShapeType.ENUM, + members={ + "TEXT": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Text")], + }, + "SPEECH": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="Speech")], + }, + "DTMF": { + "target": UNIT, + "traits": [Trait.new(id=ShapeID("smithy.api#enumValue"), value="DTMF")], + }, + }, +) + +PLAYBACK_INTERRUPTION_REASON = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#PlaybackInterruptionReason"), + shape_type=ShapeType.ENUM, + members={ + "DTMF_START_DETECTED": { + "target": UNIT, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#enumValue"), value="DTMF_START_DETECTED" + ) + ], + }, + "TEXT_DETECTED": { + "target": UNIT, + "traits": [ + Trait.new(id=ShapeID("smithy.api#enumValue"), value="TEXT_DETECTED") + ], + }, + "VOICE_START_DETECTED": { + "target": UNIT, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#enumValue"), value="VOICE_START_DETECTED" + ) + ], + }, + }, +) + +PLAYBACK_INTERRUPTION_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#PlaybackInterruptionEvent"), + members={ + "eventReason": {"target": PLAYBACK_INTERRUPTION_REASON}, + "causedByEventId": {"target": EVENT_ID}, + "eventId": {"target": EVENT_ID}, + }, +) + +TEXT_RESPONSE_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#TextResponseEvent"), + members={"messages": {"target": MESSAGES}, "eventId": {"target": EVENT_ID}}, +) + +TRANSCRIPT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#TranscriptEvent"), + members={"transcript": {"target": STRING}, "eventId": {"target": EVENT_ID}}, +) + +ELICIT_SUB_SLOT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ElicitSubSlot"), + members={ + "name": { + "target": NON_EMPTY_STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + # This needs to reference a schema that isn't defined yet. + # It will be populated with a non-null value at the end of the file. + "subSlotToElicit": None, + }, +) + +DIALOG_ACTION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#DialogAction"), + members={ + "type": { + "target": DIALOG_ACTION_TYPE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "slotToElicit": {"target": NON_EMPTY_STRING}, + "slotElicitationStyle": {"target": STYLE_TYPE}, + "subSlotToElicit": {"target": ELICIT_SUB_SLOT}, + }, +) + +RUNTIME_HINT_DETAILS = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RuntimeHintDetails"), + members={ + "runtimeHintValues": {"target": RUNTIME_HINT_VALUES_LIST}, + # This needs to reference a schema that isn't defined yet. + # It will be populated with a non-null value at the end of the file. + "subSlotHints": None, + }, +) + +SLOT_HINTS_SLOT_MAP = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SlotHintsSlotMap"), + shape_type=ShapeType.MAP, + members={"key": {"target": NAME}, "value": {"target": RUNTIME_HINT_DETAILS}}, +) + +SLOT_HINTS_INTENT_MAP = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SlotHintsIntentMap"), + shape_type=ShapeType.MAP, + members={"key": {"target": NAME}, "value": {"target": SLOT_HINTS_SLOT_MAP}}, +) + +RUNTIME_HINTS = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RuntimeHints"), + members={"slotHints": {"target": SLOT_HINTS_INTENT_MAP}}, +) + +SLOT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Slot"), + members={ + "value": {"target": VALUE}, + "shape": {"target": SHAPE}, + # This needs to reference a schema that isn't defined yet. + # It will be populated with a non-null value at the end of the file. + "values": None, + # This needs to reference a schema that isn't defined yet. + # It will be populated with a non-null value at the end of the file. + "subSlots": None, + }, +) + +SLOTS = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Slots"), + shape_type=ShapeType.MAP, + members={"key": {"target": NON_EMPTY_STRING}, "value": {"target": SLOT}}, +) + +VALUES = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Values"), + shape_type=ShapeType.LIST, + members={"member": {"target": SLOT}}, +) + +INTENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Intent"), + members={ + "name": { + "target": NON_EMPTY_STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "slots": {"target": SLOTS}, + "state": {"target": INTENT_STATE}, + "confirmationState": {"target": CONFIRMATION_STATE}, + }, +) + +INTERPRETATION = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Interpretation"), + members={ + "nluConfidence": {"target": CONFIDENCE_SCORE}, + "sentimentResponse": {"target": SENTIMENT_RESPONSE}, + "intent": {"target": INTENT}, + "interpretationSource": {"target": INTERPRETATION_SOURCE}, + }, +) + +INTERPRETATIONS = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#Interpretations"), + shape_type=ShapeType.LIST, + traits=[ + Trait.new( + id=ShapeID("smithy.api#length"), + value=MappingProxyType({"min": 0, "max": 5}), + ) + ], + members={"member": {"target": INTERPRETATION}}, +) + +SESSION_STATE = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#SessionState"), + members={ + "dialogAction": {"target": DIALOG_ACTION}, + "intent": {"target": INTENT}, + "activeContexts": {"target": ACTIVE_CONTEXTS_LIST}, + "sessionAttributes": {"target": STRING_MAP}, + "originatingRequestId": {"target": NON_EMPTY_STRING}, + "runtimeHints": {"target": RUNTIME_HINTS}, + }, +) + +CONFIGURATION_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#ConfigurationEvent"), + members={ + "requestAttributes": {"target": STRING_MAP}, + "responseContentType": { + "target": NON_EMPTY_STRING, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "sessionState": {"target": SESSION_STATE}, + "welcomeMessages": {"target": MESSAGES}, + "disablePlayback": { + "target": BOOLEAN, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=False)], + }, + "eventId": {"target": EVENT_ID}, + "clientTimestampMillis": { + "target": EPOCH_MILLIS, + "traits": [Trait.new(id=ShapeID("smithy.api#default"), value=0)], + }, + }, +) + +PUT_SESSION_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#PutSessionInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#PutSessionRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "messages": {"target": MESSAGES}, + "sessionState": { + "target": SESSION_STATE, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "requestAttributes": {"target": STRING_MAP}, + "responseContentType": { + "target": NON_EMPTY_STRING, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), value="ResponseContentType" + ) + ], + }, + }, +) + +RECOGNIZE_TEXT_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeTextInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#RecognizeTextRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "text": { + "target": TEXT, + "traits": [Trait.new(id=ShapeID("smithy.api#required"))], + }, + "sessionState": {"target": SESSION_STATE}, + "requestAttributes": {"target": STRING_MAP}, + }, +) + +PUT_SESSION = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#PutSession"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200, + } + ), + ) + ], +) + +START_CONVERSATION_REQUEST_EVENT_STREAM = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StartConversationRequestEventStream"), + shape_type=ShapeType.UNION, + traits=[Trait.new(id=ShapeID("smithy.api#streaming"))], + members={ + "ConfigurationEvent": {"target": CONFIGURATION_EVENT}, + "AudioInputEvent": {"target": AUDIO_INPUT_EVENT}, + "DTMFInputEvent": {"target": DTMF_INPUT_EVENT}, + "TextInputEvent": {"target": TEXT_INPUT_EVENT}, + "PlaybackCompletionEvent": {"target": PLAYBACK_COMPLETION_EVENT}, + "DisconnectionEvent": {"target": DISCONNECTION_EVENT}, + }, +) + +START_CONVERSATION_INPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StartConversationInput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#StartConversationRequest", + ), + Trait.new(id=ShapeID("smithy.api#input")), + ], + members={ + "botId": { + "target": BOT_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "botAliasId": { + "target": BOT_ALIAS_IDENTIFIER, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "localeId": { + "target": LOCALE_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "sessionId": { + "target": SESSION_ID, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpLabel")), + ], + }, + "conversationMode": { + "target": CONVERSATION_MODE, + "traits": [ + Trait.new( + id=ShapeID("smithy.api#httpHeader"), + value="x-amz-lex-conversation-mode", + ) + ], + }, + "requestEventStream": { + "target": START_CONVERSATION_REQUEST_EVENT_STREAM, + "traits": [ + Trait.new(id=ShapeID("smithy.api#required")), + Trait.new(id=ShapeID("smithy.api#httpPayload")), + ], + }, + }, +) + +GET_SESSION_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#GetSessionOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#GetSessionResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "sessionId": {"target": NON_EMPTY_STRING}, + "messages": {"target": MESSAGES}, + "interpretations": {"target": INTERPRETATIONS}, + "sessionState": {"target": SESSION_STATE}, + }, +) + +INTENT_RESULT_EVENT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#IntentResultEvent"), + members={ + "inputMode": {"target": INPUT_MODE}, + "interpretations": {"target": INTERPRETATIONS}, + "sessionState": {"target": SESSION_STATE}, + "requestAttributes": {"target": STRING_MAP}, + "sessionId": {"target": SESSION_ID}, + "eventId": {"target": EVENT_ID}, + "recognizedBotMember": {"target": RECOGNIZED_BOT_MEMBER}, + }, +) + +RECOGNIZE_TEXT_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeTextOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#RecognizeTextResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "messages": {"target": MESSAGES}, + "sessionState": {"target": SESSION_STATE}, + "interpretations": {"target": INTERPRETATIONS}, + "requestAttributes": {"target": STRING_MAP}, + "sessionId": {"target": SESSION_ID}, + "recognizedBotMember": {"target": RECOGNIZED_BOT_MEMBER}, + }, +) + +GET_SESSION = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#GetSession"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "GET", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200, + } + ), + ) + ], +) + +START_CONVERSATION_RESPONSE_EVENT_STREAM = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StartConversationResponseEventStream"), + shape_type=ShapeType.UNION, + traits=[Trait.new(id=ShapeID("smithy.api#streaming"))], + members={ + "PlaybackInterruptionEvent": {"target": PLAYBACK_INTERRUPTION_EVENT}, + "TranscriptEvent": {"target": TRANSCRIPT_EVENT}, + "IntentResultEvent": {"target": INTENT_RESULT_EVENT}, + "TextResponseEvent": {"target": TEXT_RESPONSE_EVENT}, + "AudioResponseEvent": {"target": AUDIO_RESPONSE_EVENT}, + "HeartbeatEvent": {"target": HEARTBEAT_EVENT}, + "AccessDeniedException": {"target": ACCESS_DENIED_EXCEPTION}, + "ResourceNotFoundException": {"target": RESOURCE_NOT_FOUND_EXCEPTION}, + "ValidationException": {"target": VALIDATION_EXCEPTION}, + "ThrottlingException": {"target": THROTTLING_EXCEPTION}, + "InternalServerException": {"target": INTERNAL_SERVER_EXCEPTION}, + "ConflictException": {"target": CONFLICT_EXCEPTION}, + "DependencyFailedException": {"target": DEPENDENCY_FAILED_EXCEPTION}, + "BadGatewayException": {"target": BAD_GATEWAY_EXCEPTION}, + }, +) + +START_CONVERSATION_OUTPUT = Schema.collection( + id=ShapeID("com.amazonaws.lexruntimev2#StartConversationOutput"), + traits=[ + Trait.new( + id=ShapeID("smithy.synthetic#originalShapeId"), + value="com.amazonaws.lexruntimev2#StartConversationResponse", + ), + Trait.new(id=ShapeID("smithy.api#output")), + ], + members={ + "responseEventStream": { + "target": START_CONVERSATION_RESPONSE_EVENT_STREAM, + "traits": [Trait.new(id=ShapeID("smithy.api#httpPayload"))], + } + }, +) + +RECOGNIZE_TEXT = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#RecognizeText"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/text", + "code": 200, + } + ), + ) + ], +) + +START_CONVERSATION = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#StartConversation"), + shape_type=ShapeType.OPERATION, + traits=[ + Trait.new( + id=ShapeID("smithy.api#http"), + value=MappingProxyType( + { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/conversation", + "code": 200, + } + ), + ) + ], +) + +AWS_DEEP_SENSE_RUN_TIME_SERVICE_API2_0 = Schema( + id=ShapeID("com.amazonaws.lexruntimev2#AWSDeepSenseRunTimeServiceApi2_0"), + shape_type=ShapeType.SERVICE, + traits=[ + Trait.new( + id=ShapeID("aws.auth#sigv4"), value=MappingProxyType({"name": "lex"}) + ), + Trait.new(id=ShapeID("smithy.api#title"), value="Amazon Lex Runtime V2"), + Trait.new( + id=ShapeID("smithy.rules#endpointTests"), + value=MappingProxyType( + { + "testCases": ( + MappingProxyType( + { + "documentation": "For region af-south-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.af-south-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "af-south-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region ap-northeast-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.ap-northeast-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "ap-northeast-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region ap-northeast-2 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.ap-northeast-2.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "ap-northeast-2", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region ap-southeast-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.ap-southeast-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "ap-southeast-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region ap-southeast-2 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.ap-southeast-2.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "ap-southeast-2", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region ca-central-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.ca-central-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "ca-central-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region eu-central-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.eu-central-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "eu-central-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region eu-west-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.eu-west-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "eu-west-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region eu-west-2 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.eu-west-2.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "eu-west-2", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-east-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-west-2 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-west-2.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-west-2", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-east-1.api.aws" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": True, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-east-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": True, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-east-1.api.aws" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": False, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.cn-north-1.api.amazonwebservices.com.cn" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "cn-north-1", + "UseFIPS": True, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.cn-north-1.amazonaws.com.cn" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "cn-north-1", + "UseFIPS": True, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.cn-north-1.api.amazonwebservices.com.cn" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "cn-north-1", + "UseFIPS": False, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.cn-north-1.amazonaws.com.cn" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "cn-north-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-gov-east-1.api.aws" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-gov-east-1", + "UseFIPS": True, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-gov-east-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-gov-east-1", + "UseFIPS": True, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack enabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-gov-east-1.api.aws" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-gov-east-1", + "UseFIPS": False, + "UseDualStack": True, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-gov-east-1.amazonaws.com" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-gov-east-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-iso-east-1.c2s.ic.gov" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-iso-east-1", + "UseFIPS": True, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-iso-east-1.c2s.ic.gov" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-iso-east-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.us-isob-east-1.sc2s.sgov.gov" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-isob-east-1", + "UseFIPS": True, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.us-isob-east-1.sc2s.sgov.gov" + } + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-isob-east-1", + "UseFIPS": False, + "UseDualStack": False, + } + ), + } + ), + MappingProxyType( + { + "documentation": "For custom endpoint with region set and fips disabled and dualstack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + {"url": "https://example.com"} + ) + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": False, + "UseDualStack": False, + "Endpoint": "https://example.com", + } + ), + } + ), + MappingProxyType( + { + "documentation": "For custom endpoint with region not set and fips disabled and dualstack disabled", + "expect": MappingProxyType( + { + "endpoint": MappingProxyType( + {"url": "https://example.com"} + ) + } + ), + "params": MappingProxyType( + { + "UseFIPS": False, + "UseDualStack": False, + "Endpoint": "https://example.com", + } + ), + } + ), + MappingProxyType( + { + "documentation": "For custom endpoint with fips enabled and dualstack disabled", + "expect": MappingProxyType( + { + "error": "Invalid Configuration: FIPS and custom endpoint are not supported" + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": True, + "UseDualStack": False, + "Endpoint": "https://example.com", + } + ), + } + ), + MappingProxyType( + { + "documentation": "For custom endpoint with fips disabled and dualstack enabled", + "expect": MappingProxyType( + { + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported" + } + ), + "params": MappingProxyType( + { + "Region": "us-east-1", + "UseFIPS": False, + "UseDualStack": True, + "Endpoint": "https://example.com", + } + ), + } + ), + MappingProxyType( + { + "documentation": "Missing region", + "expect": MappingProxyType( + {"error": "Invalid Configuration: Missing Region"} + ), + } + ), + ), + "version": "1.0", + } + ), + ), + Trait.new( + id=ShapeID("smithy.rules#endpointRuleSet"), + value=MappingProxyType( + { + "version": "1.0", + "parameters": MappingProxyType( + { + "Region": MappingProxyType( + { + "builtIn": "AWS::Region", + "required": False, + "documentation": "The AWS region used to dispatch the request.", + "type": "string", + } + ), + "UseDualStack": MappingProxyType( + { + "builtIn": "AWS::UseDualStack", + "required": True, + "default": False, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "boolean", + } + ), + "UseFIPS": MappingProxyType( + { + "builtIn": "AWS::UseFIPS", + "required": True, + "default": False, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "boolean", + } + ), + "Endpoint": MappingProxyType( + { + "builtIn": "SDK::Endpoint", + "required": False, + "documentation": "Override the endpoint used to send this request", + "type": "string", + } + ), + } + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "isSet", + "argv": ( + MappingProxyType({"ref": "Endpoint"}), + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + {"ref": "UseFIPS"} + ), + True, + ), + } + ), + ), + "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "type": "error", + } + ), + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + {"ref": "UseDualStack"} + ), + True, + ), + } + ), + ), + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported", + "type": "error", + } + ), + MappingProxyType( + { + "conditions": (), + "endpoint": MappingProxyType( + { + "url": MappingProxyType( + {"ref": "Endpoint"} + ), + "properties": MappingProxyType({}), + "headers": MappingProxyType({}), + } + ), + "type": "endpoint", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "isSet", + "argv": ( + MappingProxyType({"ref": "Region"}), + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "aws.partition", + "argv": ( + MappingProxyType( + {"ref": "Region"} + ), + ), + "assign": "PartitionResult", + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + { + "ref": "UseFIPS" + } + ), + True, + ), + } + ), + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + { + "ref": "UseDualStack" + } + ), + True, + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + True, + MappingProxyType( + { + "fn": "getAttr", + "argv": ( + MappingProxyType( + { + "ref": "PartitionResult" + } + ), + "supportsFIPS", + ), + } + ), + ), + } + ), + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + True, + MappingProxyType( + { + "fn": "getAttr", + "argv": ( + MappingProxyType( + { + "ref": "PartitionResult" + } + ), + "supportsDualStack", + ), + } + ), + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": (), + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": MappingProxyType( + {} + ), + "headers": MappingProxyType( + {} + ), + } + ), + "type": "endpoint", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": (), + "error": "FIPS and DualStack are enabled, but this partition does not support one or both", + "type": "error", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + { + "ref": "UseFIPS" + } + ), + True, + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + { + "fn": "getAttr", + "argv": ( + MappingProxyType( + { + "ref": "PartitionResult" + } + ), + "supportsFIPS", + ), + } + ), + True, + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": (), + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex-fips.{Region}.{PartitionResult#dnsSuffix}", + "properties": MappingProxyType( + {} + ), + "headers": MappingProxyType( + {} + ), + } + ), + "type": "endpoint", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": (), + "error": "FIPS is enabled but this partition does not support FIPS", + "type": "error", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + MappingProxyType( + { + "ref": "UseDualStack" + } + ), + True, + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": ( + MappingProxyType( + { + "fn": "booleanEquals", + "argv": ( + True, + MappingProxyType( + { + "fn": "getAttr", + "argv": ( + MappingProxyType( + { + "ref": "PartitionResult" + } + ), + "supportsDualStack", + ), + } + ), + ), + } + ), + ), + "rules": ( + MappingProxyType( + { + "conditions": (), + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": MappingProxyType( + {} + ), + "headers": MappingProxyType( + {} + ), + } + ), + "type": "endpoint", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": (), + "error": "DualStack is enabled but this partition does not support DualStack", + "type": "error", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": (), + "endpoint": MappingProxyType( + { + "url": "https://runtime-v2-lex.{Region}.{PartitionResult#dnsSuffix}", + "properties": MappingProxyType( + {} + ), + "headers": MappingProxyType( + {} + ), + } + ), + "type": "endpoint", + } + ), + ), + "type": "tree", + } + ), + ), + "type": "tree", + } + ), + MappingProxyType( + { + "conditions": (), + "error": "Invalid Configuration: Missing Region", + "type": "error", + } + ), + ), + } + ), + ), + Trait.new( + id=ShapeID("aws.api#service"), + value=MappingProxyType( + { + "sdkId": "Lex Runtime V2", + "arnNamespace": "lex", + "cloudFormationName": "LexRuntimeV2", + "cloudTrailEventSource": "lexruntimev2.amazonaws.com", + "docId": "runtime.lex.v2-2020-08-07", + "endpointPrefix": "runtime-v2-lex", + } + ), + ), + Trait.new( + id=ShapeID("aws.protocols#restJson1"), + value=MappingProxyType( + {"http": ("http/1.1", "h2"), "eventStreamHttp": ("h2",)} + ), + ), + ], +) + +SLOT.members["subSlots"] = Schema.member( + id=SLOT.id.with_member("subSlots"), target=SLOTS, index=3 +) + +SLOT.members["values"] = Schema.member( + id=SLOT.id.with_member("values"), target=VALUES, index=2 +) + +RUNTIME_HINT_DETAILS.members["subSlotHints"] = Schema.member( + id=RUNTIME_HINT_DETAILS.id.with_member("subSlotHints"), + target=SLOT_HINTS_SLOT_MAP, + index=1, +) + +ELICIT_SUB_SLOT.members["subSlotToElicit"] = Schema.member( + id=ELICIT_SUB_SLOT.id.with_member("subSlotToElicit"), + target=ELICIT_SUB_SLOT, + index=1, +) diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/auth.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/auth.py new file mode 100644 index 0000000..7f2d692 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/auth.py @@ -0,0 +1,35 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from typing import Any + +from smithy_core.auth import AuthOption, AuthParams +from smithy_core.interfaces.auth import AuthOption as AuthOptionProtocol +from smithy_core.shapes import ShapeID + + +class HTTPAuthSchemeResolver: + def resolve_auth_scheme( + self, auth_parameters: AuthParams[Any, Any] + ) -> list[AuthOptionProtocol]: + auth_options: list[AuthOptionProtocol] = [] + + if auth_parameters.operation == "RecognizeUtterance": + if (option := _generate_sigv4_option(auth_parameters)) is not None: + auth_options.append(option) + + return auth_options + + if (option := _generate_sigv4_option(auth_parameters)) is not None: + auth_options.append(option) + + return auth_options + + +def _generate_sigv4_option( + auth_params: AuthParams[Any, Any], +) -> AuthOptionProtocol | None: + return AuthOption( + scheme_id=ShapeID("aws.auth#sigv4"), + identity_properties={}, # type: ignore + signer_properties={}, # type: ignore + ) diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/client.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/client.py new file mode 100644 index 0000000..ca595a9 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/client.py @@ -0,0 +1,509 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from copy import deepcopy +import logging + +from smithy_core.aio.client import ClientCall, RequestPipeline +from smithy_core.aio.eventstream import DuplexEventStream +from smithy_core.exceptions import ExpectationNotMetError +from smithy_core.interceptors import InterceptorChain +from smithy_core.retries import RetryStrategyResolver +from smithy_core.types import TypedProperties +from smithy_http.plugins import user_agent_plugin + +from .config import Config, Plugin +from .models import ( + DELETE_SESSION, + DeleteSessionInput, + DeleteSessionOutput, + GET_SESSION, + GetSessionInput, + GetSessionOutput, + PUT_SESSION, + PutSessionInput, + PutSessionOutput, + RECOGNIZE_TEXT, + RECOGNIZE_UTTERANCE, + RecognizeTextInput, + RecognizeTextOutput, + RecognizeUtteranceInput, + RecognizeUtteranceOutput, + START_CONVERSATION, + StartConversationInput, + StartConversationOutput, + StartConversationRequestEventStream, + StartConversationResponseEventStream, + _StartConversationResponseEventStreamDeserializer, +) +from .user_agent import aws_user_agent_plugin + + +logger = logging.getLogger(__name__) + + +class LexRuntimeV2Client: + """ + This section contains documentation for the Amazon Lex V2 Runtime V2 API + operations. + """ + + def __init__( + self, config: Config | None = None, plugins: list[Plugin] | None = None + ): + """ + Constructor for `LexRuntimeV2Client`. + + Args: + config: + Optional configuration for the client. Here you can set things like + the endpoint for HTTP services or auth credentials. + plugins: + A list of callables that modify the configuration dynamically. These + can be used to set defaults, for example. + """ + self._config = config or Config() + + client_plugins: list[Plugin] = [aws_user_agent_plugin, user_agent_plugin] + if plugins: + client_plugins.extend(plugins) + + for plugin in client_plugins: + plugin(self._config) + + self._retry_strategy_resolver = RetryStrategyResolver() + + async def delete_session( + self, input: DeleteSessionInput, plugins: list[Plugin] | None = None + ) -> DeleteSessionOutput: + """ + Removes session information for a specified bot, alias, and user ID. + + You can use this operation to restart a conversation with a bot. When + you remove a session, the entire history of the session is removed so + that you can start again. + + You don't need to delete a session. Sessions have a time limit and will + expire. Set the session time limit when you create the bot. The default + is 5 minutes, but you can specify anything between 1 minute and 24 + hours. + + If you specify a bot or alias ID that doesn't exist, you receive a + `BadRequestException.` + + If the locale doesn't exist in the bot, or if the locale hasn't been + enables for the alias, you receive a `BadRequestException`. + + Args: + input: + An instance of `DeleteSessionInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + An instance of `DeleteSessionOutput`. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=DELETE_SESSION, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline(call) + + async def get_session( + self, input: GetSessionInput, plugins: list[Plugin] | None = None + ) -> GetSessionOutput: + """ + Returns session information for a specified bot, alias, and user. + + For example, you can use this operation to retrieve session information + for a user that has left a long-running session in use. + + If the bot, alias, or session identifier doesn't exist, Amazon Lex V2 + returns a `BadRequestException`. If the locale doesn't exist or is not + enabled for the alias, you receive a `BadRequestException`. + + Args: + input: + An instance of `GetSessionInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + An instance of `GetSessionOutput`. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=GET_SESSION, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline(call) + + async def put_session( + self, input: PutSessionInput, plugins: list[Plugin] | None = None + ) -> PutSessionOutput: + """ + Creates a new session or modifies an existing session with an Amazon Lex + V2 bot. Use this operation to enable your application to set the state + of the bot. + + Args: + input: + An instance of `PutSessionInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + An instance of `PutSessionOutput`. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=PUT_SESSION, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline(call) + + async def recognize_text( + self, input: RecognizeTextInput, plugins: list[Plugin] | None = None + ) -> RecognizeTextOutput: + """ + Sends user input to Amazon Lex V2. Client applications use this API to + send requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets + the user input using the machine learning model that it build for the + bot. + + In response, Amazon Lex V2 returns the next message to convey to the + user and an optional response card to display. + + If the optional post-fulfillment response is specified, the messages are + returned as follows. For more information, see + [PostFulfillmentStatusSpecification](https://docs.aws.amazon.com/lexv2/latest/dg/API_PostFulfillmentStatusSpecification.html). + + - **Success message** - Returned if the Lambda function completes + successfully and the intent state is fulfilled or ready fulfillment if + the message is present. + + - **Failed message** - The failed message is returned if the Lambda + function throws an exception or if the Lambda function returns a + failed intent state without a message. + + - **Timeout message** - If you don't configure a timeout message and a + timeout, and the Lambda function doesn't return within 30 seconds, + the timeout message is returned. If you configure a timeout, the + timeout message is returned when the period times out. + + For more information, see [Completion + message](https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-complete.html). + + Args: + input: + An instance of `RecognizeTextInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + An instance of `RecognizeTextOutput`. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=RECOGNIZE_TEXT, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline(call) + + async def recognize_utterance( + self, input: RecognizeUtteranceInput, plugins: list[Plugin] | None = None + ) -> RecognizeUtteranceOutput: + """ + Sends user input to Amazon Lex V2. You can send text or speech. Clients + use this API to send text and audio requests to Amazon Lex V2 at + runtime. Amazon Lex V2 interprets the user input using the machine + learning model built for the bot. + + The following request fields must be compressed with gzip and then + base64 encoded before you send them to Amazon Lex V2. + + - requestAttributes + + - sessionState + + The following response fields are compressed using gzip and then base64 + encoded by Amazon Lex V2. Before you can use these fields, you must + decode and decompress them. + + - inputTranscript + + - interpretations + + - messages + + - requestAttributes + + - sessionState + + The example contains a Java application that compresses and encodes a + Java object to send to Amazon Lex V2, and a second that decodes and + decompresses a response from Amazon Lex V2. + + If the optional post-fulfillment response is specified, the messages are + returned as follows. For more information, see + [PostFulfillmentStatusSpecification](https://docs.aws.amazon.com/lexv2/latest/dg/API_PostFulfillmentStatusSpecification.html). + + - **Success message** - Returned if the Lambda function completes + successfully and the intent state is fulfilled or ready fulfillment if + the message is present. + + - **Failed message** - The failed message is returned if the Lambda + function throws an exception or if the Lambda function returns a + failed intent state without a message. + + - **Timeout message** - If you don't configure a timeout message and a + timeout, and the Lambda function doesn't return within 30 seconds, + the timeout message is returned. If you configure a timeout, the + timeout message is returned when the period times out. + + For more information, see [Completion + message](https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-complete.html). + + Args: + input: + An instance of `RecognizeUtteranceInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + An instance of `RecognizeUtteranceOutput`. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=RECOGNIZE_UTTERANCE, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline(call) + + async def start_conversation( + self, input: StartConversationInput, plugins: list[Plugin] | None = None + ) -> DuplexEventStream[ + StartConversationRequestEventStream, + StartConversationResponseEventStream, + StartConversationOutput, + ]: + """ + Starts an HTTP/2 bidirectional event stream that enables you to send + audio, text, or DTMF input in real time. After your application starts a + conversation, users send input to Amazon Lex V2 as a stream of events. + Amazon Lex V2 processes the incoming events and responds with streaming + text or audio events. + + Audio input must be in the following format: + `audio/lpcm sample-rate=8000 sample-size-bits=16 channel-count=1; is-big-endian=false`. + + If the optional post-fulfillment response is specified, the messages are + returned as follows. For more information, see + [PostFulfillmentStatusSpecification](https://docs.aws.amazon.com/lexv2/latest/dg/API_PostFulfillmentStatusSpecification.html). + + - **Success message** - Returned if the Lambda function completes + successfully and the intent state is fulfilled or ready fulfillment if + the message is present. + + - **Failed message** - The failed message is returned if the Lambda + function throws an exception or if the Lambda function returns a + failed intent state without a message. + + - **Timeout message** - If you don't configure a timeout message and a + timeout, and the Lambda function doesn't return within 30 seconds, + the timeout message is returned. If you configure a timeout, the + timeout message is returned when the period times out. + + For more information, see [Completion + message](https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-complete.html). + + If the optional update message is configured, it is played at the + specified frequency while the Lambda function is running and the update + message state is active. If the fulfillment update message is not + active, the Lambda function runs with a 30 second timeout. + + For more information, see [Update + message](https://docs.aws.amazon.com/lexv2/latest/dg/streaming-progress.html#progress-update.html) + + The `StartConversation` operation is supported only in the following + SDKs: + + - [AWS SDK for + C++](https://docs.aws.amazon.com/goto/SdkForCpp/runtime.lex.v2-2020-08-07/StartConversation) + + - [AWS SDK for Java + V2](https://docs.aws.amazon.com/goto/SdkForJavaV2/runtime.lex.v2-2020-08-07/StartConversation) + + - [AWS SDK for Ruby + V3](https://docs.aws.amazon.com/goto/SdkForRubyV3/runtime.lex.v2-2020-08-07/StartConversation) + + Args: + input: + An instance of `StartConversationInput`. + plugins: + A list of callables that modify the configuration dynamically. + Changes made by these plugins only apply for the duration of the + operation execution and will not affect any other operation + invocations. + + Returns: + A `DuplexEventStream` for bidirectional streaming. + """ + operation_plugins: list[Plugin] = [] + if plugins: + operation_plugins.extend(plugins) + config = deepcopy(self._config) + for plugin in operation_plugins: + plugin(config) + if config.protocol is None or config.transport is None: + raise ExpectationNotMetError( + "protocol and transport MUST be set on the config to make calls." + ) + + retry_strategy = await self._retry_strategy_resolver.resolve_retry_strategy( + retry_strategy=config.retry_strategy + ) + + pipeline = RequestPipeline(protocol=config.protocol, transport=config.transport) + call = ClientCall( + input=input, + operation=START_CONVERSATION, + context=TypedProperties({"config": config}), + interceptor=InterceptorChain(config.interceptors), + auth_scheme_resolver=config.auth_scheme_resolver, + supported_auth_schemes=config.auth_schemes, + endpoint_resolver=config.endpoint_resolver, + retry_strategy=retry_strategy, + ) + + return await pipeline.duplex_stream( + call, + StartConversationRequestEventStream, + StartConversationResponseEventStream, + _StartConversationResponseEventStreamDeserializer().deserialize, + ) diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/config.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/config.py new file mode 100644 index 0000000..f425dc5 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/config.py @@ -0,0 +1,189 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from dataclasses import dataclass +from typing import Any, Callable, TypeAlias, Union + +from smithy_aws_core.aio.protocols import RestJsonClientProtocol +from smithy_aws_core.auth import SigV4AuthScheme +from smithy_aws_core.endpoints.standard_regional import ( + StandardRegionalEndpointsResolver as _RegionalResolver, +) +from smithy_aws_core.identity import AWSCredentialsIdentity, AWSIdentityProperties +from smithy_core.aio.interfaces import ( + ClientProtocol, + ClientTransport, + EndpointResolver as _EndpointResolver, +) +from smithy_core.aio.interfaces.auth import AuthScheme +from smithy_core.aio.interfaces.identity import IdentityResolver +from smithy_core.interceptors import Interceptor +from smithy_core.interfaces import URI +from smithy_core.interfaces.retries import RetryStrategy +from smithy_core.retries import RetryStrategyOptions +from smithy_core.shapes import ShapeID +from smithy_http.aio.crt import AWSCRTHTTPClient +from smithy_http.interfaces import HTTPRequestConfiguration + +from ._private.schemas import ( + AWS_DEEP_SENSE_RUN_TIME_SERVICE_API2_0 as _SCHEMA_AWS_DEEP_SENSE_RUN_TIME_SERVICE_API2_0, +) +from .auth import HTTPAuthSchemeResolver +from .models import ( + DeleteSessionInput, + DeleteSessionOutput, + GetSessionInput, + GetSessionOutput, + PutSessionInput, + PutSessionOutput, + RecognizeTextInput, + RecognizeTextOutput, + RecognizeUtteranceInput, + RecognizeUtteranceOutput, + StartConversationInput, + StartConversationOutput, +) + + +_ServiceInterceptor = Union[ + Interceptor[DeleteSessionInput, DeleteSessionOutput, Any, Any], + Interceptor[GetSessionInput, GetSessionOutput, Any, Any], + Interceptor[PutSessionInput, PutSessionOutput, Any, Any], + Interceptor[RecognizeTextInput, RecognizeTextOutput, Any, Any], + Interceptor[RecognizeUtteranceInput, RecognizeUtteranceOutput, Any, Any], + Interceptor[StartConversationInput, StartConversationOutput, Any, Any], +] + + +@dataclass(init=False) +class Config: + """Configuration for Lex Runtime V2.""" + + auth_scheme_resolver: HTTPAuthSchemeResolver + """ + An auth scheme resolver that determines the auth scheme for each + operation. + """ + + auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] + """A map of auth scheme ids to auth schemes.""" + + aws_access_key_id: str | None + """The identifier for a secret access key.""" + + aws_credentials_identity_resolver: ( + IdentityResolver[AWSCredentialsIdentity, AWSIdentityProperties] | None + ) + """Resolves AWS Credentials. Required for operations that use Sigv4 Auth.""" + + aws_secret_access_key: str | None + """A secret access key that can be used to sign requests.""" + + aws_session_token: str | None + """An access key ID that identifies temporary security credentials.""" + + endpoint_resolver: _EndpointResolver + """ + The endpoint resolver used to resolve the final endpoint per-operation + based on the configuration. + """ + + endpoint_uri: str | URI | None + """A static URI to route requests to.""" + + http_request_config: HTTPRequestConfiguration | None + """Configuration for individual HTTP requests.""" + + interceptors: list[_ServiceInterceptor] + """ + The list of interceptors, which are hooks that are called during the + execution of a request. + """ + + protocol: ClientProtocol[Any, Any] | None + """The protocol to serialize and deserialize requests with.""" + + region: str | None + """ + The AWS region to connect to. The configured region is used to determine + the service endpoint. + """ + + retry_strategy: RetryStrategy | RetryStrategyOptions | None + """ + The retry strategy or options for configuring retry behavior. Can be + either a configured RetryStrategy or RetryStrategyOptions to create one. + """ + + sdk_ua_app_id: str | None + """ + A unique and opaque application ID that is appended to the User-Agent + header. + """ + + transport: ClientTransport[Any, Any] | None + """The transport to use to send requests (e.g. an HTTP client).""" + + user_agent_extra: str | None + """Additional suffix to be added to the User-Agent header.""" + + def __init__( + self, + *, + auth_scheme_resolver: HTTPAuthSchemeResolver | None = None, + auth_schemes: dict[ShapeID, AuthScheme[Any, Any, Any, Any]] | None = None, + aws_access_key_id: str | None = None, + aws_credentials_identity_resolver: IdentityResolver[ + AWSCredentialsIdentity, AWSIdentityProperties + ] + | None = None, + aws_secret_access_key: str | None = None, + aws_session_token: str | None = None, + endpoint_resolver: _EndpointResolver | None = None, + endpoint_uri: str | URI | None = None, + http_request_config: HTTPRequestConfiguration | None = None, + interceptors: list[_ServiceInterceptor] | None = None, + protocol: ClientProtocol[Any, Any] | None = None, + region: str | None = None, + retry_strategy: RetryStrategy | RetryStrategyOptions | None = None, + sdk_ua_app_id: str | None = None, + transport: ClientTransport[Any, Any] | None = None, + user_agent_extra: str | None = None, + ): + self.auth_scheme_resolver = auth_scheme_resolver or HTTPAuthSchemeResolver() + self.auth_schemes = auth_schemes or { + ShapeID("aws.auth#sigv4"): SigV4AuthScheme(service="lex") + } + self.aws_access_key_id = aws_access_key_id + self.aws_credentials_identity_resolver = aws_credentials_identity_resolver + self.aws_secret_access_key = aws_secret_access_key + self.aws_session_token = aws_session_token + self.endpoint_resolver = endpoint_resolver or _RegionalResolver( + endpoint_prefix="runtime-v2-lex" + ) + self.endpoint_uri = endpoint_uri + self.http_request_config = http_request_config + self.interceptors = interceptors or [] + self.protocol = protocol or RestJsonClientProtocol( + _SCHEMA_AWS_DEEP_SENSE_RUN_TIME_SERVICE_API2_0 + ) + self.region = region + self.retry_strategy = retry_strategy + self.sdk_ua_app_id = sdk_ua_app_id + self.transport = transport or AWSCRTHTTPClient() + self.user_agent_extra = user_agent_extra + + def set_auth_scheme(self, scheme: AuthScheme[Any, Any, Any, Any]) -> None: + """ + Sets the implementation of an auth scheme. + + Using this method ensures the correct key is used. + + Args: + scheme: + The auth scheme to add. + """ + self.auth_schemes[scheme.scheme_id] = scheme + + +Plugin: TypeAlias = Callable[[Config], None] +"""A callable that allows customizing the config object on each request.""" diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/models.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/models.py new file mode 100644 index 0000000..ec72518 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/models.py @@ -0,0 +1,5543 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from dataclasses import dataclass, field +from enum import StrEnum +import logging +from typing import Any, Literal, Self, Union + +from smithy_core.aio.interfaces import StreamingBlob +from smithy_core.deserializers import ShapeDeserializer +from smithy_core.documents import TypeRegistry +from smithy_core.exceptions import ModeledError, SerializationError +from smithy_core.schemas import APIOperation, Schema +from smithy_core.serializers import ShapeSerializer +from smithy_core.shapes import ShapeID + +from ._private.schemas import ( + ACCESS_DENIED_EXCEPTION as _SCHEMA_ACCESS_DENIED_EXCEPTION, + ACTIVE_CONTEXT as _SCHEMA_ACTIVE_CONTEXT, + ACTIVE_CONTEXT_TIME_TO_LIVE as _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE, + AUDIO_INPUT_EVENT as _SCHEMA_AUDIO_INPUT_EVENT, + AUDIO_RESPONSE_EVENT as _SCHEMA_AUDIO_RESPONSE_EVENT, + BAD_GATEWAY_EXCEPTION as _SCHEMA_BAD_GATEWAY_EXCEPTION, + BUTTON as _SCHEMA_BUTTON, + CONFIDENCE_SCORE as _SCHEMA_CONFIDENCE_SCORE, + CONFIGURATION_EVENT as _SCHEMA_CONFIGURATION_EVENT, + CONFLICT_EXCEPTION as _SCHEMA_CONFLICT_EXCEPTION, + DELETE_SESSION as _SCHEMA_DELETE_SESSION, + DELETE_SESSION_INPUT as _SCHEMA_DELETE_SESSION_INPUT, + DELETE_SESSION_OUTPUT as _SCHEMA_DELETE_SESSION_OUTPUT, + DEPENDENCY_FAILED_EXCEPTION as _SCHEMA_DEPENDENCY_FAILED_EXCEPTION, + DIALOG_ACTION as _SCHEMA_DIALOG_ACTION, + DISCONNECTION_EVENT as _SCHEMA_DISCONNECTION_EVENT, + DTMF_INPUT_EVENT as _SCHEMA_DTMF_INPUT_EVENT, + ELICIT_SUB_SLOT as _SCHEMA_ELICIT_SUB_SLOT, + GET_SESSION as _SCHEMA_GET_SESSION, + GET_SESSION_INPUT as _SCHEMA_GET_SESSION_INPUT, + GET_SESSION_OUTPUT as _SCHEMA_GET_SESSION_OUTPUT, + HEARTBEAT_EVENT as _SCHEMA_HEARTBEAT_EVENT, + IMAGE_RESPONSE_CARD as _SCHEMA_IMAGE_RESPONSE_CARD, + INTENT as _SCHEMA_INTENT, + INTENT_RESULT_EVENT as _SCHEMA_INTENT_RESULT_EVENT, + INTERNAL_SERVER_EXCEPTION as _SCHEMA_INTERNAL_SERVER_EXCEPTION, + INTERPRETATION as _SCHEMA_INTERPRETATION, + MESSAGE as _SCHEMA_MESSAGE, + PLAYBACK_COMPLETION_EVENT as _SCHEMA_PLAYBACK_COMPLETION_EVENT, + PLAYBACK_INTERRUPTION_EVENT as _SCHEMA_PLAYBACK_INTERRUPTION_EVENT, + PUT_SESSION as _SCHEMA_PUT_SESSION, + PUT_SESSION_INPUT as _SCHEMA_PUT_SESSION_INPUT, + PUT_SESSION_OUTPUT as _SCHEMA_PUT_SESSION_OUTPUT, + RECOGNIZED_BOT_MEMBER as _SCHEMA_RECOGNIZED_BOT_MEMBER, + RECOGNIZE_TEXT as _SCHEMA_RECOGNIZE_TEXT, + RECOGNIZE_TEXT_INPUT as _SCHEMA_RECOGNIZE_TEXT_INPUT, + RECOGNIZE_TEXT_OUTPUT as _SCHEMA_RECOGNIZE_TEXT_OUTPUT, + RECOGNIZE_UTTERANCE as _SCHEMA_RECOGNIZE_UTTERANCE, + RECOGNIZE_UTTERANCE_INPUT as _SCHEMA_RECOGNIZE_UTTERANCE_INPUT, + RECOGNIZE_UTTERANCE_OUTPUT as _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT, + RESOURCE_NOT_FOUND_EXCEPTION as _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + RUNTIME_HINTS as _SCHEMA_RUNTIME_HINTS, + RUNTIME_HINT_DETAILS as _SCHEMA_RUNTIME_HINT_DETAILS, + RUNTIME_HINT_VALUE as _SCHEMA_RUNTIME_HINT_VALUE, + SENTIMENT_RESPONSE as _SCHEMA_SENTIMENT_RESPONSE, + SENTIMENT_SCORE as _SCHEMA_SENTIMENT_SCORE, + SESSION_STATE as _SCHEMA_SESSION_STATE, + SLOT as _SCHEMA_SLOT, + START_CONVERSATION as _SCHEMA_START_CONVERSATION, + START_CONVERSATION_INPUT as _SCHEMA_START_CONVERSATION_INPUT, + START_CONVERSATION_OUTPUT as _SCHEMA_START_CONVERSATION_OUTPUT, + START_CONVERSATION_REQUEST_EVENT_STREAM as _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, + START_CONVERSATION_RESPONSE_EVENT_STREAM as _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, + TEXT_INPUT_EVENT as _SCHEMA_TEXT_INPUT_EVENT, + TEXT_RESPONSE_EVENT as _SCHEMA_TEXT_RESPONSE_EVENT, + THROTTLING_EXCEPTION as _SCHEMA_THROTTLING_EXCEPTION, + TRANSCRIPT_EVENT as _SCHEMA_TRANSCRIPT_EVENT, + VALIDATION_EXCEPTION as _SCHEMA_VALIDATION_EXCEPTION, + VALUE as _SCHEMA_VALUE, +) + + +logger = logging.getLogger(__name__) + + +class ServiceError(ModeledError): + """ + Base error for all errors in the service. + + Some exceptions do not extend from this class, including + synthetic, implicit, and shared exception types. + """ + + +@dataclass(kw_only=True) +class AccessDeniedException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_ACCESS_DENIED_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_ACCESS_DENIED_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_ACCESS_DENIED_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_ACCESS_DENIED_EXCEPTION, consumer=_consumer) + return kwargs + + +def _serialize_active_context_parameters_map( + serializer: ShapeSerializer, schema: Schema, value: dict[str, str] +) -> None: + with serializer.begin_map(schema, len(value)) as m: + value_schema = schema.members["value"] + for k, v in value.items(): + m.entry(k, lambda vs: vs.write_string(value_schema, v)) + + +def _deserialize_active_context_parameters_map( + deserializer: ShapeDeserializer, schema: Schema +) -> dict[str, str]: + result: dict[str, str] = {} + value_schema = schema.members["value"] + + def _read_value(k: str, d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result[k] = d.read_string(value_schema) + + deserializer.read_map(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class ActiveContextTimeToLive: + """ + The time that a context is active. You can specify the time to live in + seconds or in conversation turns. + """ + + time_to_live_in_seconds: int + """ + The number of seconds that the context is active. You can specify + between 5 and 86400 seconds (24 hours). + """ + + turns_to_live: int + """ + The number of turns that the context is active. You can specify up to 20 + turns. Each request and response from the bot is a turn. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_integer( + _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE.members["timeToLiveInSeconds"], + self.time_to_live_in_seconds, + ) + serializer.write_integer( + _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE.members["turnsToLive"], + self.turns_to_live, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["time_to_live_in_seconds"] = de.read_integer( + _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE.members[ + "timeToLiveInSeconds" + ] + ) + + case 1: + kwargs["turns_to_live"] = de.read_integer( + _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE.members["turnsToLive"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct( + _SCHEMA_ACTIVE_CONTEXT_TIME_TO_LIVE, consumer=_consumer + ) + return kwargs + + +@dataclass(kw_only=True) +class ActiveContext: + """ + Contains information about the contexts that a user is using in a + session. You can configure Amazon Lex V2 to set a context when an intent + is fulfilled, or you can set a context using the , , or operations. + + Use a context to indicate to Amazon Lex V2 intents that should be used + as follow-up intents. For example, if the active context is + `order-fulfilled`, only intents that have `order-fulfilled` configured + as a trigger are considered for follow up. + """ + + name: str + """The name of the context.""" + + time_to_live: ActiveContextTimeToLive + """ + Indicates the number of turns or seconds that the context is active. + Once the time to live expires, the context is no longer returned in a + response. + """ + + context_attributes: dict[str, str] + """ + A list of contexts active for the request. A context can be activated + when a previous intent is fulfilled, or by including the context in the + request. + + If you don't specify a list of contexts, Amazon Lex V2 will use the + current list of contexts for the session. If you specify an empty list, + all contexts for the session are cleared. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_ACTIVE_CONTEXT, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_ACTIVE_CONTEXT.members["name"], self.name) + serializer.write_struct( + _SCHEMA_ACTIVE_CONTEXT.members["timeToLive"], self.time_to_live + ) + _serialize_active_context_parameters_map( + serializer, + _SCHEMA_ACTIVE_CONTEXT.members["contextAttributes"], + self.context_attributes, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["name"] = de.read_string( + _SCHEMA_ACTIVE_CONTEXT.members["name"] + ) + + case 1: + kwargs["time_to_live"] = ActiveContextTimeToLive.deserialize(de) + + case 2: + kwargs["context_attributes"] = ( + _deserialize_active_context_parameters_map( + de, _SCHEMA_ACTIVE_CONTEXT.members["contextAttributes"] + ) + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_ACTIVE_CONTEXT, consumer=_consumer) + return kwargs + + +def _serialize_active_contexts_list( + serializer: ShapeSerializer, schema: Schema, value: list[ActiveContext] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_active_contexts_list( + deserializer: ShapeDeserializer, schema: Schema +) -> list[ActiveContext]: + result: list[ActiveContext] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(ActiveContext.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class AudioInputEvent: + """ + Represents a chunk of audio sent from the client application to Amazon + Lex V2. The audio is all or part of an utterance from the user. + + Amazon Lex V2 accumulates audio chunks until it recognizes a natural + pause in speech before processing the input. + """ + + content_type: str + """ + The encoding used for the audio chunk. You must use 8 KHz PCM 16-bit + mono-channel little-endian format. The value of the field should be: + + `audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; is-big-endian=false` + """ + + audio_chunk: bytes | None = None + """An encoded stream of audio.""" + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_AUDIO_INPUT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.audio_chunk is not None: + serializer.write_blob( + _SCHEMA_AUDIO_INPUT_EVENT.members["audioChunk"], self.audio_chunk + ) + + serializer.write_string( + _SCHEMA_AUDIO_INPUT_EVENT.members["contentType"], self.content_type + ) + if self.event_id is not None: + serializer.write_string( + _SCHEMA_AUDIO_INPUT_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_AUDIO_INPUT_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["audio_chunk"] = de.read_blob( + _SCHEMA_AUDIO_INPUT_EVENT.members["audioChunk"] + ) + + case 1: + kwargs["content_type"] = de.read_string( + _SCHEMA_AUDIO_INPUT_EVENT.members["contentType"] + ) + + case 2: + kwargs["event_id"] = de.read_string( + _SCHEMA_AUDIO_INPUT_EVENT.members["eventId"] + ) + + case 3: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_AUDIO_INPUT_EVENT.members["clientTimestampMillis"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_AUDIO_INPUT_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class AudioResponseEvent: + """ + An event sent from Amazon Lex V2 to your client application containing + audio to play to the user. + """ + + audio_chunk: bytes | None = None + """A chunk of the audio to play.""" + + content_type: str | None = None + """ + The encoding of the audio chunk. This is the same as the encoding + configure in the `contentType` field of the `ConfigurationEvent`. + """ + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_AUDIO_RESPONSE_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.audio_chunk is not None: + serializer.write_blob( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["audioChunk"], self.audio_chunk + ) + + if self.content_type is not None: + serializer.write_string( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["contentType"], self.content_type + ) + + if self.event_id is not None: + serializer.write_string( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["eventId"], self.event_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["audio_chunk"] = de.read_blob( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["audioChunk"] + ) + + case 1: + kwargs["content_type"] = de.read_string( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["contentType"] + ) + + case 2: + kwargs["event_id"] = de.read_string( + _SCHEMA_AUDIO_RESPONSE_EVENT.members["eventId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_AUDIO_RESPONSE_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class ConflictException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_CONFLICT_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_CONFLICT_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_CONFLICT_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_CONFLICT_EXCEPTION, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class DeleteSessionInput: + """Dataclass for DeleteSessionInput structure.""" + + bot_id: str | None = None + """The identifier of the bot that contains the session data.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that contains the session data.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the session to delete.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DELETE_SESSION_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_INPUT.members["botAliasId"], self.bot_alias_id + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_INPUT.members["sessionId"], self.session_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_INPUT.members["sessionId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_DELETE_SESSION_INPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class DeleteSessionOutput: + """Dataclass for DeleteSessionOutput structure.""" + + bot_id: str | None = None + """The identifier of the bot that contained the session data.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that contained the session data.""" + + locale_id: str | None = None + """The locale where the session was used.""" + + session_id: str | None = None + """The identifier of the deleted session.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DELETE_SESSION_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["botAliasId"], self.bot_alias_id + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["sessionId"], self.session_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_DELETE_SESSION_OUTPUT.members["sessionId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_DELETE_SESSION_OUTPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class InternalServerException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "server" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_INTERNAL_SERVER_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_INTERNAL_SERVER_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_INTERNAL_SERVER_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_INTERNAL_SERVER_EXCEPTION, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class ResourceNotFoundException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct( + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, consumer=_consumer + ) + return kwargs + + +@dataclass(kw_only=True) +class ThrottlingException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_THROTTLING_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_THROTTLING_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_THROTTLING_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_THROTTLING_EXCEPTION, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class ValidationException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_VALIDATION_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_VALIDATION_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_VALIDATION_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_VALIDATION_EXCEPTION, consumer=_consumer) + return kwargs + + +DELETE_SESSION = APIOperation( + input=DeleteSessionInput, + output=DeleteSessionOutput, + schema=_SCHEMA_DELETE_SESSION, + input_schema=_SCHEMA_DELETE_SESSION_INPUT, + output_schema=_SCHEMA_DELETE_SESSION_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID("com.amazonaws.lexruntimev2#ConflictException"): ConflictException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ResourceNotFoundException" + ): ResourceNotFoundException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_CONFLICT_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) + + +@dataclass(kw_only=True) +class GetSessionInput: + """Dataclass for GetSessionInput structure.""" + + bot_id: str | None = None + """The identifier of the bot that contains the session data.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that contains the session data.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the session to return.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_GET_SESSION_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_GET_SESSION_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_GET_SESSION_INPUT.members["botAliasId"], self.bot_alias_id + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_GET_SESSION_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_GET_SESSION_INPUT.members["sessionId"], self.session_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_GET_SESSION_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_GET_SESSION_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_GET_SESSION_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_GET_SESSION_INPUT.members["sessionId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_GET_SESSION_INPUT, consumer=_consumer) + return kwargs + + +class ConfirmationState(StrEnum): + CONFIRMED = "Confirmed" + DENIED = "Denied" + NONE = "None" + + +class Shape(StrEnum): + SCALAR = "Scalar" + LIST_ = "List" + COMPOSITE = "Composite" + + +def _serialize_string_list( + serializer: ShapeSerializer, schema: Schema, value: list[str] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_string(member_schema, e) + + +def _deserialize_string_list( + deserializer: ShapeDeserializer, schema: Schema +) -> list[str]: + result: list[str] = [] + member_schema = schema.members["member"] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(d.read_string(member_schema)) + + deserializer.read_list(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class Value: + """ + Information about the value provided for a slot and Amazon Lex V2's + interpretation. + """ + + interpreted_value: str + """ + The value that Amazon Lex V2 determines for the slot, given the user + input. The actual value depends on the setting of the value selection + strategy for the bot. You can choose to use the value entered by the + user, or you can have Amazon Lex V2 choose the first value in the + `resolvedValues` list. + """ + + original_value: str | None = None + """ + The part of the user's response to the slot elicitation that Amazon Lex + V2 determines is relevant to the slot value. + """ + + resolved_values: list[str] | None = None + """ + A list of values that Amazon Lex V2 determines are possible resolutions + for the user input. The first value matches the `interpretedValue`. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_VALUE, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.original_value is not None: + serializer.write_string( + _SCHEMA_VALUE.members["originalValue"], self.original_value + ) + + serializer.write_string( + _SCHEMA_VALUE.members["interpretedValue"], self.interpreted_value + ) + if self.resolved_values is not None: + _serialize_string_list( + serializer, + _SCHEMA_VALUE.members["resolvedValues"], + self.resolved_values, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["original_value"] = de.read_string( + _SCHEMA_VALUE.members["originalValue"] + ) + + case 1: + kwargs["interpreted_value"] = de.read_string( + _SCHEMA_VALUE.members["interpretedValue"] + ) + + case 2: + kwargs["resolved_values"] = _deserialize_string_list( + de, _SCHEMA_VALUE.members["resolvedValues"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_VALUE, consumer=_consumer) + return kwargs + + +class IntentState(StrEnum): + FAILED = "Failed" + FULFILLED = "Fulfilled" + IN_PROGRESS = "InProgress" + READY_FOR_FULFILLMENT = "ReadyForFulfillment" + WAITING = "Waiting" + FULFILLMENT_IN_PROGRESS = "FulfillmentInProgress" + + +class InterpretationSource(StrEnum): + BEDROCK = "Bedrock" + LEX = "Lex" + + +@dataclass(kw_only=True) +class ConfidenceScore: + """ + Provides a score that indicates the confidence that Amazon Lex V2 has + that an intent is the one that satisfies the user's intent. + """ + + score: float = 0 + """ + A score that indicates how confident Amazon Lex V2 is that an intent + satisfies the user's intent. Ranges between 0.00 and 1.00. Higher + scores indicate higher confidence. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_CONFIDENCE_SCORE, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_double(_SCHEMA_CONFIDENCE_SCORE.members["score"], self.score) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["score"] = de.read_double( + _SCHEMA_CONFIDENCE_SCORE.members["score"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_CONFIDENCE_SCORE, consumer=_consumer) + return kwargs + + +class SentimentType(StrEnum): + MIXED = "MIXED" + NEGATIVE = "NEGATIVE" + NEUTRAL = "NEUTRAL" + POSITIVE = "POSITIVE" + + +@dataclass(kw_only=True) +class SentimentScore: + """The individual sentiment responses for the utterance.""" + + positive: float = 0 + """ + The level of confidence that Amazon Comprehend has in the accuracy of + its detection of the `POSITIVE` sentiment. + """ + + negative: float = 0 + """ + The level of confidence that Amazon Comprehend has in the accuracy of + its detection of the `NEGATIVE` sentiment. + """ + + neutral: float = 0 + """ + The level of confidence that Amazon Comprehend has in the accuracy of + its detection of the `NEUTRAL` sentiment. + """ + + mixed: float = 0 + """ + The level of confidence that Amazon Comprehend has in the accuracy of + its detection of the `MIXED` sentiment. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_SENTIMENT_SCORE, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_double( + _SCHEMA_SENTIMENT_SCORE.members["positive"], self.positive + ) + serializer.write_double( + _SCHEMA_SENTIMENT_SCORE.members["negative"], self.negative + ) + serializer.write_double( + _SCHEMA_SENTIMENT_SCORE.members["neutral"], self.neutral + ) + serializer.write_double(_SCHEMA_SENTIMENT_SCORE.members["mixed"], self.mixed) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["positive"] = de.read_double( + _SCHEMA_SENTIMENT_SCORE.members["positive"] + ) + + case 1: + kwargs["negative"] = de.read_double( + _SCHEMA_SENTIMENT_SCORE.members["negative"] + ) + + case 2: + kwargs["neutral"] = de.read_double( + _SCHEMA_SENTIMENT_SCORE.members["neutral"] + ) + + case 3: + kwargs["mixed"] = de.read_double( + _SCHEMA_SENTIMENT_SCORE.members["mixed"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_SENTIMENT_SCORE, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class SentimentResponse: + """ + Provides information about the sentiment expressed in a user's response + in a conversation. Sentiments are determined using Amazon Comprehend. + Sentiments are only returned if they are enabled for the bot. + + For more information, see [Determine + Sentiment](https://docs.aws.amazon.com/comprehend/latest/dg/how-sentiment.html) + in the *Amazon Comprehend developer guide*. + """ + + sentiment: str | None = None + """ + The overall sentiment expressed in the user's response. This is the + sentiment most likely expressed by the user based on the analysis by + Amazon Comprehend. + """ + + sentiment_score: SentimentScore | None = None + """The individual sentiment responses for the utterance.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_SENTIMENT_RESPONSE, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.sentiment is not None: + serializer.write_string( + _SCHEMA_SENTIMENT_RESPONSE.members["sentiment"], self.sentiment + ) + + if self.sentiment_score is not None: + serializer.write_struct( + _SCHEMA_SENTIMENT_RESPONSE.members["sentimentScore"], + self.sentiment_score, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["sentiment"] = de.read_string( + _SCHEMA_SENTIMENT_RESPONSE.members["sentiment"] + ) + + case 1: + kwargs["sentiment_score"] = SentimentScore.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_SENTIMENT_RESPONSE, consumer=_consumer) + return kwargs + + +class MessageContentType(StrEnum): + CUSTOM_PAYLOAD = "CustomPayload" + IMAGE_RESPONSE_CARD = "ImageResponseCard" + PLAIN_TEXT = "PlainText" + SSML = "SSML" + + +@dataclass(kw_only=True) +class Button: + """A button that appears on a response card show to the user.""" + + text: str + """The text that is displayed on the button.""" + + value: str + """The value returned to Amazon Lex V2 when a user chooses the button.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_BUTTON, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_BUTTON.members["text"], self.text) + serializer.write_string(_SCHEMA_BUTTON.members["value"], self.value) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["text"] = de.read_string(_SCHEMA_BUTTON.members["text"]) + + case 1: + kwargs["value"] = de.read_string(_SCHEMA_BUTTON.members["value"]) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_BUTTON, consumer=_consumer) + return kwargs + + +def _serialize_buttons_list( + serializer: ShapeSerializer, schema: Schema, value: list[Button] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_buttons_list( + deserializer: ShapeDeserializer, schema: Schema +) -> list[Button]: + result: list[Button] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(Button.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class ImageResponseCard: + """ + A card that is shown to the user by a messaging platform. You define the + contents of the card, the card is displayed by the platform. + + When you use a response card, the response from the user is constrained + to the text associated with a button on the card. + """ + + title: str + """ + The title to display on the response card. The format of the title is + determined by the platform displaying the response card. + """ + + subtitle: str | None = None + """ + The subtitle to display on the response card. The format of the subtitle + is determined by the platform displaying the response card. + """ + + image_url: str | None = None + """ + The URL of an image to display on the response card. The image URL must + be publicly available so that the platform displaying the response card + has access to the image. + """ + + buttons: list[Button] | None = None + """ + A list of buttons that should be displayed on the response card. The + arrangement of the buttons is determined by the platform that displays + the button. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_IMAGE_RESPONSE_CARD, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["title"], self.title + ) + if self.subtitle is not None: + serializer.write_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["subtitle"], self.subtitle + ) + + if self.image_url is not None: + serializer.write_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["imageUrl"], self.image_url + ) + + if self.buttons is not None: + _serialize_buttons_list( + serializer, _SCHEMA_IMAGE_RESPONSE_CARD.members["buttons"], self.buttons + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["title"] = de.read_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["title"] + ) + + case 1: + kwargs["subtitle"] = de.read_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["subtitle"] + ) + + case 2: + kwargs["image_url"] = de.read_string( + _SCHEMA_IMAGE_RESPONSE_CARD.members["imageUrl"] + ) + + case 3: + kwargs["buttons"] = _deserialize_buttons_list( + de, _SCHEMA_IMAGE_RESPONSE_CARD.members["buttons"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_IMAGE_RESPONSE_CARD, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class Message: + """Container for text that is returned to the customer..""" + + content_type: str + """Indicates the type of response.""" + + content: str | None = field(repr=False, default=None) + """The text of the message.""" + + image_response_card: ImageResponseCard | None = None + """ + A card that is shown to the user by a messaging platform. You define the + contents of the card, the card is displayed by the platform. + + When you use a response card, the response from the user is constrained + to the text associated with a button on the card. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_MESSAGE, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.content is not None: + serializer.write_string(_SCHEMA_MESSAGE.members["content"], self.content) + + serializer.write_string( + _SCHEMA_MESSAGE.members["contentType"], self.content_type + ) + if self.image_response_card is not None: + serializer.write_struct( + _SCHEMA_MESSAGE.members["imageResponseCard"], self.image_response_card + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["content"] = de.read_string( + _SCHEMA_MESSAGE.members["content"] + ) + + case 1: + kwargs["content_type"] = de.read_string( + _SCHEMA_MESSAGE.members["contentType"] + ) + + case 2: + kwargs["image_response_card"] = ImageResponseCard.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_MESSAGE, consumer=_consumer) + return kwargs + + +def _serialize_messages( + serializer: ShapeSerializer, schema: Schema, value: list[Message] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_messages( + deserializer: ShapeDeserializer, schema: Schema +) -> list[Message]: + result: list[Message] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(Message.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +class StyleType(StrEnum): + DEFAULT = "Default" + SPELL_BY_LETTER = "SpellByLetter" + SPELL_BY_WORD = "SpellByWord" + + +class DialogActionType(StrEnum): + CLOSE = "Close" + CONFIRM_INTENT = "ConfirmIntent" + DELEGATE = "Delegate" + ELICIT_INTENT = "ElicitIntent" + ELICIT_SLOT = "ElicitSlot" + NONE = "None" + + +@dataclass(kw_only=True) +class RuntimeHintValue: + """ + Provides the phrase that Amazon Lex V2 should look for in the user's + input to the bot. + """ + + phrase: str + """ + The phrase that Amazon Lex V2 should look for in the user's input to + the bot. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RUNTIME_HINT_VALUE, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_RUNTIME_HINT_VALUE.members["phrase"], self.phrase + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["phrase"] = de.read_string( + _SCHEMA_RUNTIME_HINT_VALUE.members["phrase"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RUNTIME_HINT_VALUE, consumer=_consumer) + return kwargs + + +def _serialize_runtime_hint_values_list( + serializer: ShapeSerializer, schema: Schema, value: list[RuntimeHintValue] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_runtime_hint_values_list( + deserializer: ShapeDeserializer, schema: Schema +) -> list[RuntimeHintValue]: + result: list[RuntimeHintValue] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(RuntimeHintValue.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +def _serialize_string_map( + serializer: ShapeSerializer, schema: Schema, value: dict[str, str] +) -> None: + with serializer.begin_map(schema, len(value)) as m: + value_schema = schema.members["value"] + for k, v in value.items(): + m.entry(k, lambda vs: vs.write_string(value_schema, v)) + + +def _deserialize_string_map( + deserializer: ShapeDeserializer, schema: Schema +) -> dict[str, str]: + result: dict[str, str] = {} + value_schema = schema.members["value"] + + def _read_value(k: str, d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result[k] = d.read_string(value_schema) + + deserializer.read_map(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class BadGatewayException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "server" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_BAD_GATEWAY_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_BAD_GATEWAY_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_BAD_GATEWAY_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_BAD_GATEWAY_EXCEPTION, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class DependencyFailedException(ServiceError): + """""" + + fault: Literal["client", "server"] | None = "client" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DEPENDENCY_FAILED_EXCEPTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION.members["message"], self.message + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["message"] = de.read_string( + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION.members["message"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct( + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION, consumer=_consumer + ) + return kwargs + + +@dataclass(kw_only=True) +class PutSessionOutput: + """Dataclass for PutSessionOutput structure.""" + + content_type: str | None = None + """ + The type of response. Same as the type specified in the + `responseContentType` field in the request. + """ + + messages: str | None = None + """ + A list of messages that were last sent to the user. The messages are + ordered based on how you return the messages from you Lambda function or + the order that the messages are defined in the bot. + """ + + session_state: str | None = None + """ + A base-64-encoded gzipped field that represents the current state of the + dialog between the user and the bot. Use this to determine the progress + of the conversation and what the next action may be. + """ + + request_attributes: str | None = None + """ + A base-64-encoded gzipped field that provides request-specific + information passed between the client application and Amazon Lex V2. + These are the same as the `requestAttribute` parameter in the call to + the `PutSession` operation. + """ + + session_id: str | None = None + """The identifier of the session that received the data.""" + + audio_stream: StreamingBlob = b"" + """ + If the requested content type was audio, the audio version of the + message to convey to the user. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_PUT_SESSION_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.content_type is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["contentType"], self.content_type + ) + + if self.messages is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["messages"], self.messages + ) + + if self.session_state is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["sessionState"], self.session_state + ) + + if self.request_attributes is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["requestAttributes"], + self.request_attributes, + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["sessionId"], self.session_id + ) + + serializer.write_data_stream( + _SCHEMA_PUT_SESSION_OUTPUT.members["audioStream"], self.audio_stream + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["content_type"] = de.read_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["contentType"] + ) + + case 1: + kwargs["messages"] = de.read_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["messages"] + ) + + case 2: + kwargs["session_state"] = de.read_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["sessionState"] + ) + + case 3: + kwargs["request_attributes"] = de.read_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["requestAttributes"] + ) + + case 4: + kwargs["session_id"] = de.read_string( + _SCHEMA_PUT_SESSION_OUTPUT.members["sessionId"] + ) + + case 5: + kwargs["audio_stream"] = de.read_data_stream( + _SCHEMA_PUT_SESSION_OUTPUT.members["audioStream"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_PUT_SESSION_OUTPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RecognizedBotMember: + """The bot member that processes the request.""" + + bot_id: str + """The identifier of the bot member that processes the request.""" + + bot_name: str | None = None + """The name of the bot member that processes the request.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RECOGNIZED_BOT_MEMBER, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_RECOGNIZED_BOT_MEMBER.members["botId"], self.bot_id + ) + if self.bot_name is not None: + serializer.write_string( + _SCHEMA_RECOGNIZED_BOT_MEMBER.members["botName"], self.bot_name + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_RECOGNIZED_BOT_MEMBER.members["botId"] + ) + + case 1: + kwargs["bot_name"] = de.read_string( + _SCHEMA_RECOGNIZED_BOT_MEMBER.members["botName"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RECOGNIZED_BOT_MEMBER, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RecognizeUtteranceInput: + """Dataclass for RecognizeUtteranceInput structure.""" + + bot_id: str | None = None + """The identifier of the bot that should receive the request.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that should receive the request.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the session in use.""" + + session_state: str | None = field(repr=False, default=None) + """ + Sets the state of the session with the user. You can use this to set the + current intent, attributes, context, and dialog action. Use the dialog + action to determine the next step that Amazon Lex V2 should use in the + conversation with the user. + + The `sessionState` field must be compressed using gzip and then base64 + encoded before sending to Amazon Lex V2. + """ + + request_attributes: str | None = field(repr=False, default=None) + """ + Request-specific information passed between the client application and + Amazon Lex V2 + + The namespace `x-amz-lex:` is reserved for special attributes. Don't + create any request attributes for prefix `x-amz-lex:`. + + The `requestAttributes` field must be compressed using gzip and then + base64 encoded before sending to Amazon Lex V2. + """ + + request_content_type: str | None = None + """ + Indicates the format for audio input or that the content is text. The + header must start with one of the following prefixes: + + - PCM format, audio data must be in little-endian byte order. + + - audio/l16; rate=16000; channels=1 + + - audio/x-l16; sample-rate=16000; channel-count=1 + + - audio/lpcm; sample-rate=8000; sample-size-bits=16; channel-count=1; + is-big-endian=false + + - Opus format + + - audio/x-cbr-opus-with-preamble;preamble-size=0;bit-rate=256000;frame-size-milliseconds=4 + + - Text format + + - text/plain; charset=utf-8 + """ + + response_content_type: str | None = None + """ + The message that Amazon Lex V2 returns in the response can be either + text or speech based on the `responseContentType` value. + + - If the value is `text/plain;charset=utf-8`, Amazon Lex V2 returns text + in the response. + + - If the value begins with `audio/`, Amazon Lex V2 returns speech in the + response. Amazon Lex V2 uses Amazon Polly to generate the speech using + the configuration that you specified in the `responseContentType` + parameter. For example, if you specify `audio/mpeg` as the value, + Amazon Lex V2 returns speech in the MPEG format. + + - If the value is `audio/pcm`, the speech returned is `audio/pcm` at 16 + KHz in 16-bit, little-endian format. + + - The following are the accepted values: + + - audio/mpeg + + - audio/ogg + + - audio/pcm (16 KHz) + + - audio/* (defaults to mpeg) + + - text/plain; charset=utf-8 + """ + + input_stream: StreamingBlob = b"" + """ + User input in PCM or Opus audio format or text format as described in + the `requestContentType` parameter. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RECOGNIZE_UTTERANCE_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["botAliasId"], + self.bot_alias_id, + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["sessionId"], self.session_id + ) + + if self.session_state is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["sessionState"], + self.session_state, + ) + + if self.request_attributes is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["requestAttributes"], + self.request_attributes, + ) + + if self.request_content_type is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["requestContentType"], + self.request_content_type, + ) + + if self.response_content_type is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["responseContentType"], + self.response_content_type, + ) + + if self.input_stream is not None: + serializer.write_data_stream( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["inputStream"], + self.input_stream, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["sessionId"] + ) + + case 4: + kwargs["session_state"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["sessionState"] + ) + + case 5: + kwargs["request_attributes"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["requestAttributes"] + ) + + case 6: + kwargs["request_content_type"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["requestContentType"] + ) + + case 7: + kwargs["response_content_type"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["responseContentType"] + ) + + case 8: + kwargs["input_stream"] = de.read_data_stream( + _SCHEMA_RECOGNIZE_UTTERANCE_INPUT.members["inputStream"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RECOGNIZE_UTTERANCE_INPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RecognizeUtteranceOutput: + """Dataclass for RecognizeUtteranceOutput structure.""" + + input_mode: str | None = None + """ + Indicates whether the input mode to the operation was text, speech, or + from a touch-tone keypad. + """ + + content_type: str | None = None + """Content type as specified in the `responseContentType` in the request.""" + + messages: str | None = None + """ + A list of messages that were last sent to the user. The messages are + ordered based on the order that you returned the messages from your + Lambda function or the order that the messages are defined in the bot. + + The `messages` field is compressed with gzip and then base64 encoded. + Before you can use the contents of the field, you must decode and + decompress the contents. See the example for a simple function to decode + and decompress the contents. + """ + + interpretations: str | None = None + """ + A list of intents that Amazon Lex V2 determined might satisfy the + user's utterance. + + Each interpretation includes the intent, a score that indicates how + confident Amazon Lex V2 is that the interpretation is the correct one, + and an optional sentiment response that indicates the sentiment + expressed in the utterance. + + The `interpretations` field is compressed with gzip and then base64 + encoded. Before you can use the contents of the field, you must decode + and decompress the contents. See the example for a simple function to + decode and decompress the contents. + """ + + session_state: str | None = None + """ + Represents the current state of the dialog between the user and the bot. + + Use this to determine the progress of the conversation and what the next + action might be. + + The `sessionState` field is compressed with gzip and then base64 + encoded. Before you can use the contents of the field, you must decode + and decompress the contents. See the example for a simple function to + decode and decompress the contents. + """ + + request_attributes: str | None = None + """ + The attributes sent in the request. + + The `requestAttributes` field is compressed with gzip and then base64 + encoded. Before you can use the contents of the field, you must decode + and decompress the contents. + """ + + session_id: str | None = None + """The identifier of the session in use.""" + + input_transcript: str | None = None + """ + The text used to process the request. + + If the input was an audio stream, the `inputTranscript` field contains + the text extracted from the audio stream. This is the text that is + actually processed to recognize intents and slot values. You can use + this information to determine if Amazon Lex V2 is correctly processing + the audio that you send. + + The `inputTranscript` field is compressed with gzip and then base64 + encoded. Before you can use the contents of the field, you must decode + and decompress the contents. See the example for a simple function to + decode and decompress the contents. + """ + + audio_stream: StreamingBlob = b"" + """ + The prompt or statement to send to the user. This is based on the bot + configuration and context. For example, if Amazon Lex V2 did not + understand the user intent, it sends the `clarificationPrompt` + configured for the bot. If the intent requires confirmation before + taking the fulfillment action, it sends the `confirmationPrompt`. + Another example: Suppose that the Lambda function successfully fulfilled + the intent, and sent a message to convey to the user. Then Amazon Lex V2 + sends that message in the response. + """ + + recognized_bot_member: str | None = None + """The bot member that recognized the utterance.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.input_mode is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["inputMode"], self.input_mode + ) + + if self.content_type is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["contentType"], + self.content_type, + ) + + if self.messages is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["messages"], self.messages + ) + + if self.interpretations is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["interpretations"], + self.interpretations, + ) + + if self.session_state is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["sessionState"], + self.session_state, + ) + + if self.request_attributes is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["requestAttributes"], + self.request_attributes, + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["sessionId"], self.session_id + ) + + if self.input_transcript is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["inputTranscript"], + self.input_transcript, + ) + + serializer.write_data_stream( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["audioStream"], self.audio_stream + ) + if self.recognized_bot_member is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["recognizedBotMember"], + self.recognized_bot_member, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["input_mode"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["inputMode"] + ) + + case 1: + kwargs["content_type"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["contentType"] + ) + + case 2: + kwargs["messages"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["messages"] + ) + + case 3: + kwargs["interpretations"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["interpretations"] + ) + + case 4: + kwargs["session_state"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["sessionState"] + ) + + case 5: + kwargs["request_attributes"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["requestAttributes"] + ) + + case 6: + kwargs["session_id"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["sessionId"] + ) + + case 7: + kwargs["input_transcript"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["inputTranscript"] + ) + + case 8: + kwargs["audio_stream"] = de.read_data_stream( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members["audioStream"] + ) + + case 9: + kwargs["recognized_bot_member"] = de.read_string( + _SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT.members[ + "recognizedBotMember" + ] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT, consumer=_consumer) + return kwargs + + +RECOGNIZE_UTTERANCE = APIOperation( + input=RecognizeUtteranceInput, + output=RecognizeUtteranceOutput, + schema=_SCHEMA_RECOGNIZE_UTTERANCE, + input_schema=_SCHEMA_RECOGNIZE_UTTERANCE_INPUT, + output_schema=_SCHEMA_RECOGNIZE_UTTERANCE_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID( + "com.amazonaws.lexruntimev2#BadGatewayException" + ): BadGatewayException, + ShapeID("com.amazonaws.lexruntimev2#ConflictException"): ConflictException, + ShapeID( + "com.amazonaws.lexruntimev2#DependencyFailedException" + ): DependencyFailedException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ResourceNotFoundException" + ): ResourceNotFoundException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_BAD_GATEWAY_EXCEPTION, + _SCHEMA_CONFLICT_EXCEPTION, + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) + + +class ConversationMode(StrEnum): + AUDIO = "AUDIO" + TEXT = "TEXT" + + +@dataclass(kw_only=True) +class DisconnectionEvent: + """ + A notification from the client that it is disconnecting from Amazon Lex + V2. Sending a `DisconnectionEvent` event is optional, but can help + identify a conversation in logs. + """ + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DISCONNECTION_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.event_id is not None: + serializer.write_string( + _SCHEMA_DISCONNECTION_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_DISCONNECTION_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["event_id"] = de.read_string( + _SCHEMA_DISCONNECTION_EVENT.members["eventId"] + ) + + case 1: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_DISCONNECTION_EVENT.members["clientTimestampMillis"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_DISCONNECTION_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class DTMFInputEvent: + """ + A DTMF character sent from the client application. DTMF characters are + typically sent from a phone keypad to represent numbers. For example, + you can have Amazon Lex V2 process a credit card number input from a + phone. + """ + + input_character: str = field(repr=False) + """ + The DTMF character that the user pressed. The allowed characters are A - + D, 0 - 9, # and *. + """ + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DTMF_INPUT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string( + _SCHEMA_DTMF_INPUT_EVENT.members["inputCharacter"], self.input_character + ) + if self.event_id is not None: + serializer.write_string( + _SCHEMA_DTMF_INPUT_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_DTMF_INPUT_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["input_character"] = de.read_string( + _SCHEMA_DTMF_INPUT_EVENT.members["inputCharacter"] + ) + + case 1: + kwargs["event_id"] = de.read_string( + _SCHEMA_DTMF_INPUT_EVENT.members["eventId"] + ) + + case 2: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_DTMF_INPUT_EVENT.members["clientTimestampMillis"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_DTMF_INPUT_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class PlaybackCompletionEvent: + """ + Event sent from the client application to Amazon Lex V2 to indicate that + playback of audio is complete and that Amazon Lex V2 should start + processing the user's input. + """ + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_PLAYBACK_COMPLETION_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.event_id is not None: + serializer.write_string( + _SCHEMA_PLAYBACK_COMPLETION_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_PLAYBACK_COMPLETION_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["event_id"] = de.read_string( + _SCHEMA_PLAYBACK_COMPLETION_EVENT.members["eventId"] + ) + + case 1: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_PLAYBACK_COMPLETION_EVENT.members[ + "clientTimestampMillis" + ] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_PLAYBACK_COMPLETION_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class TextInputEvent: + """ + The event sent from your client application to Amazon Lex V2 with text + input from the user. + """ + + text: str = field(repr=False) + """ + The text from the user. Amazon Lex V2 processes this as a complete + statement. + """ + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_TEXT_INPUT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_TEXT_INPUT_EVENT.members["text"], self.text) + if self.event_id is not None: + serializer.write_string( + _SCHEMA_TEXT_INPUT_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_TEXT_INPUT_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["text"] = de.read_string( + _SCHEMA_TEXT_INPUT_EVENT.members["text"] + ) + + case 1: + kwargs["event_id"] = de.read_string( + _SCHEMA_TEXT_INPUT_EVENT.members["eventId"] + ) + + case 2: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_TEXT_INPUT_EVENT.members["clientTimestampMillis"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_TEXT_INPUT_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class HeartbeatEvent: + """ + Event that Amazon Lex V2 sends to indicate that the stream is still open + between the client application and Amazon Lex V2 + """ + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_HEARTBEAT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.event_id is not None: + serializer.write_string( + _SCHEMA_HEARTBEAT_EVENT.members["eventId"], self.event_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["event_id"] = de.read_string( + _SCHEMA_HEARTBEAT_EVENT.members["eventId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_HEARTBEAT_EVENT, consumer=_consumer) + return kwargs + + +class InputMode(StrEnum): + TEXT = "Text" + SPEECH = "Speech" + DTMF = "DTMF" + + +class PlaybackInterruptionReason(StrEnum): + DTMF_START_DETECTED = "DTMF_START_DETECTED" + TEXT_DETECTED = "TEXT_DETECTED" + VOICE_START_DETECTED = "VOICE_START_DETECTED" + + +@dataclass(kw_only=True) +class PlaybackInterruptionEvent: + """ + Event sent from Amazon Lex V2 to indicate to the client application + should stop playback of audio. For example, if the client is playing a + prompt that asks for the user's telephone number, the user might start + to say the phone number before the prompt is complete. Amazon Lex V2 + sends this event to the client application to indicate that the user is + responding and that Amazon Lex V2 is processing their input. + """ + + event_reason: str | None = None + """Indicates the type of user input that Amazon Lex V2 detected.""" + + caused_by_event_id: str | None = None + """ + The identifier of the event that contained the audio, DTMF, or text that + caused the interruption. + """ + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_PLAYBACK_INTERRUPTION_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.event_reason is not None: + serializer.write_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["eventReason"], + self.event_reason, + ) + + if self.caused_by_event_id is not None: + serializer.write_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["causedByEventId"], + self.caused_by_event_id, + ) + + if self.event_id is not None: + serializer.write_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["eventId"], self.event_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["event_reason"] = de.read_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["eventReason"] + ) + + case 1: + kwargs["caused_by_event_id"] = de.read_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["causedByEventId"] + ) + + case 2: + kwargs["event_id"] = de.read_string( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT.members["eventId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct( + _SCHEMA_PLAYBACK_INTERRUPTION_EVENT, consumer=_consumer + ) + return kwargs + + +@dataclass(kw_only=True) +class TextResponseEvent: + """ + The event sent from Amazon Lex V2 to your application with text to + present to the user. + """ + + messages: list[Message] | None = None + """ + A list of messages to send to the user. Messages are ordered based on + the order that you returned the messages from your Lambda function or + the order that the messages are defined in the bot. + """ + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_TEXT_RESPONSE_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.messages is not None: + _serialize_messages( + serializer, + _SCHEMA_TEXT_RESPONSE_EVENT.members["messages"], + self.messages, + ) + + if self.event_id is not None: + serializer.write_string( + _SCHEMA_TEXT_RESPONSE_EVENT.members["eventId"], self.event_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["messages"] = _deserialize_messages( + de, _SCHEMA_TEXT_RESPONSE_EVENT.members["messages"] + ) + + case 1: + kwargs["event_id"] = de.read_string( + _SCHEMA_TEXT_RESPONSE_EVENT.members["eventId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_TEXT_RESPONSE_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class TranscriptEvent: + """ + Event sent from Amazon Lex V2 to your client application that contains a + transcript of voice audio. + """ + + transcript: str | None = None + """The transcript of the voice audio from the user.""" + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_TRANSCRIPT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.transcript is not None: + serializer.write_string( + _SCHEMA_TRANSCRIPT_EVENT.members["transcript"], self.transcript + ) + + if self.event_id is not None: + serializer.write_string( + _SCHEMA_TRANSCRIPT_EVENT.members["eventId"], self.event_id + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["transcript"] = de.read_string( + _SCHEMA_TRANSCRIPT_EVENT.members["transcript"] + ) + + case 1: + kwargs["event_id"] = de.read_string( + _SCHEMA_TRANSCRIPT_EVENT.members["eventId"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_TRANSCRIPT_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class ElicitSubSlot: + """ + The specific constituent sub slot of the composite slot to elicit in + dialog action. + """ + + name: str + """The name of the slot that should be elicited from the user.""" + + sub_slot_to_elicit: "ElicitSubSlot | None" = None + """The field is not supported.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_ELICIT_SUB_SLOT, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_ELICIT_SUB_SLOT.members["name"], self.name) + if self.sub_slot_to_elicit is not None: + serializer.write_struct( + _SCHEMA_ELICIT_SUB_SLOT.members["subSlotToElicit"], + self.sub_slot_to_elicit, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["name"] = de.read_string( + _SCHEMA_ELICIT_SUB_SLOT.members["name"] + ) + + case 1: + kwargs["sub_slot_to_elicit"] = ElicitSubSlot.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_ELICIT_SUB_SLOT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class DialogAction: + """The next action that Amazon Lex V2 should take.""" + + type: str + """ + The next action that the bot should take in its interaction with the + user. The following values are possible: + + - `Close` -- Indicates that there will not be a response from the user. + For example, the statement \"Your order has been placed\" does not + require a response. + + - `ConfirmIntent` -- The next action is asking the user if the intent is + complete and ready to be fulfilled. This is a yes/no question such as + \"Place the order?\" + + - `Delegate` -- The next action is determined by Amazon Lex V2. + + - `ElicitIntent` -- The next action is to elicit an intent from the + user. + + - `ElicitSlot` -- The next action is to elicit a slot value from the + user. + """ + + slot_to_elicit: str | None = None + """The name of the slot that should be elicited from the user.""" + + slot_elicitation_style: str | None = None + """ + Configures the slot to use spell-by-letter or spell-by-word style. When + you use a style on a slot, users can spell out their input to make it + clear to your bot. + + - Spell by letter - \"b\" \"o\" \"b\" + + - Spell by word - \"b as in boy\" \"o as in oscar\" \"b as in boy\" + + For more information, see [Using spelling to enter slot + values](https://docs.aws.amazon.com/lexv2/latest/dg/spelling-styles.html) + . + """ + + sub_slot_to_elicit: "ElicitSubSlot | None" = None + """ + The name of the constituent sub slot of the composite slot specified in + slotToElicit that should be elicited from the user. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_DIALOG_ACTION, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_DIALOG_ACTION.members["type"], self.type) + if self.slot_to_elicit is not None: + serializer.write_string( + _SCHEMA_DIALOG_ACTION.members["slotToElicit"], self.slot_to_elicit + ) + + if self.slot_elicitation_style is not None: + serializer.write_string( + _SCHEMA_DIALOG_ACTION.members["slotElicitationStyle"], + self.slot_elicitation_style, + ) + + if self.sub_slot_to_elicit is not None: + serializer.write_struct( + _SCHEMA_DIALOG_ACTION.members["subSlotToElicit"], + self.sub_slot_to_elicit, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["type"] = de.read_string( + _SCHEMA_DIALOG_ACTION.members["type"] + ) + + case 1: + kwargs["slot_to_elicit"] = de.read_string( + _SCHEMA_DIALOG_ACTION.members["slotToElicit"] + ) + + case 2: + kwargs["slot_elicitation_style"] = de.read_string( + _SCHEMA_DIALOG_ACTION.members["slotElicitationStyle"] + ) + + case 3: + kwargs["sub_slot_to_elicit"] = ElicitSubSlot.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_DIALOG_ACTION, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RuntimeHintDetails: + """ + Provides an array of phrases that should be given preference when + resolving values for a slot. + """ + + runtime_hint_values: list[RuntimeHintValue] | None = None + """ + One or more strings that Amazon Lex V2 should look for in the input to + the bot. Each phrase is given preference when deciding on slot values. + """ + + sub_slot_hints: "dict[str, RuntimeHintDetails] | None" = None + """ + A map of constituent sub slot names inside a composite slot in the + intent and the phrases that should be added for each sub slot. Inside + each composite slot hints, this structure provides a mechanism to add + granular sub slot phrases. Only sub slot hints are supported for + composite slots. The intent name, composite slot name and the + constituent sub slot names must exist. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RUNTIME_HINT_DETAILS, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.runtime_hint_values is not None: + _serialize_runtime_hint_values_list( + serializer, + _SCHEMA_RUNTIME_HINT_DETAILS.members["runtimeHintValues"], + self.runtime_hint_values, + ) + + if self.sub_slot_hints is not None: + _serialize_slot_hints_slot_map( + serializer, + _SCHEMA_RUNTIME_HINT_DETAILS.members["subSlotHints"], + self.sub_slot_hints, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["runtime_hint_values"] = ( + _deserialize_runtime_hint_values_list( + de, + _SCHEMA_RUNTIME_HINT_DETAILS.members["runtimeHintValues"], + ) + ) + + case 1: + kwargs["sub_slot_hints"] = _deserialize_slot_hints_slot_map( + de, _SCHEMA_RUNTIME_HINT_DETAILS.members["subSlotHints"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RUNTIME_HINT_DETAILS, consumer=_consumer) + return kwargs + + +def _serialize_slot_hints_slot_map( + serializer: ShapeSerializer, schema: Schema, value: dict[str, RuntimeHintDetails] +) -> None: + with serializer.begin_map(schema, len(value)) as m: + value_schema = schema.members["value"] + for k, v in value.items(): + m.entry(k, lambda vs: vs.write_struct(value_schema, v)) + + +def _deserialize_slot_hints_slot_map( + deserializer: ShapeDeserializer, schema: Schema +) -> dict[str, RuntimeHintDetails]: + result: dict[str, RuntimeHintDetails] = {} + value_schema = schema.members["value"] + + def _read_value(k: str, d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result[k] = RuntimeHintDetails.deserialize(d) + + deserializer.read_map(schema, _read_value) + return result + + +def _serialize_slot_hints_intent_map( + serializer: ShapeSerializer, + schema: Schema, + value: dict[str, dict[str, RuntimeHintDetails]], +) -> None: + with serializer.begin_map(schema, len(value)) as m: + value_schema = schema.members["value"] + for k, v in value.items(): + m.entry(k, lambda vs: _serialize_slot_hints_slot_map(vs, value_schema, v)) + + +def _deserialize_slot_hints_intent_map( + deserializer: ShapeDeserializer, schema: Schema +) -> dict[str, dict[str, RuntimeHintDetails]]: + result: dict[str, dict[str, RuntimeHintDetails]] = {} + value_schema = schema.members["value"] + + def _read_value(k: str, d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result[k] = _deserialize_slot_hints_slot_map(d, value_schema) + + deserializer.read_map(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class RuntimeHints: + """ + You can provide Amazon Lex V2 with hints to the phrases that a customer + is likely to use for a slot. When a slot with hints is resolved, the + phrases in the runtime hints are preferred in the resolution. You can + provide hints for a maximum of 100 intents. You can provide a maximum of + 100 slots. + + Before you can use runtime hints with an existing bot, you must first + rebuild the bot. + + For more information, see [Using runtime hints to improve recognition of + slot + values](https://docs.aws.amazon.com/lexv2/latest/dg/using-hints.html). + """ + + slot_hints: "dict[str, dict[str, RuntimeHintDetails]] | None" = None + """ + A list of the slots in the intent that should have runtime hints added, + and the phrases that should be added for each slot. + + The first level of the `slotHints` map is the name of the intent. The + second level is the name of the slot within the intent. For more + information, see [Using hints to improve + accuracy](https://docs.aws.amazon.com/lexv2/latest/dg/using-hints.html). + + The intent name and slot name must exist. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RUNTIME_HINTS, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.slot_hints is not None: + _serialize_slot_hints_intent_map( + serializer, _SCHEMA_RUNTIME_HINTS.members["slotHints"], self.slot_hints + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["slot_hints"] = _deserialize_slot_hints_intent_map( + de, _SCHEMA_RUNTIME_HINTS.members["slotHints"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RUNTIME_HINTS, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class Slot: + """A value that Amazon Lex V2 uses to fulfill an intent.""" + + value: Value | None = None + """The current value of the slot.""" + + shape: str | None = None + """ + When the `shape` value is `List`, it indicates that the `values` field + contains a list of slot values. When the value is `Scalar`, it indicates + that the `value` field contains a single value. + """ + + values: "list[Slot] | None" = None + """ + A list of one or more values that the user provided for the slot. For + example, if a for a slot that elicits pizza toppings, the values might + be \"pepperoni\" and \"pineapple.\" + """ + + sub_slots: "dict[str, Slot] | None" = None + """The constituent sub slots of a composite slot.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_SLOT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.value is not None: + serializer.write_struct(_SCHEMA_SLOT.members["value"], self.value) + + if self.shape is not None: + serializer.write_string(_SCHEMA_SLOT.members["shape"], self.shape) + + if self.values is not None: + _serialize_values(serializer, _SCHEMA_SLOT.members["values"], self.values) + + if self.sub_slots is not None: + _serialize_slots( + serializer, _SCHEMA_SLOT.members["subSlots"], self.sub_slots + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["value"] = Value.deserialize(de) + + case 1: + kwargs["shape"] = de.read_string(_SCHEMA_SLOT.members["shape"]) + + case 2: + kwargs["values"] = _deserialize_values( + de, _SCHEMA_SLOT.members["values"] + ) + + case 3: + kwargs["sub_slots"] = _deserialize_slots( + de, _SCHEMA_SLOT.members["subSlots"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_SLOT, consumer=_consumer) + return kwargs + + +def _serialize_slots( + serializer: ShapeSerializer, schema: Schema, value: dict[str, Slot] +) -> None: + with serializer.begin_map(schema, len(value)) as m: + value_schema = schema.members["value"] + for k, v in value.items(): + m.entry(k, lambda vs: vs.write_struct(value_schema, v)) + + +def _deserialize_slots( + deserializer: ShapeDeserializer, schema: Schema +) -> dict[str, Slot]: + result: dict[str, Slot] = {} + value_schema = schema.members["value"] + + def _read_value(k: str, d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result[k] = Slot.deserialize(d) + + deserializer.read_map(schema, _read_value) + return result + + +def _serialize_values( + serializer: ShapeSerializer, schema: Schema, value: list[Slot] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_values(deserializer: ShapeDeserializer, schema: Schema) -> list[Slot]: + result: list[Slot] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(Slot.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class Intent: + """The current intent that Amazon Lex V2 is attempting to fulfill.""" + + name: str + """The name of the intent.""" + + slots: "dict[str, Slot] | None" = None + """ + A map of all of the slots for the intent. The name of the slot maps to + the value of the slot. If a slot has not been filled, the value is null. + """ + + state: str | None = None + """ + Indicates the fulfillment state for the intent. The meanings of each + value are as follows: + + - `Failed` -- The bot failed to fulfill the intent. + + - `Fulfilled` -- The bot has completed fulfillment of the intent. + + - `FulfillmentInProgress` -- The bot is in the middle of fulfilling the + intent. + + - `InProgress` -- The bot is in the middle of eliciting the slot values + that are necessary to fulfill the intent. + + - `ReadyForFulfillment` -- The bot has elicited all the slot values for + the intent and is ready to fulfill the intent. + + - `Waiting` -- The bot is waiting for a response from the user (limited + to streaming conversations). + """ + + confirmation_state: str | None = None + """ + Indicates whether the intent has been `Confirmed`, `Denied`, or `None` + if the confirmation stage has not yet been reached. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_INTENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_string(_SCHEMA_INTENT.members["name"], self.name) + if self.slots is not None: + _serialize_slots(serializer, _SCHEMA_INTENT.members["slots"], self.slots) + + if self.state is not None: + serializer.write_string(_SCHEMA_INTENT.members["state"], self.state) + + if self.confirmation_state is not None: + serializer.write_string( + _SCHEMA_INTENT.members["confirmationState"], self.confirmation_state + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["name"] = de.read_string(_SCHEMA_INTENT.members["name"]) + + case 1: + kwargs["slots"] = _deserialize_slots( + de, _SCHEMA_INTENT.members["slots"] + ) + + case 2: + kwargs["state"] = de.read_string(_SCHEMA_INTENT.members["state"]) + + case 3: + kwargs["confirmation_state"] = de.read_string( + _SCHEMA_INTENT.members["confirmationState"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_INTENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class Interpretation: + """ + An object containing information about an intent that Amazon Lex V2 + determined might satisfy the user's utterance. The intents are ordered + by the confidence score. + """ + + nlu_confidence: ConfidenceScore | None = None + """ + Determines the threshold where Amazon Lex V2 will insert the + `AMAZON.FallbackIntent`, `AMAZON.KendraSearchIntent`, or both when + returning alternative intents in a response. `AMAZON.FallbackIntent` and + `AMAZON.KendraSearchIntent` are only inserted if they are configured for + the bot. + """ + + sentiment_response: SentimentResponse | None = None + """ + The sentiment expressed in an utterance. + + When the bot is configured to send utterances to Amazon Comprehend for + sentiment analysis, this field contains the result of the analysis. + """ + + intent: "Intent | None" = None + """ + A list of intents that might satisfy the user's utterance. The intents + are ordered by the confidence score. + """ + + interpretation_source: str | None = None + """Specifies the service that interpreted the input.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_INTERPRETATION, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.nlu_confidence is not None: + serializer.write_struct( + _SCHEMA_INTERPRETATION.members["nluConfidence"], self.nlu_confidence + ) + + if self.sentiment_response is not None: + serializer.write_struct( + _SCHEMA_INTERPRETATION.members["sentimentResponse"], + self.sentiment_response, + ) + + if self.intent is not None: + serializer.write_struct( + _SCHEMA_INTERPRETATION.members["intent"], self.intent + ) + + if self.interpretation_source is not None: + serializer.write_string( + _SCHEMA_INTERPRETATION.members["interpretationSource"], + self.interpretation_source, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["nlu_confidence"] = ConfidenceScore.deserialize(de) + + case 1: + kwargs["sentiment_response"] = SentimentResponse.deserialize(de) + + case 2: + kwargs["intent"] = Intent.deserialize(de) + + case 3: + kwargs["interpretation_source"] = de.read_string( + _SCHEMA_INTERPRETATION.members["interpretationSource"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_INTERPRETATION, consumer=_consumer) + return kwargs + + +def _serialize_interpretations( + serializer: ShapeSerializer, schema: Schema, value: list[Interpretation] +) -> None: + member_schema = schema.members["member"] + with serializer.begin_list(schema, len(value)) as ls: + for e in value: + ls.write_struct(member_schema, e) + + +def _deserialize_interpretations( + deserializer: ShapeDeserializer, schema: Schema +) -> list[Interpretation]: + result: list[Interpretation] = [] + + def _read_value(d: ShapeDeserializer): + if d.is_null(): + d.read_null() + + else: + result.append(Interpretation.deserialize(d)) + + deserializer.read_list(schema, _read_value) + return result + + +@dataclass(kw_only=True) +class SessionState: + """The state of the user's session with Amazon Lex V2.""" + + dialog_action: "DialogAction | None" = None + """ + The next step that Amazon Lex V2 should take in the conversation with a + user. + """ + + intent: "Intent | None" = None + """The active intent that Amazon Lex V2 is processing.""" + + active_contexts: list[ActiveContext] | None = None + """ + One or more contexts that indicate to Amazon Lex V2 the context of a + request. When a context is active, Amazon Lex V2 considers intents with + the matching context as a trigger as the next intent in a session. + """ + + session_attributes: dict[str, str] | None = None + """ + Map of key/value pairs representing session-specific context + information. It contains application information passed between Amazon + Lex V2 and a client application. + """ + + originating_request_id: str | None = None + """A unique identifier for a specific request.""" + + runtime_hints: "RuntimeHints | None" = None + """ + Hints for phrases that a customer is likely to use for a slot. Amazon + Lex V2 uses the hints to help determine the correct value of a slot. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_SESSION_STATE, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.dialog_action is not None: + serializer.write_struct( + _SCHEMA_SESSION_STATE.members["dialogAction"], self.dialog_action + ) + + if self.intent is not None: + serializer.write_struct( + _SCHEMA_SESSION_STATE.members["intent"], self.intent + ) + + if self.active_contexts is not None: + _serialize_active_contexts_list( + serializer, + _SCHEMA_SESSION_STATE.members["activeContexts"], + self.active_contexts, + ) + + if self.session_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_SESSION_STATE.members["sessionAttributes"], + self.session_attributes, + ) + + if self.originating_request_id is not None: + serializer.write_string( + _SCHEMA_SESSION_STATE.members["originatingRequestId"], + self.originating_request_id, + ) + + if self.runtime_hints is not None: + serializer.write_struct( + _SCHEMA_SESSION_STATE.members["runtimeHints"], self.runtime_hints + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["dialog_action"] = DialogAction.deserialize(de) + + case 1: + kwargs["intent"] = Intent.deserialize(de) + + case 2: + kwargs["active_contexts"] = _deserialize_active_contexts_list( + de, _SCHEMA_SESSION_STATE.members["activeContexts"] + ) + + case 3: + kwargs["session_attributes"] = _deserialize_string_map( + de, _SCHEMA_SESSION_STATE.members["sessionAttributes"] + ) + + case 4: + kwargs["originating_request_id"] = de.read_string( + _SCHEMA_SESSION_STATE.members["originatingRequestId"] + ) + + case 5: + kwargs["runtime_hints"] = RuntimeHints.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_SESSION_STATE, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class ConfigurationEvent: + """ + The initial event sent from the application to Amazon Lex V2 to + configure the conversation, including session and request attributes and + the response content type. + """ + + response_content_type: str + """ + The message that Amazon Lex V2 returns in the response can be either + text or speech based on the `responseContentType` value. + + - If the value is `text/plain;charset=utf-8`, Amazon Lex V2 returns text + in the response. + + - If the value begins with `audio/`, Amazon Lex V2 returns speech in the + response. Amazon Lex V2 uses Amazon Polly to generate the speech using + the configuration that you specified in the `requestContentType` + parameter. For example, if you specify `audio/mpeg` as the value, + Amazon Lex V2 returns speech in the MPEG format. + + - If the value is `audio/pcm`, the speech returned is audio/pcm in + 16-bit, little-endian format. + + - The following are the accepted values: + + - audio/mpeg + + - audio/ogg + + - audio/pcm + + - audio/* (defaults to mpeg) + + - text/plain; charset=utf-8 + """ + + request_attributes: dict[str, str] | None = None + """ + Request-specific information passed between the client application and + Amazon Lex V2. + + The namespace `x-amz-lex:` is reserved for special attributes. Don't + create any request attributes for prefix `x-amz-lex:`. + """ + + session_state: "SessionState | None" = None + """The state of the user's session with Amazon Lex V2.""" + + welcome_messages: list[Message] | None = None + """ + A list of messages to send to the user. + + If you set the `welcomeMessage` field, you must also set the + [`DialogAction`](https://docs.aws.amazon.com/lexv2/latest/dg/API_runtime_DialogAction.html) + structure's + [`type`](https://docs.aws.amazon.com/lexv2/latest/dg/API_runtime_DialogAction.html#lexv2-Type-runtime_DialogAction-type) + field. + """ + + disable_playback: bool = False + """ + Determines whether Amazon Lex V2 should send audio responses to the + client application. + + Set this field to false when the client is operating in a playback mode + where audio responses are played to the user. If the client isn't + operating in playback mode, such as a text chat application, set this to + true so that Amazon Lex V2 doesn't wait for the prompt to finish + playing on the client. + """ + + event_id: str | None = None + """ + A unique identifier that your application assigns to the event. You can + use this to identify events in logs. + """ + + client_timestamp_millis: int = 0 + """ + A timestamp set by the client of the date and time that the event was + sent to Amazon Lex V2. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_CONFIGURATION_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.request_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_CONFIGURATION_EVENT.members["requestAttributes"], + self.request_attributes, + ) + + serializer.write_string( + _SCHEMA_CONFIGURATION_EVENT.members["responseContentType"], + self.response_content_type, + ) + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_CONFIGURATION_EVENT.members["sessionState"], self.session_state + ) + + if self.welcome_messages is not None: + _serialize_messages( + serializer, + _SCHEMA_CONFIGURATION_EVENT.members["welcomeMessages"], + self.welcome_messages, + ) + + serializer.write_boolean( + _SCHEMA_CONFIGURATION_EVENT.members["disablePlayback"], + self.disable_playback, + ) + if self.event_id is not None: + serializer.write_string( + _SCHEMA_CONFIGURATION_EVENT.members["eventId"], self.event_id + ) + + serializer.write_long( + _SCHEMA_CONFIGURATION_EVENT.members["clientTimestampMillis"], + self.client_timestamp_millis, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["request_attributes"] = _deserialize_string_map( + de, _SCHEMA_CONFIGURATION_EVENT.members["requestAttributes"] + ) + + case 1: + kwargs["response_content_type"] = de.read_string( + _SCHEMA_CONFIGURATION_EVENT.members["responseContentType"] + ) + + case 2: + kwargs["session_state"] = SessionState.deserialize(de) + + case 3: + kwargs["welcome_messages"] = _deserialize_messages( + de, _SCHEMA_CONFIGURATION_EVENT.members["welcomeMessages"] + ) + + case 4: + kwargs["disable_playback"] = de.read_boolean( + _SCHEMA_CONFIGURATION_EVENT.members["disablePlayback"] + ) + + case 5: + kwargs["event_id"] = de.read_string( + _SCHEMA_CONFIGURATION_EVENT.members["eventId"] + ) + + case 6: + kwargs["client_timestamp_millis"] = de.read_long( + _SCHEMA_CONFIGURATION_EVENT.members["clientTimestampMillis"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_CONFIGURATION_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class PutSessionInput: + """Dataclass for PutSessionInput structure.""" + + bot_id: str | None = None + """The identifier of the bot that receives the session data.""" + + bot_alias_id: str | None = None + """The alias identifier of the bot that receives the session data.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the session that receives the session data.""" + + messages: list[Message] | None = None + """ + A list of messages to send to the user. Messages are sent in the order + that they are defined in the list. + """ + + session_state: "SessionState | None" = None + """ + Sets the state of the session with the user. You can use this to set the + current intent, attributes, context, and dialog action. Use the dialog + action to determine the next step that Amazon Lex V2 should use in the + conversation with the user. + """ + + request_attributes: dict[str, str] | None = None + """ + Request-specific information passed between Amazon Lex V2 and the client + application. + + The namespace `x-amz-lex:` is reserved for special attributes. Don't + create any request attributes with the prefix `x-amz-lex:`. + """ + + response_content_type: str | None = None + """ + The message that Amazon Lex V2 returns in the response can be either + text or speech depending on the value of this parameter. + + - If the value is `text/plain; charset=utf-8`, Amazon Lex V2 returns + text in the response. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_PUT_SESSION_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_INPUT.members["botAliasId"], self.bot_alias_id + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_INPUT.members["sessionId"], self.session_id + ) + + if self.messages is not None: + _serialize_messages( + serializer, _SCHEMA_PUT_SESSION_INPUT.members["messages"], self.messages + ) + + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_PUT_SESSION_INPUT.members["sessionState"], self.session_state + ) + + if self.request_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_PUT_SESSION_INPUT.members["requestAttributes"], + self.request_attributes, + ) + + if self.response_content_type is not None: + serializer.write_string( + _SCHEMA_PUT_SESSION_INPUT.members["responseContentType"], + self.response_content_type, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_PUT_SESSION_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_PUT_SESSION_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_PUT_SESSION_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_PUT_SESSION_INPUT.members["sessionId"] + ) + + case 4: + kwargs["messages"] = _deserialize_messages( + de, _SCHEMA_PUT_SESSION_INPUT.members["messages"] + ) + + case 5: + kwargs["session_state"] = SessionState.deserialize(de) + + case 6: + kwargs["request_attributes"] = _deserialize_string_map( + de, _SCHEMA_PUT_SESSION_INPUT.members["requestAttributes"] + ) + + case 7: + kwargs["response_content_type"] = de.read_string( + _SCHEMA_PUT_SESSION_INPUT.members["responseContentType"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_PUT_SESSION_INPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RecognizeTextInput: + """Dataclass for RecognizeTextInput structure.""" + + bot_id: str | None = None + """The identifier of the bot that processes the request.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that processes the request.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the user session that is having the conversation.""" + + text: str | None = field(repr=False, default=None) + """The text that the user entered. Amazon Lex V2 interprets this text.""" + + session_state: "SessionState | None" = None + """The current state of the dialog between the user and the bot.""" + + request_attributes: dict[str, str] | None = None + """ + Request-specific information passed between the client application and + Amazon Lex V2 + + The namespace `x-amz-lex:` is reserved for special attributes. Don't + create any request attributes with the prefix `x-amz-lex:`. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RECOGNIZE_TEXT_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["botAliasId"], self.bot_alias_id + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["sessionId"], self.session_id + ) + + if self.text is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["text"], self.text + ) + + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["sessionState"], self.session_state + ) + + if self.request_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["requestAttributes"], + self.request_attributes, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["sessionId"] + ) + + case 4: + kwargs["text"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_INPUT.members["text"] + ) + + case 5: + kwargs["session_state"] = SessionState.deserialize(de) + + case 6: + kwargs["request_attributes"] = _deserialize_string_map( + de, _SCHEMA_RECOGNIZE_TEXT_INPUT.members["requestAttributes"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RECOGNIZE_TEXT_INPUT, consumer=_consumer) + return kwargs + + +PUT_SESSION = APIOperation( + input=PutSessionInput, + output=PutSessionOutput, + schema=_SCHEMA_PUT_SESSION, + input_schema=_SCHEMA_PUT_SESSION_INPUT, + output_schema=_SCHEMA_PUT_SESSION_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID( + "com.amazonaws.lexruntimev2#BadGatewayException" + ): BadGatewayException, + ShapeID("com.amazonaws.lexruntimev2#ConflictException"): ConflictException, + ShapeID( + "com.amazonaws.lexruntimev2#DependencyFailedException" + ): DependencyFailedException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ResourceNotFoundException" + ): ResourceNotFoundException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_BAD_GATEWAY_EXCEPTION, + _SCHEMA_CONFLICT_EXCEPTION, + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) + + +@dataclass +class StartConversationRequestEventStreamConfigurationEvent: + """ + Configuration information sent from your client application to Amazon + Lex V2 + """ + + value: ConfigurationEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members[ + "ConfigurationEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=ConfigurationEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamAudioInputEvent: + """ + Speech audio sent from your client application to Amazon Lex V2. Audio + starts accumulating when Amazon Lex V2 identifies a voice and continues + until a natural pause in the speech is found before processing. + """ + + value: AudioInputEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members["AudioInputEvent"], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=AudioInputEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamDTMFInputEvent: + """ + DTMF information sent to Amazon Lex V2 by your application. Amazon Lex + V2 accumulates the DMTF information from when the user sends the first + character and ends + + - when there's a pause longer that the value configured for the end + timeout. + + - when there's a digit that is the configured end character. + + - when Amazon Lex V2 accumulates characters equal to the maximum DTMF + character configuration. + """ + + value: DTMFInputEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members["DTMFInputEvent"], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=DTMFInputEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamTextInputEvent: + """ + Text sent from your client application to Amazon Lex V2. Each + `TextInputEvent` is processed individually. + """ + + value: TextInputEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members["TextInputEvent"], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=TextInputEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamPlaybackCompletionEvent: + """ + Event sent from the client application to Amazon Lex V2 to indicate that + it has finished playing audio and that Amazon Lex V2 should start + listening for user input. + """ + + value: PlaybackCompletionEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members[ + "PlaybackCompletionEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=PlaybackCompletionEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamDisconnectionEvent: + """ + Event sent from the client application to indicate to Amazon Lex V2 that + the conversation is over. + """ + + value: DisconnectionEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM.members[ + "DisconnectionEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=DisconnectionEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationRequestEventStreamUnknown: + """ + Represents an unknown variant. + + If you receive this value, you will need to update your library to receive the + parsed value. + + This value may not be deliberately sent. + """ + + tag: str + + def serialize(self, serializer: ShapeSerializer): + raise SerializationError("Unknown union variants may not be serialized.") + + def serialize_members(self, serializer: ShapeSerializer): + raise SerializationError("Unknown union variants may not be serialized.") + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + raise NotImplementedError() + + +StartConversationRequestEventStream = Union[ + StartConversationRequestEventStreamConfigurationEvent + | StartConversationRequestEventStreamAudioInputEvent + | StartConversationRequestEventStreamDTMFInputEvent + | StartConversationRequestEventStreamTextInputEvent + | StartConversationRequestEventStreamPlaybackCompletionEvent + | StartConversationRequestEventStreamDisconnectionEvent + | StartConversationRequestEventStreamUnknown +] +""" +Represents a stream of events between your application and Amazon Lex +V2. +""" + + +class _StartConversationRequestEventStreamDeserializer: + _result: StartConversationRequestEventStream | None = None + + def deserialize( + self, deserializer: ShapeDeserializer + ) -> StartConversationRequestEventStream: + self._result = None + deserializer.read_struct( + _SCHEMA_START_CONVERSATION_REQUEST_EVENT_STREAM, self._consumer + ) + + if self._result is None: + raise SerializationError( + "Unions must have exactly one value, but found none." + ) + + return self._result + + def _consumer(self, schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + self._set_result( + StartConversationRequestEventStreamConfigurationEvent.deserialize( + de + ) + ) + + case 1: + self._set_result( + StartConversationRequestEventStreamAudioInputEvent.deserialize(de) + ) + + case 2: + self._set_result( + StartConversationRequestEventStreamDTMFInputEvent.deserialize(de) + ) + + case 3: + self._set_result( + StartConversationRequestEventStreamTextInputEvent.deserialize(de) + ) + + case 4: + self._set_result( + StartConversationRequestEventStreamPlaybackCompletionEvent.deserialize( + de + ) + ) + + case 5: + self._set_result( + StartConversationRequestEventStreamDisconnectionEvent.deserialize( + de + ) + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + def _set_result(self, value: StartConversationRequestEventStream) -> None: + if self._result is not None: + raise SerializationError( + "Unions must have exactly one value, but found more than one." + ) + self._result = value + + +@dataclass(kw_only=True) +class StartConversationInput: + """Dataclass for StartConversationInput structure.""" + + bot_id: str | None = None + """The identifier of the bot to process the request.""" + + bot_alias_id: str | None = None + """The alias identifier in use for the bot that processes the request.""" + + locale_id: str | None = None + """The locale where the session is in use.""" + + session_id: str | None = None + """The identifier of the user session that is having the conversation.""" + + conversation_mode: str | None = None + """ + The conversation type that you are using the Amazon Lex V2. If the + conversation mode is `AUDIO` you can send both audio and DTMF + information. If the mode is `TEXT` you can only send text. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_INPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.bot_id is not None: + serializer.write_string( + _SCHEMA_START_CONVERSATION_INPUT.members["botId"], self.bot_id + ) + + if self.bot_alias_id is not None: + serializer.write_string( + _SCHEMA_START_CONVERSATION_INPUT.members["botAliasId"], + self.bot_alias_id, + ) + + if self.locale_id is not None: + serializer.write_string( + _SCHEMA_START_CONVERSATION_INPUT.members["localeId"], self.locale_id + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_START_CONVERSATION_INPUT.members["sessionId"], self.session_id + ) + + if self.conversation_mode is not None: + serializer.write_string( + _SCHEMA_START_CONVERSATION_INPUT.members["conversationMode"], + self.conversation_mode, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["bot_id"] = de.read_string( + _SCHEMA_START_CONVERSATION_INPUT.members["botId"] + ) + + case 1: + kwargs["bot_alias_id"] = de.read_string( + _SCHEMA_START_CONVERSATION_INPUT.members["botAliasId"] + ) + + case 2: + kwargs["locale_id"] = de.read_string( + _SCHEMA_START_CONVERSATION_INPUT.members["localeId"] + ) + + case 3: + kwargs["session_id"] = de.read_string( + _SCHEMA_START_CONVERSATION_INPUT.members["sessionId"] + ) + + case 4: + kwargs["conversation_mode"] = de.read_string( + _SCHEMA_START_CONVERSATION_INPUT.members["conversationMode"] + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_START_CONVERSATION_INPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class GetSessionOutput: + """Dataclass for GetSessionOutput structure.""" + + session_id: str | None = None + """The identifier of the returned session.""" + + messages: list[Message] | None = None + """ + A list of messages that were last sent to the user. The messages are + ordered based on the order that your returned the messages from your + Lambda function or the order that messages are defined in the bot. + """ + + interpretations: "list[Interpretation] | None" = None + """ + A list of intents that Amazon Lex V2 determined might satisfy the + user's utterance. + + Each interpretation includes the intent, a score that indicates how + confident Amazon Lex V2 is that the interpretation is the correct one, + and an optional sentiment response that indicates the sentiment + expressed in the utterance. + """ + + session_state: "SessionState | None" = None + """ + Represents the current state of the dialog between the user and the bot. + + You can use this to determine the progress of the conversation and what + the next action might be. + """ + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_GET_SESSION_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.session_id is not None: + serializer.write_string( + _SCHEMA_GET_SESSION_OUTPUT.members["sessionId"], self.session_id + ) + + if self.messages is not None: + _serialize_messages( + serializer, + _SCHEMA_GET_SESSION_OUTPUT.members["messages"], + self.messages, + ) + + if self.interpretations is not None: + _serialize_interpretations( + serializer, + _SCHEMA_GET_SESSION_OUTPUT.members["interpretations"], + self.interpretations, + ) + + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_GET_SESSION_OUTPUT.members["sessionState"], self.session_state + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["session_id"] = de.read_string( + _SCHEMA_GET_SESSION_OUTPUT.members["sessionId"] + ) + + case 1: + kwargs["messages"] = _deserialize_messages( + de, _SCHEMA_GET_SESSION_OUTPUT.members["messages"] + ) + + case 2: + kwargs["interpretations"] = _deserialize_interpretations( + de, _SCHEMA_GET_SESSION_OUTPUT.members["interpretations"] + ) + + case 3: + kwargs["session_state"] = SessionState.deserialize(de) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_GET_SESSION_OUTPUT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class IntentResultEvent: + """ + Contains the current state of the conversation between the client + application and Amazon Lex V2. + """ + + input_mode: str | None = None + """ + Indicates whether the input to the operation was text, speech, or from a + touch-tone keypad. + """ + + interpretations: "list[Interpretation] | None" = None + """ + A list of intents that Amazon Lex V2 determined might satisfy the + user's utterance. + + Each interpretation includes the intent, a score that indicates how + confident Amazon Lex V2 is that the interpretation is the correct one, + and an optional sentiment response that indicates the sentiment + expressed in the utterance. + """ + + session_state: "SessionState | None" = None + """The state of the user's session with Amazon Lex V2.""" + + request_attributes: dict[str, str] | None = None + """The attributes sent in the request.""" + + session_id: str | None = None + """The identifier of the session in use.""" + + event_id: str | None = None + """ + A unique identifier of the event sent by Amazon Lex V2. The identifier + is in the form `RESPONSE-N`, where N is a number starting with one and + incremented for each event sent by Amazon Lex V2 in the current session. + """ + + recognized_bot_member: RecognizedBotMember | None = None + """The bot member that is processing the intent.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_INTENT_RESULT_EVENT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.input_mode is not None: + serializer.write_string( + _SCHEMA_INTENT_RESULT_EVENT.members["inputMode"], self.input_mode + ) + + if self.interpretations is not None: + _serialize_interpretations( + serializer, + _SCHEMA_INTENT_RESULT_EVENT.members["interpretations"], + self.interpretations, + ) + + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_INTENT_RESULT_EVENT.members["sessionState"], self.session_state + ) + + if self.request_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_INTENT_RESULT_EVENT.members["requestAttributes"], + self.request_attributes, + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_INTENT_RESULT_EVENT.members["sessionId"], self.session_id + ) + + if self.event_id is not None: + serializer.write_string( + _SCHEMA_INTENT_RESULT_EVENT.members["eventId"], self.event_id + ) + + if self.recognized_bot_member is not None: + serializer.write_struct( + _SCHEMA_INTENT_RESULT_EVENT.members["recognizedBotMember"], + self.recognized_bot_member, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["input_mode"] = de.read_string( + _SCHEMA_INTENT_RESULT_EVENT.members["inputMode"] + ) + + case 1: + kwargs["interpretations"] = _deserialize_interpretations( + de, _SCHEMA_INTENT_RESULT_EVENT.members["interpretations"] + ) + + case 2: + kwargs["session_state"] = SessionState.deserialize(de) + + case 3: + kwargs["request_attributes"] = _deserialize_string_map( + de, _SCHEMA_INTENT_RESULT_EVENT.members["requestAttributes"] + ) + + case 4: + kwargs["session_id"] = de.read_string( + _SCHEMA_INTENT_RESULT_EVENT.members["sessionId"] + ) + + case 5: + kwargs["event_id"] = de.read_string( + _SCHEMA_INTENT_RESULT_EVENT.members["eventId"] + ) + + case 6: + kwargs["recognized_bot_member"] = RecognizedBotMember.deserialize( + de + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_INTENT_RESULT_EVENT, consumer=_consumer) + return kwargs + + +@dataclass(kw_only=True) +class RecognizeTextOutput: + """Dataclass for RecognizeTextOutput structure.""" + + messages: list[Message] | None = None + """ + A list of messages last sent to the user. The messages are ordered based + on the order that you returned the messages from your Lambda function or + the order that the messages are defined in the bot. + """ + + session_state: "SessionState | None" = None + """ + Represents the current state of the dialog between the user and the bot. + + Use this to determine the progress of the conversation and what the next + action may be. + """ + + interpretations: "list[Interpretation] | None" = None + """ + A list of intents that Amazon Lex V2 determined might satisfy the + user's utterance. + + Each interpretation includes the intent, a score that indicates now + confident Amazon Lex V2 is that the interpretation is the correct one, + and an optional sentiment response that indicates the sentiment + expressed in the utterance. + """ + + request_attributes: dict[str, str] | None = None + """The attributes sent in the request.""" + + session_id: str | None = None + """The identifier of the session in use.""" + + recognized_bot_member: RecognizedBotMember | None = None + """The bot member that recognized the text.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_RECOGNIZE_TEXT_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + if self.messages is not None: + _serialize_messages( + serializer, + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["messages"], + self.messages, + ) + + if self.session_state is not None: + serializer.write_struct( + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["sessionState"], + self.session_state, + ) + + if self.interpretations is not None: + _serialize_interpretations( + serializer, + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["interpretations"], + self.interpretations, + ) + + if self.request_attributes is not None: + _serialize_string_map( + serializer, + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["requestAttributes"], + self.request_attributes, + ) + + if self.session_id is not None: + serializer.write_string( + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["sessionId"], self.session_id + ) + + if self.recognized_bot_member is not None: + serializer.write_struct( + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["recognizedBotMember"], + self.recognized_bot_member, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + kwargs["messages"] = _deserialize_messages( + de, _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["messages"] + ) + + case 1: + kwargs["session_state"] = SessionState.deserialize(de) + + case 2: + kwargs["interpretations"] = _deserialize_interpretations( + de, _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["interpretations"] + ) + + case 3: + kwargs["request_attributes"] = _deserialize_string_map( + de, _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["requestAttributes"] + ) + + case 4: + kwargs["session_id"] = de.read_string( + _SCHEMA_RECOGNIZE_TEXT_OUTPUT.members["sessionId"] + ) + + case 5: + kwargs["recognized_bot_member"] = RecognizedBotMember.deserialize( + de + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_RECOGNIZE_TEXT_OUTPUT, consumer=_consumer) + return kwargs + + +GET_SESSION = APIOperation( + input=GetSessionInput, + output=GetSessionOutput, + schema=_SCHEMA_GET_SESSION, + input_schema=_SCHEMA_GET_SESSION_INPUT, + output_schema=_SCHEMA_GET_SESSION_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ResourceNotFoundException" + ): ResourceNotFoundException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) + + +@dataclass +class StartConversationResponseEventStreamPlaybackInterruptionEvent: + """ + Event sent from Amazon Lex V2 to indicate to the client application + should stop playback of audio. For example, if the client is playing a + prompt that asks for the user's telephone number, the user might start + to say the phone number before the prompt is complete. Amazon Lex V2 + sends this event to the client application to indicate that the user is + responding and that Amazon Lex V2 is processing their input. + """ + + value: PlaybackInterruptionEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "PlaybackInterruptionEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=PlaybackInterruptionEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamTranscriptEvent: + """ + Event sent from Amazon Lex V2 to your client application that contains a + transcript of voice audio. + """ + + value: TranscriptEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members["TranscriptEvent"], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=TranscriptEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamIntentResultEvent: + """ + Event sent from Amazon Lex V2 to the client application containing the + current state of the conversation between the user and Amazon Lex V2. + """ + + value: IntentResultEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "IntentResultEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=IntentResultEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamTextResponseEvent: + """ + The event sent from Amazon Lex V2 to your application with text to + present to the user. + """ + + value: TextResponseEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "TextResponseEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=TextResponseEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamAudioResponseEvent: + """ + An event sent from Amazon Lex V2 to your client application containing + audio to play to the user. + """ + + value: AudioResponseEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "AudioResponseEvent" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=AudioResponseEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamHeartbeatEvent: + """ + Event that Amazon Lex V2 sends to indicate that the stream is still open + between the client application and Amazon Lex V2 + """ + + value: HeartbeatEvent + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members["HeartbeatEvent"], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=HeartbeatEvent.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamAccessDeniedException: + """ + Exception thrown when the credentials passed with the request are + invalid or expired. Also thrown when the credentials in the request do + not have permission to access the `StartConversation` operation. + """ + + value: AccessDeniedException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "AccessDeniedException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=AccessDeniedException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamResourceNotFoundException: + """ + Exception thrown if one of the input parameters points to a resource + that does not exist. For example, if the bot ID specified does not + exist. + """ + + value: ResourceNotFoundException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "ResourceNotFoundException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=ResourceNotFoundException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamValidationException: + """ + Exception thrown when one or more parameters could not be validated. The + `message` contains the name of the field that isn't valid. + """ + + value: ValidationException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "ValidationException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=ValidationException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamThrottlingException: + """ + Exception thrown when your application exceeds the maximum number of + concurrent requests. + """ + + value: ThrottlingException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "ThrottlingException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=ThrottlingException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamInternalServerException: + """An error occurred with Amazon Lex V2.""" + + value: InternalServerException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "InternalServerException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=InternalServerException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamConflictException: + """ + Exception thrown when two clients are using the same AWS account, Amazon + Lex V2 bot, and session ID. + """ + + value: ConflictException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "ConflictException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=ConflictException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamDependencyFailedException: + """""" + + value: DependencyFailedException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "DependencyFailedException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=DependencyFailedException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamBadGatewayException: + """""" + + value: BadGatewayException + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self) + + def serialize_members(self, serializer: ShapeSerializer): + serializer.write_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM.members[ + "BadGatewayException" + ], + self.value, + ) + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(value=BadGatewayException.deserialize(deserializer)) + + +@dataclass +class StartConversationResponseEventStreamUnknown: + """ + Represents an unknown variant. + + If you receive this value, you will need to update your library to receive the + parsed value. + + This value may not be deliberately sent. + """ + + tag: str + + def serialize(self, serializer: ShapeSerializer): + raise SerializationError("Unknown union variants may not be serialized.") + + def serialize_members(self, serializer: ShapeSerializer): + raise SerializationError("Unknown union variants may not be serialized.") + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + raise NotImplementedError() + + +StartConversationResponseEventStream = Union[ + StartConversationResponseEventStreamPlaybackInterruptionEvent + | StartConversationResponseEventStreamTranscriptEvent + | StartConversationResponseEventStreamIntentResultEvent + | StartConversationResponseEventStreamTextResponseEvent + | StartConversationResponseEventStreamAudioResponseEvent + | StartConversationResponseEventStreamHeartbeatEvent + | StartConversationResponseEventStreamAccessDeniedException + | StartConversationResponseEventStreamResourceNotFoundException + | StartConversationResponseEventStreamValidationException + | StartConversationResponseEventStreamThrottlingException + | StartConversationResponseEventStreamInternalServerException + | StartConversationResponseEventStreamConflictException + | StartConversationResponseEventStreamDependencyFailedException + | StartConversationResponseEventStreamBadGatewayException + | StartConversationResponseEventStreamUnknown +] +""" +Represents a stream of events between Amazon Lex V2 and your +application. +""" + + +class _StartConversationResponseEventStreamDeserializer: + _result: StartConversationResponseEventStream | None = None + + def deserialize( + self, deserializer: ShapeDeserializer + ) -> StartConversationResponseEventStream: + self._result = None + deserializer.read_struct( + _SCHEMA_START_CONVERSATION_RESPONSE_EVENT_STREAM, self._consumer + ) + + if self._result is None: + raise SerializationError( + "Unions must have exactly one value, but found none." + ) + + return self._result + + def _consumer(self, schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case 0: + self._set_result( + StartConversationResponseEventStreamPlaybackInterruptionEvent.deserialize( + de + ) + ) + + case 1: + self._set_result( + StartConversationResponseEventStreamTranscriptEvent.deserialize(de) + ) + + case 2: + self._set_result( + StartConversationResponseEventStreamIntentResultEvent.deserialize( + de + ) + ) + + case 3: + self._set_result( + StartConversationResponseEventStreamTextResponseEvent.deserialize( + de + ) + ) + + case 4: + self._set_result( + StartConversationResponseEventStreamAudioResponseEvent.deserialize( + de + ) + ) + + case 5: + self._set_result( + StartConversationResponseEventStreamHeartbeatEvent.deserialize(de) + ) + + case 6: + self._set_result( + StartConversationResponseEventStreamAccessDeniedException.deserialize( + de + ) + ) + + case 7: + self._set_result( + StartConversationResponseEventStreamResourceNotFoundException.deserialize( + de + ) + ) + + case 8: + self._set_result( + StartConversationResponseEventStreamValidationException.deserialize( + de + ) + ) + + case 9: + self._set_result( + StartConversationResponseEventStreamThrottlingException.deserialize( + de + ) + ) + + case 10: + self._set_result( + StartConversationResponseEventStreamInternalServerException.deserialize( + de + ) + ) + + case 11: + self._set_result( + StartConversationResponseEventStreamConflictException.deserialize( + de + ) + ) + + case 12: + self._set_result( + StartConversationResponseEventStreamDependencyFailedException.deserialize( + de + ) + ) + + case 13: + self._set_result( + StartConversationResponseEventStreamBadGatewayException.deserialize( + de + ) + ) + + case _: + logger.debug("Unexpected member schema: %s", schema) + + def _set_result(self, value: StartConversationResponseEventStream) -> None: + if self._result is not None: + raise SerializationError( + "Unions must have exactly one value, but found more than one." + ) + self._result = value + + +@dataclass(kw_only=True) +class StartConversationOutput: + """Dataclass for StartConversationOutput structure.""" + + def serialize(self, serializer: ShapeSerializer): + serializer.write_struct(_SCHEMA_START_CONVERSATION_OUTPUT, self) + + def serialize_members(self, serializer: ShapeSerializer): + pass + + @classmethod + def deserialize(cls, deserializer: ShapeDeserializer) -> Self: + return cls(**cls.deserialize_kwargs(deserializer)) + + @classmethod + def deserialize_kwargs(cls, deserializer: ShapeDeserializer) -> dict[str, Any]: + kwargs: dict[str, Any] = {} + + def _consumer(schema: Schema, de: ShapeDeserializer) -> None: + match schema.expect_member_index(): + case _: + logger.debug("Unexpected member schema: %s", schema) + + deserializer.read_struct(_SCHEMA_START_CONVERSATION_OUTPUT, consumer=_consumer) + return kwargs + + +RECOGNIZE_TEXT = APIOperation( + input=RecognizeTextInput, + output=RecognizeTextOutput, + schema=_SCHEMA_RECOGNIZE_TEXT, + input_schema=_SCHEMA_RECOGNIZE_TEXT_INPUT, + output_schema=_SCHEMA_RECOGNIZE_TEXT_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID( + "com.amazonaws.lexruntimev2#BadGatewayException" + ): BadGatewayException, + ShapeID("com.amazonaws.lexruntimev2#ConflictException"): ConflictException, + ShapeID( + "com.amazonaws.lexruntimev2#DependencyFailedException" + ): DependencyFailedException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ResourceNotFoundException" + ): ResourceNotFoundException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_BAD_GATEWAY_EXCEPTION, + _SCHEMA_CONFLICT_EXCEPTION, + _SCHEMA_DEPENDENCY_FAILED_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_RESOURCE_NOT_FOUND_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) + +START_CONVERSATION = APIOperation( + input=StartConversationInput, + output=StartConversationOutput, + schema=_SCHEMA_START_CONVERSATION, + input_schema=_SCHEMA_START_CONVERSATION_INPUT, + output_schema=_SCHEMA_START_CONVERSATION_OUTPUT, + error_registry=TypeRegistry( + { + ShapeID( + "com.amazonaws.lexruntimev2#AccessDeniedException" + ): AccessDeniedException, + ShapeID( + "com.amazonaws.lexruntimev2#InternalServerException" + ): InternalServerException, + ShapeID( + "com.amazonaws.lexruntimev2#ThrottlingException" + ): ThrottlingException, + ShapeID( + "com.amazonaws.lexruntimev2#ValidationException" + ): ValidationException, + } + ), + effective_auth_schemes=[ShapeID("aws.auth#sigv4")], + error_schemas=[ + _SCHEMA_ACCESS_DENIED_EXCEPTION, + _SCHEMA_INTERNAL_SERVER_EXCEPTION, + _SCHEMA_THROTTLING_EXCEPTION, + _SCHEMA_VALIDATION_EXCEPTION, + ], +) diff --git a/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/user_agent.py b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/user_agent.py new file mode 100644 index 0000000..b59564e --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/src/aws_sdk_lex_runtime_v2/user_agent.py @@ -0,0 +1,17 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from smithy_aws_core.interceptors.user_agent import UserAgentInterceptor + +from . import __version__ +from .config import Config + + +def aws_user_agent_plugin(config: Config): + config.interceptors.append( + UserAgentInterceptor( + ua_suffix=config.user_agent_extra, + ua_app_id=config.sdk_ua_app_id, + sdk_version=__version__, + service_id="Lex_Runtime_V2", + ) + ) diff --git a/clients/aws-sdk-lex-runtime-v2/tests/__init__.py b/clients/aws-sdk-lex-runtime-v2/tests/__init__.py new file mode 100644 index 0000000..247be3e --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/__init__.py @@ -0,0 +1 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. diff --git a/clients/aws-sdk-lex-runtime-v2/tests/integration/__init__.py b/clients/aws-sdk-lex-runtime-v2/tests/integration/__init__.py new file mode 100644 index 0000000..aac2b58 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/integration/__init__.py @@ -0,0 +1,23 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +import os + +from smithy_aws_core.identity import EnvironmentCredentialsResolver + +from aws_sdk_lex_runtime_v2.client import LexRuntimeV2Client +from aws_sdk_lex_runtime_v2.config import Config + +BOT_ID = os.environ["LEX_BOT_ID"] +BOT_ALIAS_ID = "TSTALIASID" +LOCALE_ID = "en_US" + + +def create_lex_client(region: str) -> LexRuntimeV2Client: + return LexRuntimeV2Client( + config=Config( + endpoint_uri=f"https://runtime-v2-lex.{region}.amazonaws.com", + region=region, + aws_credentials_identity_resolver=EnvironmentCredentialsResolver(), + ) + ) diff --git a/clients/aws-sdk-lex-runtime-v2/tests/integration/test_bidirectional_streaming.py b/clients/aws-sdk-lex-runtime-v2/tests/integration/test_bidirectional_streaming.py new file mode 100644 index 0000000..eba8c01 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/integration/test_bidirectional_streaming.py @@ -0,0 +1,108 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Test bidirectional streaming event stream handling.""" + +import asyncio +import uuid + +from smithy_core.aio.eventstream import DuplexEventStream + +from aws_sdk_lex_runtime_v2.models import ( + StartConversationInput, + StartConversationRequestEventStream, + StartConversationRequestEventStreamConfigurationEvent, + StartConversationRequestEventStreamTextInputEvent, + StartConversationRequestEventStreamDisconnectionEvent, + StartConversationResponseEventStream, + StartConversationResponseEventStreamTextResponseEvent, + StartConversationOutput, + ConfigurationEvent, + TextInputEvent, + DisconnectionEvent, +) +from . import BOT_ID, BOT_ALIAS_ID, LOCALE_ID, create_lex_client + + +async def _send_events( + stream: DuplexEventStream[ + StartConversationRequestEventStream, + StartConversationResponseEventStream, + StartConversationOutput, + ], +) -> None: + """Send configuration, text input, and disconnection events.""" + input_stream = stream.input_stream + + await input_stream.send( + StartConversationRequestEventStreamConfigurationEvent( + value=ConfigurationEvent(response_content_type="text/plain; charset=utf-8") + ) + ) + + await input_stream.send( + StartConversationRequestEventStreamTextInputEvent( + value=TextInputEvent(text="Hello") + ) + ) + + await asyncio.sleep(3) + + await input_stream.send( + StartConversationRequestEventStreamDisconnectionEvent( + value=DisconnectionEvent() + ) + ) + + await input_stream.close() + + +async def _receive_events( + stream: DuplexEventStream[ + StartConversationRequestEventStream, + StartConversationResponseEventStream, + StartConversationOutput, + ], +) -> tuple[bool, list[str]]: + """Receive and collect output from the stream. + + Returns: + Tuple of (got_text_response, messages) + """ + got_text_response = False + messages: list[str] = [] + + _, output_stream = await stream.await_output() + if output_stream is None: + return got_text_response, messages + + async for event in output_stream: + if isinstance(event, StartConversationResponseEventStreamTextResponseEvent): + got_text_response = True + if event.value.messages: + for msg in event.value.messages: + if msg.content: + messages.append(msg.content) + + return got_text_response, messages + + +async def test_start_conversation() -> None: + """Test bidirectional streaming StartConversation operation.""" + client = create_lex_client("us-east-1") + + stream = await client.start_conversation( + input=StartConversationInput( + bot_id=BOT_ID, + bot_alias_id=BOT_ALIAS_ID, + locale_id=LOCALE_ID, + session_id=str(uuid.uuid4()), + conversation_mode="TEXT", + ) + ) + + results = await asyncio.gather(_send_events(stream), _receive_events(stream)) + + got_text_response, messages = results[1] + assert got_text_response, "Expected to receive a TextResponse event" + assert len(messages) > 0, "Expected at least one message in the response" diff --git a/clients/aws-sdk-lex-runtime-v2/tests/integration/test_non_streaming.py b/clients/aws-sdk-lex-runtime-v2/tests/integration/test_non_streaming.py new file mode 100644 index 0000000..2322b43 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/integration/test_non_streaming.py @@ -0,0 +1,39 @@ +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Test non-streaming output type handling.""" + +import uuid + +from aws_sdk_lex_runtime_v2.models import RecognizeTextInput, RecognizeTextOutput +from . import BOT_ID, BOT_ALIAS_ID, LOCALE_ID, create_lex_client + + +async def test_recognize_text() -> None: + """Test non-streaming RecognizeText operation.""" + client = create_lex_client("us-east-1") + response = await client.recognize_text( + input=RecognizeTextInput( + bot_id=BOT_ID, + bot_alias_id=BOT_ALIAS_ID, + locale_id=LOCALE_ID, + session_id=str(uuid.uuid4()), + text="Hello", + ) + ) + + assert isinstance(response, RecognizeTextOutput) + assert response.session_id is not None + + # Verify session state with matched intent + assert response.session_state is not None + assert response.session_state.intent is not None + assert response.session_state.intent.name == "Greeting" + + # Verify interpretations contain the matched intent + assert response.interpretations is not None + assert len(response.interpretations) > 0 + + intent_names = [i.intent.name for i in response.interpretations if i.intent] + assert "Greeting" in intent_names + assert "FallbackIntent" in intent_names diff --git a/clients/aws-sdk-lex-runtime-v2/tests/setup_resources.py b/clients/aws-sdk-lex-runtime-v2/tests/setup_resources.py new file mode 100644 index 0000000..4144abb --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/setup_resources.py @@ -0,0 +1,182 @@ +# /// script +# requires-python = ">=3.12" +# dependencies = [ +# "boto3", +# ] +# /// +# +# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +# SPDX-License-Identifier: Apache-2.0 + +"""Setup script to create AWS resources for Lex Runtime V2 integration tests. + +Creates a simple Lex V2 bot with a Greeting intent for testing. + +Note: + This script is intended for local testing only and should not be used for + production setups. + +Usage: + uv run tests/setup_resources.py +""" + +import json +import time + +import boto3 + + +def create_lex_bot() -> tuple[str, str, str]: + """Create a simple Lex V2 bot for testing. + + Returns: + Tuple of (bot_id, bot_alias_id, locale_id) + """ + region = "us-east-1" + iam = boto3.client("iam") + lex = boto3.client("lexv2-models", region_name=region) + sts = boto3.client("sts") + + account_id = sts.get_caller_identity()["Account"] + role_name = "LexRuntimeV2IntegrationTestRole" + bot_name = "smithy-python-test-bot" + locale_id = "en_US" + + # Create IAM role for the bot + trust_policy = { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": {"Service": "lexv2.amazonaws.com"}, + "Action": "sts:AssumeRole", + } + ], + } + + try: + iam.create_role( + RoleName=role_name, + AssumeRolePolicyDocument=json.dumps(trust_policy), + ) + except iam.exceptions.EntityAlreadyExistsException: + pass + + role_arn = f"arn:aws:iam::{account_id}:role/{role_name}" + + # Check if bot already exists + existing_bots = lex.list_bots( + filters=[{"name": "BotName", "values": [bot_name], "operator": "EQ"}] + ) + if existing_bots["botSummaries"]: + bot_id = existing_bots["botSummaries"][0]["botId"] + print(f"Bot already exists: {bot_id}") + else: + response = lex.create_bot( + botName=bot_name, + roleArn=role_arn, + dataPrivacy={"childDirected": False}, + idleSessionTTLInSeconds=300, + ) + bot_id = response["botId"] + print(f"Created bot: {bot_id}") + _wait_for_bot(lex, bot_id) + + # Ensure locale exists + try: + locale_resp = lex.describe_bot_locale( + botId=bot_id, botVersion="DRAFT", localeId=locale_id + ) + locale_status = locale_resp["botLocaleStatus"] + print(f"Locale status: {locale_status}") + except lex.exceptions.ResourceNotFoundException: + print("Creating locale...") + lex.create_bot_locale( + botId=bot_id, + botVersion="DRAFT", + localeId=locale_id, + nluIntentConfidenceThreshold=0.40, + ) + _wait_for_bot_locale(lex, bot_id, locale_id, target_status="NotBuilt") + locale_status = "NotBuilt" + + # Create intent and build locale if not already built + if locale_status != "Built": + intent_name = "Greeting" + existing_intents = lex.list_intents( + botId=bot_id, botVersion="DRAFT", localeId=locale_id, + filters=[{"name": "IntentName", "values": [intent_name], "operator": "EQ"}], + ) + if not existing_intents["intentSummaries"]: + print(f"Creating intent: {intent_name}") + lex.create_intent( + intentName=intent_name, + botId=bot_id, + botVersion="DRAFT", + localeId=locale_id, + sampleUtterances=[ + {"utterance": "Hello"}, + {"utterance": "Hi"}, + {"utterance": "Hey"}, + ], + intentClosingSetting={ + "closingResponse": { + "messageGroups": [ + { + "message": { + "plainTextMessage": { + "value": "Hello! How can I help you?" + } + } + } + ], + }, + "active": True, + }, + ) + + print("Building locale...") + lex.build_bot_locale( + botId=bot_id, botVersion="DRAFT", localeId=locale_id + ) + _wait_for_bot_locale(lex, bot_id, locale_id, target_status="Built") + + # Use TSTALIASID (test alias, always available) + bot_alias_id = "TSTALIASID" + + return bot_id, bot_alias_id, locale_id + + +def _wait_for_bot(lex, bot_id: str, timeout: int = 60) -> None: + for _ in range(timeout // 5): + response = lex.describe_bot(botId=bot_id) + status = response["botStatus"] + if status == "Available": + return + if status in ("Failed", "Deleting"): + raise RuntimeError(f"Bot creation failed with status: {status}") + time.sleep(5) + raise TimeoutError("Bot did not become available") + + +def _wait_for_bot_locale( + lex, bot_id: str, locale_id: str, target_status: str, timeout: int = 60 +) -> None: + for _ in range(timeout // 5): + response = lex.describe_bot_locale( + botId=bot_id, botVersion="DRAFT", localeId=locale_id + ) + status = response["botLocaleStatus"] + if status == target_status: + return + if status in ("Failed", "Deleting"): + raise RuntimeError(f"Bot locale failed with status: {status}") + time.sleep(5) + raise TimeoutError(f"Bot locale did not reach {target_status}") + + +if __name__ == "__main__": + bot_id, bot_alias_id, locale_id = create_lex_bot() + + print("\nSetup complete. Export this environment variable before running tests:") + print(f"export LEX_BOT_ID={bot_id}") diff --git a/clients/aws-sdk-lex-runtime-v2/tests/test_protocol.py b/clients/aws-sdk-lex-runtime-v2/tests/test_protocol.py new file mode 100644 index 0000000..434ff03 --- /dev/null +++ b/clients/aws-sdk-lex-runtime-v2/tests/test_protocol.py @@ -0,0 +1,64 @@ +# Code generated by smithy-python-codegen DO NOT EDIT. + +from smithy_core.aio.utils import async_list +from smithy_http import tuples_to_fields +from smithy_http.aio import HTTPResponse as _HTTPResponse +from smithy_http.aio.interfaces import HTTPRequest, HTTPResponse +from smithy_http.interfaces import HTTPClientConfiguration, HTTPRequestConfiguration + +from aws_sdk_lex_runtime_v2.models import ServiceError + + +class TestHttpServiceError(ServiceError): + """A test error that subclasses the service-error for protocol tests.""" + + def __init__(self, request: HTTPRequest): + self.request = request + + +class RequestTestHTTPClient: + """An asynchronous HTTP client solely for testing purposes.""" + + TIMEOUT_EXCEPTIONS = () + + def __init__(self, *, client_config: HTTPClientConfiguration | None = None): + self._client_config = client_config + + async def send( + self, + request: HTTPRequest, + *, + request_config: HTTPRequestConfiguration | None = None, + ) -> HTTPResponse: + # Raise the exception with the request object to bypass actual request handling + raise TestHttpServiceError(request) + + +class ResponseTestHTTPClient: + """An asynchronous HTTP client solely for testing purposes.""" + + TIMEOUT_EXCEPTIONS = () + + def __init__( + self, + *, + client_config: HTTPClientConfiguration | None = None, + status: int = 200, + headers: list[tuple[str, str]] | None = None, + body: bytes = b"", + ): + self._client_config = client_config + self.status = status + self.fields = tuples_to_fields(headers or []) + self.body = body + + async def send( + self, + request: HTTPRequest, + *, + request_config: HTTPRequestConfiguration | None = None, + ) -> _HTTPResponse: + # Pre-construct the response from the request and return it + return _HTTPResponse( + status=self.status, fields=self.fields, body=async_list([self.body]) + ) diff --git a/codegen/aws-models/lex-runtime-v2.json b/codegen/aws-models/lex-runtime-v2.json new file mode 100644 index 0000000..1ee73c7 --- /dev/null +++ b/codegen/aws-models/lex-runtime-v2.json @@ -0,0 +1,3300 @@ +{ + "smithy": "2.0", + "metadata": { + "suppressions": [ + { + "id": "HttpMethodSemantics", + "namespace": "*" + }, + { + "id": "HttpResponseCodeSemantics", + "namespace": "*" + }, + { + "id": "PaginatedTrait", + "namespace": "*" + }, + { + "id": "HttpHeaderTrait", + "namespace": "*" + }, + { + "id": "HttpUriConflict", + "namespace": "*" + }, + { + "id": "Service", + "namespace": "*" + } + ] + }, + "shapes": { + "com.amazonaws.lexruntimev2#AWSDeepSenseRunTimeServiceApi2_0": { + "type": "service", + "version": "2020-08-07", + "operations": [ + { + "target": "com.amazonaws.lexruntimev2#DeleteSession" + }, + { + "target": "com.amazonaws.lexruntimev2#GetSession" + }, + { + "target": "com.amazonaws.lexruntimev2#PutSession" + }, + { + "target": "com.amazonaws.lexruntimev2#RecognizeText" + }, + { + "target": "com.amazonaws.lexruntimev2#RecognizeUtterance" + }, + { + "target": "com.amazonaws.lexruntimev2#StartConversation" + } + ], + "traits": { + "aws.api#service": { + "sdkId": "Lex Runtime V2", + "arnNamespace": "lex", + "cloudFormationName": "LexRuntimeV2", + "cloudTrailEventSource": "lexruntimev2.amazonaws.com", + "docId": "runtime.lex.v2-2020-08-07", + "endpointPrefix": "runtime-v2-lex" + }, + "aws.auth#sigv4": { + "name": "lex" + }, + "aws.protocols#restJson1": { + "http": [ + "http/1.1", + "h2" + ], + "eventStreamHttp": [ + "h2" + ] + }, + "smithy.api#documentation": "

This section contains documentation for the Amazon Lex V2 Runtime V2 API operations.

", + "smithy.api#title": "Amazon Lex Runtime V2", + "smithy.rules#endpointRuleSet": { + "version": "1.0", + "parameters": { + "Region": { + "builtIn": "AWS::Region", + "required": false, + "documentation": "The AWS region used to dispatch the request.", + "type": "string" + }, + "UseDualStack": { + "builtIn": "AWS::UseDualStack", + "required": true, + "default": false, + "documentation": "When true, use the dual-stack endpoint. If the configured endpoint does not support dual-stack, dispatching the request MAY return an error.", + "type": "boolean" + }, + "UseFIPS": { + "builtIn": "AWS::UseFIPS", + "required": true, + "default": false, + "documentation": "When true, send this request to the FIPS-compliant regional endpoint. If the configured endpoint does not have a FIPS compliant endpoint, dispatching the request will return an error.", + "type": "boolean" + }, + "Endpoint": { + "builtIn": "SDK::Endpoint", + "required": false, + "documentation": "Override the endpoint used to send this request", + "type": "string" + } + }, + "rules": [ + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Endpoint" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "error": "Invalid Configuration: FIPS and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported", + "type": "error" + }, + { + "conditions": [], + "endpoint": { + "url": { + "ref": "Endpoint" + }, + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + }, + { + "conditions": [ + { + "fn": "isSet", + "argv": [ + { + "ref": "Region" + } + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "aws.partition", + "argv": [ + { + "ref": "Region" + } + ], + "assign": "PartitionResult" + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + }, + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + } + ] + }, + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://runtime-v2-lex-fips.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "FIPS and DualStack are enabled, but this partition does not support one or both", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseFIPS" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsFIPS" + ] + }, + true + ] + } + ], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://runtime-v2-lex-fips.{Region}.{PartitionResult#dnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "FIPS is enabled but this partition does not support FIPS", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + { + "ref": "UseDualStack" + }, + true + ] + } + ], + "rules": [ + { + "conditions": [ + { + "fn": "booleanEquals", + "argv": [ + true, + { + "fn": "getAttr", + "argv": [ + { + "ref": "PartitionResult" + }, + "supportsDualStack" + ] + } + ] + } + ], + "rules": [ + { + "conditions": [], + "endpoint": { + "url": "https://runtime-v2-lex.{Region}.{PartitionResult#dualStackDnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "DualStack is enabled but this partition does not support DualStack", + "type": "error" + } + ], + "type": "tree" + }, + { + "conditions": [], + "endpoint": { + "url": "https://runtime-v2-lex.{Region}.{PartitionResult#dnsSuffix}", + "properties": {}, + "headers": {} + }, + "type": "endpoint" + } + ], + "type": "tree" + } + ], + "type": "tree" + }, + { + "conditions": [], + "error": "Invalid Configuration: Missing Region", + "type": "error" + } + ] + }, + "smithy.rules#endpointTests": { + "testCases": [ + { + "documentation": "For region af-south-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.af-south-1.amazonaws.com" + } + }, + "params": { + "Region": "af-south-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region ap-northeast-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.ap-northeast-1.amazonaws.com" + } + }, + "params": { + "Region": "ap-northeast-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region ap-northeast-2 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.ap-northeast-2.amazonaws.com" + } + }, + "params": { + "Region": "ap-northeast-2", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region ap-southeast-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.ap-southeast-1.amazonaws.com" + } + }, + "params": { + "Region": "ap-southeast-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region ap-southeast-2 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.ap-southeast-2.amazonaws.com" + } + }, + "params": { + "Region": "ap-southeast-2", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region ca-central-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.ca-central-1.amazonaws.com" + } + }, + "params": { + "Region": "ca-central-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region eu-central-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.eu-central-1.amazonaws.com" + } + }, + "params": { + "Region": "eu-central-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region eu-west-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.eu-west-1.amazonaws.com" + } + }, + "params": { + "Region": "eu-west-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region eu-west-2 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.eu-west-2.amazonaws.com" + } + }, + "params": { + "Region": "eu-west-2", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-west-2 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-west-2.amazonaws.com" + } + }, + "params": { + "Region": "us-west-2", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-east-1.api.aws" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.cn-north-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region cn-north-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.cn-north-1.amazonaws.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.cn-north-1.api.amazonwebservices.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region cn-north-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.cn-north-1.amazonaws.com.cn" + } + }, + "params": { + "Region": "cn-north-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-gov-east-1.api.aws" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": true, + "UseDualStack": true + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-gov-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack enabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-gov-east-1.api.aws" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": false, + "UseDualStack": true + } + }, + { + "documentation": "For region us-gov-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-gov-east-1.amazonaws.com" + } + }, + "params": { + "Region": "us-gov-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-iso-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-iso-east-1.c2s.ic.gov" + } + }, + "params": { + "Region": "us-iso-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS enabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex-fips.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": true, + "UseDualStack": false + } + }, + { + "documentation": "For region us-isob-east-1 with FIPS disabled and DualStack disabled", + "expect": { + "endpoint": { + "url": "https://runtime-v2-lex.us-isob-east-1.sc2s.sgov.gov" + } + }, + "params": { + "Region": "us-isob-east-1", + "UseFIPS": false, + "UseDualStack": false + } + }, + { + "documentation": "For custom endpoint with region set and fips disabled and dualstack disabled", + "expect": { + "endpoint": { + "url": "https://example.com" + } + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with region not set and fips disabled and dualstack disabled", + "expect": { + "endpoint": { + "url": "https://example.com" + } + }, + "params": { + "UseFIPS": false, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with fips enabled and dualstack disabled", + "expect": { + "error": "Invalid Configuration: FIPS and custom endpoint are not supported" + }, + "params": { + "Region": "us-east-1", + "UseFIPS": true, + "UseDualStack": false, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "For custom endpoint with fips disabled and dualstack enabled", + "expect": { + "error": "Invalid Configuration: Dualstack and custom endpoint are not supported" + }, + "params": { + "Region": "us-east-1", + "UseFIPS": false, + "UseDualStack": true, + "Endpoint": "https://example.com" + } + }, + { + "documentation": "Missing region", + "expect": { + "error": "Invalid Configuration: Missing Region" + } + } + ], + "version": "1.0" + } + } + }, + "com.amazonaws.lexruntimev2#AccessDeniedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 403 + } + }, + "com.amazonaws.lexruntimev2#ActiveContext": { + "type": "structure", + "members": { + "name": { + "target": "com.amazonaws.lexruntimev2#ActiveContextName", + "traits": { + "smithy.api#documentation": "

The name of the context.

", + "smithy.api#required": {} + } + }, + "timeToLive": { + "target": "com.amazonaws.lexruntimev2#ActiveContextTimeToLive", + "traits": { + "smithy.api#documentation": "

Indicates the number of turns or seconds that the context is active.\n Once the time to live expires, the context is no longer returned in a\n response.

", + "smithy.api#required": {} + } + }, + "contextAttributes": { + "target": "com.amazonaws.lexruntimev2#ActiveContextParametersMap", + "traits": { + "smithy.api#documentation": "

A list of contexts active for the request. A context can be\n activated when a previous intent is fulfilled, or by including the\n context in the request.

\n

If you don't specify a list of contexts, Amazon Lex V2 will use the current\n list of contexts for the session. If you specify an empty list, all\n contexts for the session are cleared.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

Contains information about the contexts that a user is using in a\n session. You can configure Amazon Lex V2 to set a context when an intent is\n fulfilled, or you can set a context using the , , or operations.

\n

Use a context to indicate to Amazon Lex V2 intents that should be used as\n follow-up intents. For example, if the active context is\n order-fulfilled, only intents that have\n order-fulfilled configured as a trigger are considered\n for follow up.

" + } + }, + "com.amazonaws.lexruntimev2#ActiveContextName": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + }, + "smithy.api#pattern": "^([A-Za-z0-9]_?)+$" + } + }, + "com.amazonaws.lexruntimev2#ActiveContextParametersMap": { + "type": "map", + "key": { + "target": "com.amazonaws.lexruntimev2#ParameterName" + }, + "value": { + "target": "com.amazonaws.lexruntimev2#Text" + }, + "traits": { + "smithy.api#length": { + "min": 0, + "max": 10 + } + } + }, + "com.amazonaws.lexruntimev2#ActiveContextTimeToLive": { + "type": "structure", + "members": { + "timeToLiveInSeconds": { + "target": "com.amazonaws.lexruntimev2#ActiveContextTimeToLiveInSeconds", + "traits": { + "smithy.api#documentation": "

The number of seconds that the context is active. You can specify\n between 5 and 86400 seconds (24 hours).

", + "smithy.api#required": {} + } + }, + "turnsToLive": { + "target": "com.amazonaws.lexruntimev2#ActiveContextTurnsToLive", + "traits": { + "smithy.api#documentation": "

The number of turns that the context is active. You can specify up\n to 20 turns. Each request and response from the bot is a turn.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

The time that a context is active. You can specify the time to live\n in seconds or in conversation turns.

" + } + }, + "com.amazonaws.lexruntimev2#ActiveContextTimeToLiveInSeconds": { + "type": "integer", + "traits": { + "smithy.api#range": { + "min": 5, + "max": 86400 + } + } + }, + "com.amazonaws.lexruntimev2#ActiveContextTurnsToLive": { + "type": "integer", + "traits": { + "smithy.api#range": { + "min": 1, + "max": 20 + } + } + }, + "com.amazonaws.lexruntimev2#ActiveContextsList": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#ActiveContext" + }, + "traits": { + "smithy.api#length": { + "min": 0, + "max": 20 + } + } + }, + "com.amazonaws.lexruntimev2#AttachmentTitle": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 250 + } + } + }, + "com.amazonaws.lexruntimev2#AttachmentUrl": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 250 + } + } + }, + "com.amazonaws.lexruntimev2#AudioChunk": { + "type": "blob" + }, + "com.amazonaws.lexruntimev2#AudioInputEvent": { + "type": "structure", + "members": { + "audioChunk": { + "target": "com.amazonaws.lexruntimev2#AudioChunk", + "traits": { + "smithy.api#documentation": "

An encoded stream of audio.

" + } + }, + "contentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The encoding used for the audio chunk. You must use 8 KHz PCM 16-bit\n mono-channel little-endian format. The value of the field should\n be:

\n

\n audio/lpcm; sample-rate=8000; sample-size-bits=16;\n channel-count=1; is-big-endian=false\n

", + "smithy.api#required": {} + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Represents a chunk of audio sent from the client application to\n Amazon Lex V2. The audio is all or part of an utterance from the user.

\n

Amazon Lex V2 accumulates audio chunks until it recognizes a natural pause\n in speech before processing the input.

" + } + }, + "com.amazonaws.lexruntimev2#AudioResponseEvent": { + "type": "structure", + "members": { + "audioChunk": { + "target": "com.amazonaws.lexruntimev2#AudioChunk", + "traits": { + "smithy.api#documentation": "

A chunk of the audio to play.

" + } + }, + "contentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The encoding of the audio chunk. This is the same as the encoding\n configure in the contentType field of the\n ConfigurationEvent.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

An event sent from Amazon Lex V2 to your client application containing audio\n to play to the user.

" + } + }, + "com.amazonaws.lexruntimev2#BadGatewayException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "server", + "smithy.api#httpError": 502 + } + }, + "com.amazonaws.lexruntimev2#BlobStream": { + "type": "blob", + "traits": { + "smithy.api#streaming": {} + } + }, + "com.amazonaws.lexruntimev2#Boolean": { + "type": "boolean", + "traits": { + "smithy.api#default": false + } + }, + "com.amazonaws.lexruntimev2#BotAliasIdentifier": { + "type": "string" + }, + "com.amazonaws.lexruntimev2#BotIdentifier": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 10, + "max": 10 + }, + "smithy.api#pattern": "^[0-9a-zA-Z]+$" + } + }, + "com.amazonaws.lexruntimev2#Button": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.lexruntimev2#ButtonText", + "traits": { + "smithy.api#documentation": "

The text that is displayed on the button.

", + "smithy.api#required": {} + } + }, + "value": { + "target": "com.amazonaws.lexruntimev2#ButtonValue", + "traits": { + "smithy.api#documentation": "

The value returned to Amazon Lex V2 when a user chooses the button.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

A button that appears on a response card show to the user.

" + } + }, + "com.amazonaws.lexruntimev2#ButtonText": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 50 + } + } + }, + "com.amazonaws.lexruntimev2#ButtonValue": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 50 + } + } + }, + "com.amazonaws.lexruntimev2#ButtonsList": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#Button" + }, + "traits": { + "smithy.api#length": { + "min": 0, + "max": 5 + } + } + }, + "com.amazonaws.lexruntimev2#ConfidenceScore": { + "type": "structure", + "members": { + "score": { + "target": "com.amazonaws.lexruntimev2#Double", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A score that indicates how confident Amazon Lex V2 is that an intent\n satisfies the user's intent. Ranges between 0.00 and 1.00. Higher\n scores indicate higher confidence.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Provides a score that indicates the confidence that Amazon Lex V2 has that\n an intent is the one that satisfies the user's intent.

" + } + }, + "com.amazonaws.lexruntimev2#ConfigurationEvent": { + "type": "structure", + "members": { + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

Request-specific information passed between the client application\n and Amazon Lex V2.

\n

The namespace x-amz-lex: is reserved for special\n attributes. Don't create any request attributes for prefix\n x-amz-lex:.

" + } + }, + "responseContentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The message that Amazon Lex V2 returns in the response can be either text or\n speech based on the responseContentType value.

\n ", + "smithy.api#required": {} + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState" + }, + "welcomeMessages": { + "target": "com.amazonaws.lexruntimev2#Messages", + "traits": { + "smithy.api#documentation": "

A list of messages to send to the user.

\n

If you set the welcomeMessage field, you must also set\n the \n DialogAction\n structure's \n type\n field.

" + } + }, + "disablePlayback": { + "target": "com.amazonaws.lexruntimev2#Boolean", + "traits": { + "smithy.api#default": false, + "smithy.api#documentation": "

Determines whether Amazon Lex V2 should send audio responses to the client\n application. \n

\n

Set this field to false when the client is operating in a playback\n mode where audio responses are played to the user. If the client isn't\n operating in playback mode, such as a text chat application, set this\n to true so that Amazon Lex V2 doesn't wait for the prompt to finish playing on\n the client.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The initial event sent from the application to Amazon Lex V2 to configure\n the conversation, including session and request attributes and the\n response content type.

" + } + }, + "com.amazonaws.lexruntimev2#ConfirmationState": { + "type": "enum", + "members": { + "CONFIRMED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Confirmed" + } + }, + "DENIED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Denied" + } + }, + "NONE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "None" + } + } + } + }, + "com.amazonaws.lexruntimev2#ConflictException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 409 + } + }, + "com.amazonaws.lexruntimev2#ConversationMode": { + "type": "enum", + "members": { + "AUDIO": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "AUDIO" + } + }, + "TEXT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "TEXT" + } + } + } + }, + "com.amazonaws.lexruntimev2#DTMFInputEvent": { + "type": "structure", + "members": { + "inputCharacter": { + "target": "com.amazonaws.lexruntimev2#DTMFRegex", + "traits": { + "smithy.api#documentation": "

The DTMF character that the user pressed. The allowed characters are\n A - D, 0 - 9, # and *.

", + "smithy.api#required": {} + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

A DTMF character sent from the client application. DTMF characters\n are typically sent from a phone keypad to represent numbers. For\n example, you can have Amazon Lex V2 process a credit card number input from a\n phone.

" + } + }, + "com.amazonaws.lexruntimev2#DTMFRegex": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 1 + }, + "smithy.api#pattern": "^[A-D0-9#*]{1}$", + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.lexruntimev2#DeleteSession": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#DeleteSessionRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#DeleteSessionResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#ConflictException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Removes session information for a specified bot, alias, and user ID.

\n

You can use this operation to restart a conversation with a bot.\n When you remove a session, the entire history of the session is removed\n so that you can start again.

\n

You don't need to delete a session. Sessions have a time limit and\n will expire. Set the session time limit when you create the bot. The\n default is 5 minutes, but you can specify anything between 1 minute and\n 24 hours.

\n

If you specify a bot or alias ID that doesn't exist, you receive a\n BadRequestException.\n

\n

If the locale doesn't exist in the bot, or if the locale hasn't been\n enables for the alias, you receive a\n BadRequestException.

", + "smithy.api#http": { + "method": "DELETE", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#DeleteSessionRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that contains the session data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that contains the session\n data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session to delete.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#DeleteSessionResponse": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that contained the session data.

" + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that contained the session\n data.

" + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session was used.

" + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the deleted session.

" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#DependencyFailedException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 424 + } + }, + "com.amazonaws.lexruntimev2#DialogAction": { + "type": "structure", + "members": { + "type": { + "target": "com.amazonaws.lexruntimev2#DialogActionType", + "traits": { + "smithy.api#documentation": "

The next action that the bot should take in its interaction with the\n user. The following values are possible:

\n ", + "smithy.api#required": {} + } + }, + "slotToElicit": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The name of the slot that should be elicited from the user.

" + } + }, + "slotElicitationStyle": { + "target": "com.amazonaws.lexruntimev2#StyleType", + "traits": { + "smithy.api#documentation": "

Configures the slot to use spell-by-letter or spell-by-word style.\n When you use a style on a slot, users can spell out their input to make\n it clear to your bot.

\n \n

For more information, see \n Using spelling to enter slot values .

" + } + }, + "subSlotToElicit": { + "target": "com.amazonaws.lexruntimev2#ElicitSubSlot", + "traits": { + "smithy.api#documentation": "

The name of the constituent sub slot of the composite slot \n specified in slotToElicit that should be elicited from the user.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The next action that Amazon Lex V2 should take.

" + } + }, + "com.amazonaws.lexruntimev2#DialogActionType": { + "type": "enum", + "members": { + "CLOSE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Close" + } + }, + "CONFIRM_INTENT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ConfirmIntent" + } + }, + "DELEGATE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Delegate" + } + }, + "ELICIT_INTENT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ElicitIntent" + } + }, + "ELICIT_SLOT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ElicitSlot" + } + }, + "NONE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "None" + } + } + } + }, + "com.amazonaws.lexruntimev2#DisconnectionEvent": { + "type": "structure", + "members": { + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

A notification from the client that it is disconnecting from Amazon Lex V2.\n Sending a DisconnectionEvent event is optional, but can\n help identify a conversation in logs.

" + } + }, + "com.amazonaws.lexruntimev2#Double": { + "type": "double", + "traits": { + "smithy.api#default": 0 + } + }, + "com.amazonaws.lexruntimev2#ElicitSubSlot": { + "type": "structure", + "members": { + "name": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The name of the slot that should be elicited from the user.

", + "smithy.api#required": {} + } + }, + "subSlotToElicit": { + "target": "com.amazonaws.lexruntimev2#ElicitSubSlot", + "traits": { + "smithy.api#documentation": "

The field is not supported.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The specific constituent sub slot of the composite slot to elicit in dialog action.

" + } + }, + "com.amazonaws.lexruntimev2#EpochMillis": { + "type": "long", + "traits": { + "smithy.api#default": 0 + } + }, + "com.amazonaws.lexruntimev2#EventId": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 2, + "max": 100 + }, + "smithy.api#pattern": "^[0-9a-zA-Z._:-]+$" + } + }, + "com.amazonaws.lexruntimev2#GetSession": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#GetSessionRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#GetSessionResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Returns session information for a specified bot, alias, and\n user.

\n

For example, you can use this operation to retrieve session\n information for a user that has left a long-running session in\n use.

\n

If the bot, alias, or session identifier doesn't exist, Amazon Lex V2\n returns a BadRequestException. If the locale doesn't exist\n or is not enabled for the alias, you receive a\n BadRequestException.

", + "smithy.api#http": { + "method": "GET", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#GetSessionRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that contains the session data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that contains the session\n data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session to return.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#GetSessionResponse": { + "type": "structure", + "members": { + "sessionId": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The identifier of the returned session.

" + } + }, + "messages": { + "target": "com.amazonaws.lexruntimev2#Messages", + "traits": { + "smithy.api#documentation": "

A list of messages that were last sent to the user. The messages are\n ordered based on the order that your returned the messages from your\n Lambda function or the order that messages are defined in the bot.\n

" + } + }, + "interpretations": { + "target": "com.amazonaws.lexruntimev2#Interpretations", + "traits": { + "smithy.api#documentation": "

A list of intents that Amazon Lex V2 determined might satisfy the user's\n utterance.

\n

Each interpretation includes the intent, a score that indicates how\n confident Amazon Lex V2 is that the interpretation is the correct one, and an\n optional sentiment response that indicates the sentiment expressed in\n the utterance.

" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState", + "traits": { + "smithy.api#documentation": "

Represents the current state of the dialog between the user and the\n bot.

\n

You can use this to determine the progress of the conversation and\n what the next action might be.

" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#HeartbeatEvent": { + "type": "structure", + "members": { + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Event that Amazon Lex V2 sends to indicate that the stream is still open\n between the client application and Amazon Lex V2

" + } + }, + "com.amazonaws.lexruntimev2#ImageResponseCard": { + "type": "structure", + "members": { + "title": { + "target": "com.amazonaws.lexruntimev2#AttachmentTitle", + "traits": { + "smithy.api#documentation": "

The title to display on the response card. The format of the title\n is determined by the platform displaying the response card.

", + "smithy.api#required": {} + } + }, + "subtitle": { + "target": "com.amazonaws.lexruntimev2#AttachmentTitle", + "traits": { + "smithy.api#documentation": "

The subtitle to display on the response card. The format of the\n subtitle is determined by the platform displaying the response\n card.

" + } + }, + "imageUrl": { + "target": "com.amazonaws.lexruntimev2#AttachmentUrl", + "traits": { + "smithy.api#documentation": "

The URL of an image to display on the response card. The image URL\n must be publicly available so that the platform displaying the response\n card has access to the image.

" + } + }, + "buttons": { + "target": "com.amazonaws.lexruntimev2#ButtonsList", + "traits": { + "smithy.api#documentation": "

A list of buttons that should be displayed on the response card. The\n arrangement of the buttons is determined by the platform that displays\n the button.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

A card that is shown to the user by a messaging platform. You define\n the contents of the card, the card is displayed by the platform.

\n

When you use a response card, the response from the user is\n constrained to the text associated with a button on the card.

" + } + }, + "com.amazonaws.lexruntimev2#InputMode": { + "type": "enum", + "members": { + "TEXT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Text" + } + }, + "SPEECH": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Speech" + } + }, + "DTMF": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "DTMF" + } + } + } + }, + "com.amazonaws.lexruntimev2#Intent": { + "type": "structure", + "members": { + "name": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The name of the intent.

", + "smithy.api#required": {} + } + }, + "slots": { + "target": "com.amazonaws.lexruntimev2#Slots", + "traits": { + "smithy.api#documentation": "

A map of all of the slots for the intent. The name of the slot maps\n to the value of the slot. If a slot has not been filled, the value is\n null.

" + } + }, + "state": { + "target": "com.amazonaws.lexruntimev2#IntentState", + "traits": { + "smithy.api#documentation": "

Indicates the fulfillment state for the intent. The meanings of each value are as follows:

\n " + } + }, + "confirmationState": { + "target": "com.amazonaws.lexruntimev2#ConfirmationState", + "traits": { + "smithy.api#documentation": "

Indicates whether the intent has been Confirmed, Denied, or None if the confirmation stage has not yet been reached.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The current intent that Amazon Lex V2 is attempting to fulfill.

" + } + }, + "com.amazonaws.lexruntimev2#IntentResultEvent": { + "type": "structure", + "members": { + "inputMode": { + "target": "com.amazonaws.lexruntimev2#InputMode", + "traits": { + "smithy.api#documentation": "

Indicates whether the input to the operation was text, speech, or from a touch-tone keypad.

" + } + }, + "interpretations": { + "target": "com.amazonaws.lexruntimev2#Interpretations", + "traits": { + "smithy.api#documentation": "

A list of intents that Amazon Lex V2 determined might satisfy the user's\n utterance.

\n

Each interpretation includes the intent, a score that indicates how\n confident Amazon Lex V2 is that the interpretation is the correct one, and an\n optional sentiment response that indicates the sentiment expressed in\n the utterance.

" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState" + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

The attributes sent in the request.

" + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session in use.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + }, + "recognizedBotMember": { + "target": "com.amazonaws.lexruntimev2#RecognizedBotMember", + "traits": { + "smithy.api#documentation": "

The bot member that is processing the intent.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Contains the current state of the conversation between the client\n application and Amazon Lex V2.

" + } + }, + "com.amazonaws.lexruntimev2#IntentState": { + "type": "enum", + "members": { + "FAILED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Failed" + } + }, + "FULFILLED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Fulfilled" + } + }, + "IN_PROGRESS": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "InProgress" + } + }, + "READY_FOR_FULFILLMENT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ReadyForFulfillment" + } + }, + "WAITING": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Waiting" + } + }, + "FULFILLMENT_IN_PROGRESS": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "FulfillmentInProgress" + } + } + } + }, + "com.amazonaws.lexruntimev2#InternalServerException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "server", + "smithy.api#httpError": 500 + } + }, + "com.amazonaws.lexruntimev2#Interpretation": { + "type": "structure", + "members": { + "nluConfidence": { + "target": "com.amazonaws.lexruntimev2#ConfidenceScore", + "traits": { + "smithy.api#documentation": "

Determines the threshold where Amazon Lex V2 will insert the\n AMAZON.FallbackIntent,\n AMAZON.KendraSearchIntent, or both when returning\n alternative intents in a response. AMAZON.FallbackIntent\n and AMAZON.KendraSearchIntent are only inserted if they\n are configured for the bot.

" + } + }, + "sentimentResponse": { + "target": "com.amazonaws.lexruntimev2#SentimentResponse", + "traits": { + "smithy.api#documentation": "

The sentiment expressed in an utterance.

\n

When the bot is configured to send utterances to Amazon Comprehend\n for sentiment analysis, this field contains the result of the\n analysis.

" + } + }, + "intent": { + "target": "com.amazonaws.lexruntimev2#Intent", + "traits": { + "smithy.api#documentation": "

A list of intents that might satisfy the user's utterance. The\n intents are ordered by the confidence score.

" + } + }, + "interpretationSource": { + "target": "com.amazonaws.lexruntimev2#InterpretationSource", + "traits": { + "smithy.api#documentation": "

Specifies the service that interpreted the input.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

An object containing information about an intent that Amazon Lex V2 determined might satisfy the user's utterance.\n The intents are ordered by the confidence score.

" + } + }, + "com.amazonaws.lexruntimev2#InterpretationSource": { + "type": "enum", + "members": { + "BEDROCK": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Bedrock" + } + }, + "LEX": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Lex" + } + } + } + }, + "com.amazonaws.lexruntimev2#Interpretations": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#Interpretation" + }, + "traits": { + "smithy.api#length": { + "min": 0, + "max": 5 + } + } + }, + "com.amazonaws.lexruntimev2#LocaleId": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1 + } + } + }, + "com.amazonaws.lexruntimev2#Message": { + "type": "structure", + "members": { + "content": { + "target": "com.amazonaws.lexruntimev2#Text", + "traits": { + "smithy.api#documentation": "

The text of the message.

" + } + }, + "contentType": { + "target": "com.amazonaws.lexruntimev2#MessageContentType", + "traits": { + "smithy.api#documentation": "

Indicates the type of response.

", + "smithy.api#required": {} + } + }, + "imageResponseCard": { + "target": "com.amazonaws.lexruntimev2#ImageResponseCard" + } + }, + "traits": { + "smithy.api#documentation": "

Container for text that is returned to the customer..

" + } + }, + "com.amazonaws.lexruntimev2#MessageContentType": { + "type": "enum", + "members": { + "CUSTOM_PAYLOAD": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "CustomPayload" + } + }, + "IMAGE_RESPONSE_CARD": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "ImageResponseCard" + } + }, + "PLAIN_TEXT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "PlainText" + } + }, + "SSML": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "SSML" + } + } + } + }, + "com.amazonaws.lexruntimev2#Messages": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#Message" + }, + "traits": { + "smithy.api#length": { + "min": 0, + "max": 10 + } + } + }, + "com.amazonaws.lexruntimev2#Name": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + }, + "smithy.api#pattern": "^([0-9a-zA-Z][_-]?)+$" + } + }, + "com.amazonaws.lexruntimev2#NonEmptyString": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1 + } + } + }, + "com.amazonaws.lexruntimev2#ParameterName": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + } + } + }, + "com.amazonaws.lexruntimev2#PlaybackCompletionEvent": { + "type": "structure", + "members": { + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Event sent from the client application to Amazon Lex V2 to indicate that\n playback of audio is complete and that Amazon Lex V2 should start processing\n the user's input.

" + } + }, + "com.amazonaws.lexruntimev2#PlaybackInterruptionEvent": { + "type": "structure", + "members": { + "eventReason": { + "target": "com.amazonaws.lexruntimev2#PlaybackInterruptionReason", + "traits": { + "smithy.api#documentation": "

Indicates the type of user input that Amazon Lex V2 detected.

" + } + }, + "causedByEventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

The identifier of the event that contained the audio, DTMF, or text\n that caused the interruption.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Event sent from Amazon Lex V2 to indicate to the client application should\n stop playback of audio. For example, if the client is playing a prompt\n that asks for the user's telephone number, the user might start to say\n the phone number before the prompt is complete. Amazon Lex V2 sends this event\n to the client application to indicate that the user is responding and\n that Amazon Lex V2 is processing their input.

" + } + }, + "com.amazonaws.lexruntimev2#PlaybackInterruptionReason": { + "type": "enum", + "members": { + "DTMF_START_DETECTED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "DTMF_START_DETECTED" + } + }, + "TEXT_DETECTED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "TEXT_DETECTED" + } + }, + "VOICE_START_DETECTED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "VOICE_START_DETECTED" + } + } + } + }, + "com.amazonaws.lexruntimev2#PutSession": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#PutSessionRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#PutSessionResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#BadGatewayException" + }, + { + "target": "com.amazonaws.lexruntimev2#ConflictException" + }, + { + "target": "com.amazonaws.lexruntimev2#DependencyFailedException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Creates a new session or modifies an existing session with an Amazon Lex V2\n bot. Use this operation to enable your application to set the state of\n the bot.

", + "smithy.api#http": { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#PutSessionRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that receives the session data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier of the bot that receives the session\n data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session that receives the session data.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "messages": { + "target": "com.amazonaws.lexruntimev2#Messages", + "traits": { + "smithy.api#documentation": "

A list of messages to send to the user. Messages are sent in the\n order that they are defined in the list.

" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState", + "traits": { + "smithy.api#documentation": "

Sets the state of the session with the user. You can use this to set\n the current intent, attributes, context, and dialog action. Use the\n dialog action to determine the next step that Amazon Lex V2 should use in the\n conversation with the user.

", + "smithy.api#required": {} + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

Request-specific information passed between Amazon Lex V2 and the client\n application.

\n

The namespace x-amz-lex: is reserved for special\n attributes. Don't create any request attributes with the prefix\n x-amz-lex:.

" + } + }, + "responseContentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The message that Amazon Lex V2 returns in the response can be either text or\n speech depending on the value of this parameter.

\n ", + "smithy.api#httpHeader": "ResponseContentType" + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#PutSessionResponse": { + "type": "structure", + "members": { + "contentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The type of response. Same as the type specified in the\n responseContentType field in the request.

", + "smithy.api#httpHeader": "Content-Type" + } + }, + "messages": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A list of messages that were last sent to the user. The messages are\n ordered based on how you return the messages from you Lambda function\n or the order that the messages are defined in the bot.

", + "smithy.api#httpHeader": "x-amz-lex-messages" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A base-64-encoded gzipped field that represents the current state of \n the dialog between the user and the bot. Use this to determine the progress \n of the conversation and what the next action may be.

", + "smithy.api#httpHeader": "x-amz-lex-session-state" + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A base-64-encoded gzipped field that provides request-specific information \n passed between the client application and Amazon Lex V2. These are the same as the \n requestAttribute parameter in the call to the \n PutSession operation.

", + "smithy.api#httpHeader": "x-amz-lex-request-attributes" + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session that received the data.

", + "smithy.api#httpHeader": "x-amz-lex-session-id" + } + }, + "audioStream": { + "target": "com.amazonaws.lexruntimev2#BlobStream", + "traits": { + "smithy.api#default": "", + "smithy.api#documentation": "

If the requested content type was audio, the audio version of the\n message to convey to the user.

", + "smithy.api#httpPayload": {} + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#RecognizeText": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#RecognizeTextRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#RecognizeTextResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#BadGatewayException" + }, + { + "target": "com.amazonaws.lexruntimev2#ConflictException" + }, + { + "target": "com.amazonaws.lexruntimev2#DependencyFailedException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Sends user input to Amazon Lex V2. Client applications use this API to send\n requests to Amazon Lex V2 at runtime. Amazon Lex V2 then interprets the user input\n using the machine learning model that it build for the bot.

\n

In response, Amazon Lex V2 returns the next message to convey to the user\n and an optional response card to display.

\n

If the optional post-fulfillment response is specified, the messages\n are returned as follows. For more information, see PostFulfillmentStatusSpecification.

\n \n

For more information, see Completion message.

", + "smithy.api#http": { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/text", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#RecognizeTextRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that processes the request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that processes the\n request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the user session that is having the\n conversation.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "text": { + "target": "com.amazonaws.lexruntimev2#Text", + "traits": { + "smithy.api#documentation": "

The text that the user entered. Amazon Lex V2 interprets this text.

", + "smithy.api#required": {} + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState", + "traits": { + "smithy.api#documentation": "

The current state of the dialog between the user and the bot.

" + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

Request-specific information passed between the client application\n and Amazon Lex V2

\n

The namespace x-amz-lex: is reserved for special\n attributes. Don't create any request attributes with the prefix\n x-amz-lex:.

" + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#RecognizeTextResponse": { + "type": "structure", + "members": { + "messages": { + "target": "com.amazonaws.lexruntimev2#Messages", + "traits": { + "smithy.api#documentation": "

A list of messages last sent to the user. The messages are ordered\n based on the order that you returned the messages from your Lambda\n function or the order that the messages are defined in the bot.

" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SessionState", + "traits": { + "smithy.api#documentation": "

Represents the current state of the dialog between the user and the\n bot.

\n

Use this to determine the progress of the conversation and what the\n next action may be.

" + } + }, + "interpretations": { + "target": "com.amazonaws.lexruntimev2#Interpretations", + "traits": { + "smithy.api#documentation": "

A list of intents that Amazon Lex V2 determined might satisfy the user's\n utterance.

\n

Each interpretation includes the intent, a score that indicates now\n confident Amazon Lex V2 is that the interpretation is the correct one, and an\n optional sentiment response that indicates the sentiment expressed in\n the utterance.

" + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

The attributes sent in the request.

" + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session in use.

" + } + }, + "recognizedBotMember": { + "target": "com.amazonaws.lexruntimev2#RecognizedBotMember", + "traits": { + "smithy.api#documentation": "

The bot member that recognized the text.

" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#RecognizeUtterance": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#RecognizeUtteranceRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#RecognizeUtteranceResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#BadGatewayException" + }, + { + "target": "com.amazonaws.lexruntimev2#ConflictException" + }, + { + "target": "com.amazonaws.lexruntimev2#DependencyFailedException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "aws.auth#unsignedPayload": {}, + "smithy.api#auth": [ + "aws.auth#sigv4" + ], + "smithy.api#documentation": "

Sends user input to Amazon Lex V2. You can send text or speech. Clients use\n this API to send text and audio requests to Amazon Lex V2 at runtime. Amazon Lex V2\n interprets the user input using the machine learning model built for\n the bot.

\n

The following request fields must be compressed with gzip and then\n base64 encoded before you send them to Amazon Lex V2.

\n \n

The following response fields are compressed using gzip and then\n base64 encoded by Amazon Lex V2. Before you can use these fields, you must\n decode and decompress them.

\n \n

The example contains a Java application that compresses and encodes\n a Java object to send to Amazon Lex V2, and a second that decodes and\n decompresses a response from Amazon Lex V2.

\n

If the optional post-fulfillment response is specified, the messages\n are returned as follows. For more information, see PostFulfillmentStatusSpecification.

\n \n

For more information, see Completion message.

", + "smithy.api#http": { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/utterance", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#RecognizeUtteranceRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot that should receive the request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that should receive the\n request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#SensitiveNonEmptyString", + "traits": { + "smithy.api#documentation": "

Sets the state of the session with the user. You can use this to set\n the current intent, attributes, context, and dialog action. Use the\n dialog action to determine the next step that Amazon Lex V2 should use in the\n conversation with the user.

\n

The sessionState field must be compressed using gzip\n and then base64 encoded before sending to Amazon Lex V2.

", + "smithy.api#httpHeader": "x-amz-lex-session-state" + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#SensitiveNonEmptyString", + "traits": { + "smithy.api#documentation": "

Request-specific information passed between the client application\n and Amazon Lex V2

\n

The namespace x-amz-lex: is reserved for special\n attributes. Don't create any request attributes for prefix\n x-amz-lex:.

\n

The requestAttributes field must be compressed using\n gzip and then base64 encoded before sending to Amazon Lex V2.

", + "smithy.api#httpHeader": "x-amz-lex-request-attributes" + } + }, + "requestContentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

Indicates the format for audio input or that the content is text.\n The header must start with one of the following prefixes:

\n ", + "smithy.api#httpHeader": "Content-Type", + "smithy.api#required": {} + } + }, + "responseContentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The message that Amazon Lex V2 returns in the response can be either text or\n speech based on the responseContentType value.

\n ", + "smithy.api#httpHeader": "Response-Content-Type" + } + }, + "inputStream": { + "target": "com.amazonaws.lexruntimev2#BlobStream", + "traits": { + "smithy.api#default": "", + "smithy.api#documentation": "

User input in PCM or Opus audio format or text format as described\n in the requestContentType parameter.

", + "smithy.api#httpPayload": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#RecognizeUtteranceResponse": { + "type": "structure", + "members": { + "inputMode": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

Indicates whether the input mode to the operation was text, speech, or from a touch-tone keypad.\n

", + "smithy.api#httpHeader": "x-amz-lex-input-mode" + } + }, + "contentType": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

Content type as specified in the responseContentType in\n the request.

", + "smithy.api#httpHeader": "Content-Type" + } + }, + "messages": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A list of messages that were last sent to the user. The messages are\n ordered based on the order that you returned the messages from your\n Lambda function or the order that the messages are defined in the\n bot.

\n

The messages field is compressed with gzip and then\n base64 encoded. Before you can use the contents of the field, you must\n decode and decompress the contents. See the example for a simple\n function to decode and decompress the contents.

", + "smithy.api#httpHeader": "x-amz-lex-messages" + } + }, + "interpretations": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A list of intents that Amazon Lex V2 determined might satisfy the user's\n utterance.

\n

Each interpretation includes the intent, a score that indicates how\n confident Amazon Lex V2 is that the interpretation is the correct one, and an\n optional sentiment response that indicates the sentiment expressed in\n the utterance.

\n

The interpretations field is compressed with gzip and\n then base64 encoded. Before you can use the contents of the field, you\n must decode and decompress the contents. See the example for a simple\n function to decode and decompress the contents.

", + "smithy.api#httpHeader": "x-amz-lex-interpretations" + } + }, + "sessionState": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

Represents the current state of the dialog between the user and the\n bot.

\n

Use this to determine the progress of the conversation and what the\n next action might be.

\n

The sessionState field is compressed with gzip and then\n base64 encoded. Before you can use the contents of the field, you must\n decode and decompress the contents. See the example for a simple\n function to decode and decompress the contents.

", + "smithy.api#httpHeader": "x-amz-lex-session-state" + } + }, + "requestAttributes": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The attributes sent in the request.

\n

The requestAttributes field is compressed with gzip and\n then base64 encoded. Before you can use the contents of the field, you\n must decode and decompress the contents.

", + "smithy.api#httpHeader": "x-amz-lex-request-attributes" + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the session in use.

", + "smithy.api#httpHeader": "x-amz-lex-session-id" + } + }, + "inputTranscript": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The text used to process the request.

\n

If the input was an audio stream, the inputTranscript\n field contains the text extracted from the audio stream. This is the\n text that is actually processed to recognize intents and slot values.\n You can use this information to determine if Amazon Lex V2 is correctly\n processing the audio that you send.

\n

The inputTranscript field is compressed with gzip and\n then base64 encoded. Before you can use the contents of the field, you\n must decode and decompress the contents. See the example for a simple\n function to decode and decompress the contents.

", + "smithy.api#httpHeader": "x-amz-lex-input-transcript" + } + }, + "audioStream": { + "target": "com.amazonaws.lexruntimev2#BlobStream", + "traits": { + "smithy.api#default": "", + "smithy.api#documentation": "

The prompt or statement to send to the user. This is based on the\n bot configuration and context. For example, if Amazon Lex V2 did not understand\n the user intent, it sends the clarificationPrompt\n configured for the bot. If the intent requires confirmation before\n taking the fulfillment action, it sends the\n confirmationPrompt. Another example: Suppose that the\n Lambda function successfully fulfilled the intent, and sent a message\n to convey to the user. Then Amazon Lex V2 sends that message in the\n response.

", + "smithy.api#httpPayload": {} + } + }, + "recognizedBotMember": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The bot member that recognized the utterance.

", + "smithy.api#httpHeader": "x-amz-lex-recognized-bot-member" + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#RecognizedBotMember": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot member that processes the request.

", + "smithy.api#required": {} + } + }, + "botName": { + "target": "com.amazonaws.lexruntimev2#Name", + "traits": { + "smithy.api#documentation": "

The name of the bot member that processes the request.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The bot member that processes the request.

" + } + }, + "com.amazonaws.lexruntimev2#ResourceNotFoundException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 404 + } + }, + "com.amazonaws.lexruntimev2#RuntimeHintDetails": { + "type": "structure", + "members": { + "runtimeHintValues": { + "target": "com.amazonaws.lexruntimev2#RuntimeHintValuesList", + "traits": { + "smithy.api#documentation": "

One or more strings that Amazon Lex V2 should look for in the input to the\n bot. Each phrase is given preference when deciding on slot\n values.

" + } + }, + "subSlotHints": { + "target": "com.amazonaws.lexruntimev2#SlotHintsSlotMap", + "traits": { + "smithy.api#documentation": "

A map of constituent sub slot names inside a composite slot in the intent and the phrases \n that should be added for each sub slot. Inside each composite slot hints, this structure provides \n a mechanism to add granular sub slot phrases. Only sub slot hints are supported for composite slots. \n The intent name, composite slot name and the constituent sub slot names must exist.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Provides an array of phrases that should be given preference when\n resolving values for a slot.

" + } + }, + "com.amazonaws.lexruntimev2#RuntimeHintPhrase": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 140 + } + } + }, + "com.amazonaws.lexruntimev2#RuntimeHintValue": { + "type": "structure", + "members": { + "phrase": { + "target": "com.amazonaws.lexruntimev2#RuntimeHintPhrase", + "traits": { + "smithy.api#documentation": "

The phrase that Amazon Lex V2 should look for in the user's input to the\n bot.

", + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

Provides the phrase that Amazon Lex V2 should look for in the user's input\n to the bot.

" + } + }, + "com.amazonaws.lexruntimev2#RuntimeHintValuesList": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#RuntimeHintValue" + }, + "traits": { + "smithy.api#length": { + "min": 1, + "max": 100 + } + } + }, + "com.amazonaws.lexruntimev2#RuntimeHints": { + "type": "structure", + "members": { + "slotHints": { + "target": "com.amazonaws.lexruntimev2#SlotHintsIntentMap", + "traits": { + "smithy.api#documentation": "

A list of the slots in the intent that should have runtime hints\n added, and the phrases that should be added for each slot.

\n

The first level of the slotHints map is the name of the\n intent. The second level is the name of the slot within the intent. For\n more information, see Using hints to improve\n accuracy.

\n

The intent name and slot name must exist.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

You can provide Amazon Lex V2 with hints to the phrases that a customer is\n likely to use for a slot. When a slot with hints is resolved, the\n phrases in the runtime hints are preferred in the resolution. You can\n provide hints for a maximum of 100 intents. You can provide a maximum\n of 100 slots.

\n

Before you can use runtime hints with an existing bot, you must\n first rebuild the bot.

\n

For more information, see Using runtime hints to\n improve recognition of slot values.

" + } + }, + "com.amazonaws.lexruntimev2#SensitiveNonEmptyString": { + "type": "string", + "traits": { + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.lexruntimev2#SentimentResponse": { + "type": "structure", + "members": { + "sentiment": { + "target": "com.amazonaws.lexruntimev2#SentimentType", + "traits": { + "smithy.api#documentation": "

The overall sentiment expressed in the user's response. This is the\n sentiment most likely expressed by the user based on the analysis by\n Amazon Comprehend.

" + } + }, + "sentimentScore": { + "target": "com.amazonaws.lexruntimev2#SentimentScore" + } + }, + "traits": { + "smithy.api#documentation": "

Provides information about the sentiment expressed in a user's\n response in a conversation. Sentiments are determined using Amazon\n Comprehend. Sentiments are only returned if they are enabled for the\n bot.

\n

For more information, see \n Determine Sentiment in the Amazon Comprehend\n developer guide.

" + } + }, + "com.amazonaws.lexruntimev2#SentimentScore": { + "type": "structure", + "members": { + "positive": { + "target": "com.amazonaws.lexruntimev2#Double", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

The level of confidence that Amazon Comprehend has in the accuracy\n of its detection of the POSITIVE sentiment.

" + } + }, + "negative": { + "target": "com.amazonaws.lexruntimev2#Double", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

The level of confidence that Amazon Comprehend has in the accuracy\n of its detection of the NEGATIVE sentiment.

" + } + }, + "neutral": { + "target": "com.amazonaws.lexruntimev2#Double", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

The level of confidence that Amazon Comprehend has in the accuracy\n of its detection of the NEUTRAL sentiment.

" + } + }, + "mixed": { + "target": "com.amazonaws.lexruntimev2#Double", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

The level of confidence that Amazon Comprehend has in the accuracy\n of its detection of the MIXED sentiment.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The individual sentiment responses for the utterance.

" + } + }, + "com.amazonaws.lexruntimev2#SentimentType": { + "type": "enum", + "members": { + "MIXED": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "MIXED" + } + }, + "NEGATIVE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "NEGATIVE" + } + }, + "NEUTRAL": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "NEUTRAL" + } + }, + "POSITIVE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "POSITIVE" + } + } + } + }, + "com.amazonaws.lexruntimev2#SessionId": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 2, + "max": 100 + }, + "smithy.api#pattern": "^[0-9a-zA-Z._:-]+$" + } + }, + "com.amazonaws.lexruntimev2#SessionState": { + "type": "structure", + "members": { + "dialogAction": { + "target": "com.amazonaws.lexruntimev2#DialogAction", + "traits": { + "smithy.api#documentation": "

The next step that Amazon Lex V2 should take in the conversation with a\n user.

" + } + }, + "intent": { + "target": "com.amazonaws.lexruntimev2#Intent", + "traits": { + "smithy.api#documentation": "

The active intent that Amazon Lex V2 is processing.

" + } + }, + "activeContexts": { + "target": "com.amazonaws.lexruntimev2#ActiveContextsList", + "traits": { + "smithy.api#documentation": "

One or more contexts that indicate to Amazon Lex V2 the context of a\n request. When a context is active, Amazon Lex V2 considers intents with the\n matching context as a trigger as the next intent in a session.

" + } + }, + "sessionAttributes": { + "target": "com.amazonaws.lexruntimev2#StringMap", + "traits": { + "smithy.api#documentation": "

Map of key/value pairs representing session-specific context\n information. It contains application information passed between Amazon Lex V2\n and a client application.

" + } + }, + "originatingRequestId": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

A unique identifier for a specific request.

" + } + }, + "runtimeHints": { + "target": "com.amazonaws.lexruntimev2#RuntimeHints", + "traits": { + "smithy.api#documentation": "

Hints for phrases that a customer is likely to use for a slot. Amazon Lex V2\n uses the hints to help determine the correct value of a slot.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The state of the user's session with Amazon Lex V2.

" + } + }, + "com.amazonaws.lexruntimev2#Shape": { + "type": "enum", + "members": { + "SCALAR": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Scalar" + } + }, + "LIST": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "List" + } + }, + "COMPOSITE": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Composite" + } + } + } + }, + "com.amazonaws.lexruntimev2#Slot": { + "type": "structure", + "members": { + "value": { + "target": "com.amazonaws.lexruntimev2#Value", + "traits": { + "smithy.api#documentation": "

The current value of the slot.

" + } + }, + "shape": { + "target": "com.amazonaws.lexruntimev2#Shape", + "traits": { + "smithy.api#documentation": "

When the shape value is List, it indicates\n that the values field contains a list of slot values. When\n the value is Scalar, it indicates that the\n value field contains a single value.

" + } + }, + "values": { + "target": "com.amazonaws.lexruntimev2#Values", + "traits": { + "smithy.api#documentation": "

A list of one or more values that the user provided for the slot.\n For example, if a for a slot that elicits pizza toppings, the values\n might be \"pepperoni\" and \"pineapple.\"

" + } + }, + "subSlots": { + "target": "com.amazonaws.lexruntimev2#Slots", + "traits": { + "smithy.api#documentation": "

The constituent sub slots of a composite slot.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

A value that Amazon Lex V2 uses to fulfill an intent.

" + } + }, + "com.amazonaws.lexruntimev2#SlotHintsIntentMap": { + "type": "map", + "key": { + "target": "com.amazonaws.lexruntimev2#Name" + }, + "value": { + "target": "com.amazonaws.lexruntimev2#SlotHintsSlotMap" + } + }, + "com.amazonaws.lexruntimev2#SlotHintsSlotMap": { + "type": "map", + "key": { + "target": "com.amazonaws.lexruntimev2#Name" + }, + "value": { + "target": "com.amazonaws.lexruntimev2#RuntimeHintDetails" + } + }, + "com.amazonaws.lexruntimev2#Slots": { + "type": "map", + "key": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString" + }, + "value": { + "target": "com.amazonaws.lexruntimev2#Slot" + } + }, + "com.amazonaws.lexruntimev2#StartConversation": { + "type": "operation", + "input": { + "target": "com.amazonaws.lexruntimev2#StartConversationRequest" + }, + "output": { + "target": "com.amazonaws.lexruntimev2#StartConversationResponse" + }, + "errors": [ + { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException" + }, + { + "target": "com.amazonaws.lexruntimev2#InternalServerException" + }, + { + "target": "com.amazonaws.lexruntimev2#ThrottlingException" + }, + { + "target": "com.amazonaws.lexruntimev2#ValidationException" + } + ], + "traits": { + "smithy.api#documentation": "

Starts an HTTP/2 bidirectional event stream that enables you to send\n audio, text, or DTMF input in real time. After your application starts\n a conversation, users send input to Amazon Lex V2 as a stream of events. Amazon Lex V2\n processes the incoming events and responds with streaming text or audio\n events. \n

\n

Audio input must be in the following format: audio/lpcm\n sample-rate=8000 sample-size-bits=16 channel-count=1;\n is-big-endian=false.

\n

If the optional post-fulfillment response is specified, the messages\n are returned as follows. For more information, see PostFulfillmentStatusSpecification.

\n \n

For more information, see Completion message.

\n

If the optional update message is configured, it is played at the\n specified frequency while the Lambda function is running and the update\n message state is active. If the fulfillment update message is not\n active, the Lambda function runs with a 30 second timeout.

\n

For more information, see Update message \n

\n

The StartConversation operation is supported only in\n the following SDKs:

\n ", + "smithy.api#http": { + "method": "POST", + "uri": "/bots/{botId}/botAliases/{botAliasId}/botLocales/{localeId}/sessions/{sessionId}/conversation", + "code": 200 + } + } + }, + "com.amazonaws.lexruntimev2#StartConversationRequest": { + "type": "structure", + "members": { + "botId": { + "target": "com.amazonaws.lexruntimev2#BotIdentifier", + "traits": { + "smithy.api#documentation": "

The identifier of the bot to process the request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "botAliasId": { + "target": "com.amazonaws.lexruntimev2#BotAliasIdentifier", + "traits": { + "smithy.api#documentation": "

The alias identifier in use for the bot that processes the\n request.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "localeId": { + "target": "com.amazonaws.lexruntimev2#LocaleId", + "traits": { + "smithy.api#documentation": "

The locale where the session is in use.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "sessionId": { + "target": "com.amazonaws.lexruntimev2#SessionId", + "traits": { + "smithy.api#documentation": "

The identifier of the user session that is having the\n conversation.

", + "smithy.api#httpLabel": {}, + "smithy.api#required": {} + } + }, + "conversationMode": { + "target": "com.amazonaws.lexruntimev2#ConversationMode", + "traits": { + "smithy.api#documentation": "

The conversation type that you are using the Amazon Lex V2. If the\n conversation mode is AUDIO you can send both audio and\n DTMF information. If the mode is TEXT you can only send\n text.

", + "smithy.api#httpHeader": "x-amz-lex-conversation-mode" + } + }, + "requestEventStream": { + "target": "com.amazonaws.lexruntimev2#StartConversationRequestEventStream", + "traits": { + "smithy.api#documentation": "

Represents the stream of events to Amazon Lex V2 from your application. The\n events are encoded as HTTP/2 data frames.

", + "smithy.api#httpPayload": {}, + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#input": {} + } + }, + "com.amazonaws.lexruntimev2#StartConversationRequestEventStream": { + "type": "union", + "members": { + "ConfigurationEvent": { + "target": "com.amazonaws.lexruntimev2#ConfigurationEvent", + "traits": { + "smithy.api#documentation": "

Configuration information sent from your client application to\n Amazon Lex V2

" + } + }, + "AudioInputEvent": { + "target": "com.amazonaws.lexruntimev2#AudioInputEvent", + "traits": { + "smithy.api#documentation": "

Speech audio sent from your client application to Amazon Lex V2. Audio\n starts accumulating when Amazon Lex V2 identifies a voice and continues until a\n natural pause in the speech is found before processing.

" + } + }, + "DTMFInputEvent": { + "target": "com.amazonaws.lexruntimev2#DTMFInputEvent", + "traits": { + "smithy.api#documentation": "

DTMF information sent to Amazon Lex V2 by your application. Amazon Lex V2\n accumulates the DMTF information from when the user sends the first\n character and ends

\n " + } + }, + "TextInputEvent": { + "target": "com.amazonaws.lexruntimev2#TextInputEvent", + "traits": { + "smithy.api#documentation": "

Text sent from your client application to Amazon Lex V2. Each\n TextInputEvent is processed individually.

" + } + }, + "PlaybackCompletionEvent": { + "target": "com.amazonaws.lexruntimev2#PlaybackCompletionEvent", + "traits": { + "smithy.api#documentation": "

Event sent from the client application to Amazon Lex V2 to indicate that it\n has finished playing audio and that Amazon Lex V2 should start listening for\n user input.

" + } + }, + "DisconnectionEvent": { + "target": "com.amazonaws.lexruntimev2#DisconnectionEvent", + "traits": { + "smithy.api#documentation": "

Event sent from the client application to indicate to Amazon Lex V2 that the\n conversation is over.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Represents a stream of events between your application and\n Amazon Lex V2.

", + "smithy.api#streaming": {} + } + }, + "com.amazonaws.lexruntimev2#StartConversationResponse": { + "type": "structure", + "members": { + "responseEventStream": { + "target": "com.amazonaws.lexruntimev2#StartConversationResponseEventStream", + "traits": { + "smithy.api#documentation": "

Represents the stream of events from Amazon Lex V2 to your application. The\n events are encoded as HTTP/2 data frames.

", + "smithy.api#httpPayload": {} + } + } + }, + "traits": { + "smithy.api#output": {} + } + }, + "com.amazonaws.lexruntimev2#StartConversationResponseEventStream": { + "type": "union", + "members": { + "PlaybackInterruptionEvent": { + "target": "com.amazonaws.lexruntimev2#PlaybackInterruptionEvent" + }, + "TranscriptEvent": { + "target": "com.amazonaws.lexruntimev2#TranscriptEvent" + }, + "IntentResultEvent": { + "target": "com.amazonaws.lexruntimev2#IntentResultEvent", + "traits": { + "smithy.api#documentation": "

Event sent from Amazon Lex V2 to the client application containing the\n current state of the conversation between the user and Amazon Lex V2.

" + } + }, + "TextResponseEvent": { + "target": "com.amazonaws.lexruntimev2#TextResponseEvent" + }, + "AudioResponseEvent": { + "target": "com.amazonaws.lexruntimev2#AudioResponseEvent" + }, + "HeartbeatEvent": { + "target": "com.amazonaws.lexruntimev2#HeartbeatEvent" + }, + "AccessDeniedException": { + "target": "com.amazonaws.lexruntimev2#AccessDeniedException", + "traits": { + "smithy.api#documentation": "

Exception thrown when the credentials passed with the request are\n invalid or expired. Also thrown when the credentials in the request do\n not have permission to access the StartConversation\n operation.

" + } + }, + "ResourceNotFoundException": { + "target": "com.amazonaws.lexruntimev2#ResourceNotFoundException", + "traits": { + "smithy.api#documentation": "

Exception thrown if one of the input parameters points to a resource\n that does not exist. For example, if the bot ID specified does not\n exist.

" + } + }, + "ValidationException": { + "target": "com.amazonaws.lexruntimev2#ValidationException", + "traits": { + "smithy.api#documentation": "

Exception thrown when one or more parameters could not be validated.\n The message contains the name of the field that isn't\n valid.

" + } + }, + "ThrottlingException": { + "target": "com.amazonaws.lexruntimev2#ThrottlingException", + "traits": { + "smithy.api#documentation": "

Exception thrown when your application exceeds the maximum number of\n concurrent requests.

" + } + }, + "InternalServerException": { + "target": "com.amazonaws.lexruntimev2#InternalServerException", + "traits": { + "smithy.api#documentation": "

An error occurred with Amazon Lex V2.

" + } + }, + "ConflictException": { + "target": "com.amazonaws.lexruntimev2#ConflictException", + "traits": { + "smithy.api#documentation": "

Exception thrown when two clients are using the same AWS account,\n Amazon Lex V2 bot, and session ID.

" + } + }, + "DependencyFailedException": { + "target": "com.amazonaws.lexruntimev2#DependencyFailedException" + }, + "BadGatewayException": { + "target": "com.amazonaws.lexruntimev2#BadGatewayException" + } + }, + "traits": { + "smithy.api#documentation": "

Represents a stream of events between Amazon Lex V2 and your\n application.

", + "smithy.api#streaming": {} + } + }, + "com.amazonaws.lexruntimev2#String": { + "type": "string" + }, + "com.amazonaws.lexruntimev2#StringList": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString" + } + }, + "com.amazonaws.lexruntimev2#StringMap": { + "type": "map", + "key": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString" + }, + "value": { + "target": "com.amazonaws.lexruntimev2#String" + } + }, + "com.amazonaws.lexruntimev2#StyleType": { + "type": "enum", + "members": { + "DEFAULT": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "Default" + } + }, + "SPELL_BY_LETTER": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "SpellByLetter" + } + }, + "SPELL_BY_WORD": { + "target": "smithy.api#Unit", + "traits": { + "smithy.api#enumValue": "SpellByWord" + } + } + } + }, + "com.amazonaws.lexruntimev2#Text": { + "type": "string", + "traits": { + "smithy.api#length": { + "min": 1, + "max": 1024 + }, + "smithy.api#sensitive": {} + } + }, + "com.amazonaws.lexruntimev2#TextInputEvent": { + "type": "structure", + "members": { + "text": { + "target": "com.amazonaws.lexruntimev2#Text", + "traits": { + "smithy.api#documentation": "

The text from the user. Amazon Lex V2 processes this as a complete\n statement.

", + "smithy.api#required": {} + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier that your application assigns to the event. You\n can use this to identify events in logs.

" + } + }, + "clientTimestampMillis": { + "target": "com.amazonaws.lexruntimev2#EpochMillis", + "traits": { + "smithy.api#default": 0, + "smithy.api#documentation": "

A timestamp set by the client of the date and time that the event\n was sent to Amazon Lex V2.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The event sent from your client application to Amazon Lex V2 with text input\n from the user.

" + } + }, + "com.amazonaws.lexruntimev2#TextResponseEvent": { + "type": "structure", + "members": { + "messages": { + "target": "com.amazonaws.lexruntimev2#Messages", + "traits": { + "smithy.api#documentation": "

A list of messages to send to the user. Messages are ordered based\n on the order that you returned the messages from your Lambda function\n or the order that the messages are defined in the bot.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

The event sent from Amazon Lex V2 to your application with text to present\n to the user.

" + } + }, + "com.amazonaws.lexruntimev2#ThrottlingException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 429 + } + }, + "com.amazonaws.lexruntimev2#TranscriptEvent": { + "type": "structure", + "members": { + "transcript": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#documentation": "

The transcript of the voice audio from the user.

" + } + }, + "eventId": { + "target": "com.amazonaws.lexruntimev2#EventId", + "traits": { + "smithy.api#documentation": "

A unique identifier of the event sent by Amazon Lex V2. The identifier is in\n the form RESPONSE-N, where N is a number starting with one\n and incremented for each event sent by Amazon Lex V2 in the current\n session.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Event sent from Amazon Lex V2 to your client application that contains a\n transcript of voice audio.

" + } + }, + "com.amazonaws.lexruntimev2#ValidationException": { + "type": "structure", + "members": { + "message": { + "target": "com.amazonaws.lexruntimev2#String", + "traits": { + "smithy.api#required": {} + } + } + }, + "traits": { + "smithy.api#documentation": "

", + "smithy.api#error": "client", + "smithy.api#httpError": 400 + } + }, + "com.amazonaws.lexruntimev2#Value": { + "type": "structure", + "members": { + "originalValue": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The part of the user's response to the slot elicitation that Amazon Lex V2 determines is relevant to the slot value.

" + } + }, + "interpretedValue": { + "target": "com.amazonaws.lexruntimev2#NonEmptyString", + "traits": { + "smithy.api#documentation": "

The value that Amazon Lex V2 determines for the slot, given the user input. The actual value depends on the setting of the value selection strategy for the bot. You can choose to use the value entered by the user, or you can have Amazon Lex V2 choose the first value in the resolvedValues list.

", + "smithy.api#required": {} + } + }, + "resolvedValues": { + "target": "com.amazonaws.lexruntimev2#StringList", + "traits": { + "smithy.api#documentation": "

A list of values that Amazon Lex V2 determines are possible resolutions for the user input. The first value matches the interpretedValue.

" + } + } + }, + "traits": { + "smithy.api#documentation": "

Information about the value provided for a slot and Amazon Lex V2's interpretation.

" + } + }, + "com.amazonaws.lexruntimev2#Values": { + "type": "list", + "member": { + "target": "com.amazonaws.lexruntimev2#Slot" + } + } + } +} \ No newline at end of file