from __future__ import annotations
# Code generated by smithy-python-codegen DO NOT EDIT.

from dataclasses import dataclass
import logging
from typing import Any, ClassVar, Literal, Self, Union

from smithy_core.deserializers import ShapeDeserializer
from smithy_core.documents import TypeRegistry
from smithy_core.exceptions import SmithyException
from smithy_core.schemas import APIOperation, Schema
from smithy_core.serializers import ShapeSerializer
from smithy_core.shapes import ShapeID

from ._private.schemas import (
    ACTION_VALUE as _SCHEMA_ACTION_VALUE,
    FORBIDDEN_EXCEPTION as _SCHEMA_FORBIDDEN_EXCEPTION,
    OBSERVATION_VALUE as _SCHEMA_OBSERVATION_VALUE,
    QUERY_AGENT as _SCHEMA_QUERY_AGENT,
    QUERY_AGENT_INPUT as _SCHEMA_QUERY_AGENT_INPUT,
    QUERY_AGENT_OUTPUT as _SCHEMA_QUERY_AGENT_OUTPUT,
    UNAUTHORIZED_EXCEPTION as _SCHEMA_UNAUTHORIZED_EXCEPTION,
    VALIDATION_EXCEPTION as _SCHEMA_VALIDATION_EXCEPTION,
    VALIDATION_EXCEPTION_FIELD as _SCHEMA_VALIDATION_EXCEPTION_FIELD,
    VIBE_VALIDATION_EXCEPTION as _SCHEMA_VIBE_VALIDATION_EXCEPTION,
)



logger = logging.getLogger(__name__)

class ServiceError(SmithyException):
    """Base error for all errors in the service."""
    pass

@dataclass
class ApiError(ServiceError):
    """Base error for all API errors in the service."""
    code: ClassVar[str]
    fault: ClassVar[Literal["client", "server"]]

    message: str

    def __post_init__(self) -> None:
        super().__init__(self.message)

@dataclass
class UnknownApiError(ApiError):
    """Error representing any unknown api errors."""
    code: ClassVar[str] = 'Unknown'
    fault: ClassVar[Literal["client", "server"]] = "client"

@dataclass(kw_only=True)
class ValidationExceptionField:
    """
    Describes one specific validation failure for an input member.

    :param path:
        **[Required]** - A JSONPointer expression to the structure member whose value
        failed to satisfy the modeled constraints.

    :param message:
        **[Required]** - A detailed description of the validation failure.

    """

    path: str

    message: str

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_VALIDATION_EXCEPTION_FIELD, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(_SCHEMA_VALIDATION_EXCEPTION_FIELD.members["path"], self.path)
        serializer.write_string(_SCHEMA_VALIDATION_EXCEPTION_FIELD.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["path"] = de.read_string(_SCHEMA_VALIDATION_EXCEPTION_FIELD.members["path"])

                case 1:
                    kwargs["message"] = de.read_string(_SCHEMA_VALIDATION_EXCEPTION_FIELD.members["message"])

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_VALIDATION_EXCEPTION_FIELD, consumer=_consumer)
        return kwargs

def _serialize_validation_exception_field_list(serializer: ShapeSerializer, schema: Schema, value: list[ValidationExceptionField]) -> 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_validation_exception_field_list(deserializer: ShapeDeserializer, schema: Schema) -> list[ValidationExceptionField]:
    result: list[ValidationExceptionField] = []
    def _read_value(d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result.append(ValidationExceptionField.deserialize(d))
    deserializer.read_list(schema, _read_value)
    return result

@dataclass(kw_only=True)
class ValidationException(ApiError):
    """
    A standard error for input validation failures. This should be thrown by
    services when a member of the input structure falls outside of the modeled or
    documented constraints.

    :param message: A message associated with the specific error.

    :param field_list:
         A list of specific failures encountered while validating the input. A member can
         appear in this list more than once if it failed to satisfy multiple constraints.

    """

    code: ClassVar[str] = "ValidationException"
    fault: ClassVar[Literal["client", "server"]] = "client"

    message: str
    field_list: list[ValidationExceptionField] | None = None

    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)
        if self.field_list is not None:
            _serialize_validation_exception_field_list(serializer, _SCHEMA_VALIDATION_EXCEPTION.members["fieldList"], self.field_list)

    @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 1:
                    kwargs["field_list"] = _deserialize_validation_exception_field_list(de, _SCHEMA_VALIDATION_EXCEPTION.members["fieldList"])

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_VALIDATION_EXCEPTION, consumer=_consumer)
        return kwargs

def _serialize_float_list(serializer: ShapeSerializer, schema: Schema, value: list[float]) -> None:
    member_schema = schema.members["member"]
    with serializer.begin_list(schema, len(value)) as ls:
        for e in value:
            ls.write_float(member_schema, e)

def _deserialize_float_list(deserializer: ShapeDeserializer, schema: Schema) -> list[float]:
    result: list[float] = []
    member_schema = schema.members["member"]
    def _read_value(d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result.append(d.read_float(member_schema))
    deserializer.read_list(schema, _read_value)
    return result

def _serialize_float_list_list(serializer: ShapeSerializer, schema: Schema, value: list[list[float]]) -> None:
    member_schema = schema.members["member"]
    with serializer.begin_list(schema, len(value)) as ls:
        for e in value:
            _serialize_float_list(ls, member_schema, e)

def _deserialize_float_list_list(deserializer: ShapeDeserializer, schema: Schema) -> list[list[float]]:
    result: list[list[float]] = []
    member_schema = schema.members["member"]
    def _read_value(d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result.append(_deserialize_float_list(d, member_schema))
    deserializer.read_list(schema, _read_value)
    return result

def _serialize_boolean_list(serializer: ShapeSerializer, schema: Schema, value: list[bool]) -> None:
    member_schema = schema.members["member"]
    with serializer.begin_list(schema, len(value)) as ls:
        for e in value:
            ls.write_boolean(member_schema, e)

def _deserialize_boolean_list(deserializer: ShapeDeserializer, schema: Schema) -> list[bool]:
    result: list[bool] = []
    member_schema = schema.members["member"]
    def _read_value(d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result.append(d.read_boolean(member_schema))
    deserializer.read_list(schema, _read_value)
    return result

def _serialize_integer_list(serializer: ShapeSerializer, schema: Schema, value: list[int]) -> None:
    member_schema = schema.members["member"]
    with serializer.begin_list(schema, len(value)) as ls:
        for e in value:
            ls.write_integer(member_schema, e)

def _deserialize_integer_list(deserializer: ShapeDeserializer, schema: Schema) -> list[int]:
    result: list[int] = []
    member_schema = schema.members["member"]
    def _read_value(d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result.append(d.read_integer(member_schema))
    deserializer.read_list(schema, _read_value)
    return result

@dataclass(kw_only=True)
class ForbiddenException(ApiError):

    code: ClassVar[str] = "ForbiddenException"
    fault: ClassVar[Literal["client", "server"]] = "client"

    message: str

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_FORBIDDEN_EXCEPTION, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(_SCHEMA_FORBIDDEN_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_FORBIDDEN_EXCEPTION.members["message"])

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_FORBIDDEN_EXCEPTION, consumer=_consumer)
        return kwargs

@dataclass(kw_only=True)
class UnauthorizedException(ApiError):

    code: ClassVar[str] = "UnauthorizedException"
    fault: ClassVar[Literal["client", "server"]] = "client"

    message: str

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_UNAUTHORIZED_EXCEPTION, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(_SCHEMA_UNAUTHORIZED_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_UNAUTHORIZED_EXCEPTION.members["message"])

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_UNAUTHORIZED_EXCEPTION, consumer=_consumer)
        return kwargs

@dataclass(kw_only=True)
class VibeValidationException(ApiError):

    code: ClassVar[str] = "VibeValidationException"
    fault: ClassVar[Literal["client", "server"]] = "client"

    message: str

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_VIBE_VALIDATION_EXCEPTION, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_string(_SCHEMA_VIBE_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_VIBE_VALIDATION_EXCEPTION.members["message"])

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_VIBE_VALIDATION_EXCEPTION, consumer=_consumer)
        return kwargs

@dataclass
class ObservationValueDiscrete:

    value: int

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_integer(_SCHEMA_OBSERVATION_VALUE.members["discrete"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=deserializer.read_integer(_SCHEMA_OBSERVATION_VALUE.members["discrete"]))

@dataclass
class ObservationValueContinuous:

    value: list[float]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_float_list(serializer, _SCHEMA_OBSERVATION_VALUE.members["continuous"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_float_list(deserializer, _SCHEMA_OBSERVATION_VALUE.members["continuous"]))

@dataclass
class ObservationValueMultiDiscrete:

    value: list[int]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_integer_list(serializer, _SCHEMA_OBSERVATION_VALUE.members["multiDiscrete"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_integer_list(deserializer, _SCHEMA_OBSERVATION_VALUE.members["multiDiscrete"]))

@dataclass
class ObservationValueMultiBinary:

    value: list[bool]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_boolean_list(serializer, _SCHEMA_OBSERVATION_VALUE.members["multiBinary"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_boolean_list(deserializer, _SCHEMA_OBSERVATION_VALUE.members["multiBinary"]))

@dataclass
class ObservationValueBox:

    value: list[list[float]]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_float_list_list(serializer, _SCHEMA_OBSERVATION_VALUE.members["box"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_float_list_list(deserializer, _SCHEMA_OBSERVATION_VALUE.members["box"]))

@dataclass
class ObservationValueDict:

    value: dict[str, ObservationValue]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_OBSERVATION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_value_map(serializer, _SCHEMA_OBSERVATION_VALUE.members["dict"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_value_map(deserializer, _SCHEMA_OBSERVATION_VALUE.members["dict"]))

@dataclass
class ObservationValueUnknown:
    """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 SmithyException("Unknown union variants may not be serialized.")

    def serialize_members(self, serializer: ShapeSerializer):
        raise SmithyException("Unknown union variants may not be serialized.")

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        raise NotImplementedError()

ObservationValue = Union[ObservationValueDiscrete | ObservationValueContinuous | ObservationValueMultiDiscrete | ObservationValueMultiBinary | ObservationValueBox | ObservationValueDict | ObservationValueUnknown]

class _ObservationValueDeserializer:
    _result: ObservationValue | None = None

    def deserialize(self, deserializer: ShapeDeserializer) -> ObservationValue:
        self._result = None
        deserializer.read_struct(_SCHEMA_OBSERVATION_VALUE, self._consumer)

        if self._result is None:
            raise SmithyException("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(ObservationValueDiscrete.deserialize(de))

            case 1:
                self._set_result(ObservationValueContinuous.deserialize(de))

            case 2:
                self._set_result(ObservationValueMultiDiscrete.deserialize(de))

            case 3:
                self._set_result(ObservationValueMultiBinary.deserialize(de))

            case 4:
                self._set_result(ObservationValueBox.deserialize(de))

            case 5:
                self._set_result(ObservationValueDict.deserialize(de))

            case _:
                logger.debug("Unexpected member schema: %s", schema)

    def _set_result(self, value: ObservationValue) -> None:
        if self._result is not None:
            raise SmithyException("Unions must have exactly one value, but found more than one.")
        self._result = value

def _serialize_value_map(serializer: ShapeSerializer, schema: Schema, value: dict[str, ObservationValue]) -> 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_value_map(deserializer: ShapeDeserializer, schema: Schema) -> dict[str, ObservationValue]:
    result: dict[str, ObservationValue] = {}
    value_schema = schema.members["value"]
    def _read_value(k: str, d: ShapeDeserializer):
        if d.is_null():
            d.read_null()

        else:
            result[k] = _ObservationValueDeserializer().deserialize(d)
    deserializer.read_map(schema, _read_value)
    return result

@dataclass
class ActionValueDiscrete:

    value: int

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_integer(_SCHEMA_ACTION_VALUE.members["discrete"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=deserializer.read_integer(_SCHEMA_ACTION_VALUE.members["discrete"]))

@dataclass
class ActionValueContinuous:

    value: list[float]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_float_list(serializer, _SCHEMA_ACTION_VALUE.members["continuous"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_float_list(deserializer, _SCHEMA_ACTION_VALUE.members["continuous"]))

@dataclass
class ActionValueMultiDiscrete:

    value: list[int]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_integer_list(serializer, _SCHEMA_ACTION_VALUE.members["multiDiscrete"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_integer_list(deserializer, _SCHEMA_ACTION_VALUE.members["multiDiscrete"]))

@dataclass
class ActionValueMultiBinary:

    value: list[bool]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_boolean_list(serializer, _SCHEMA_ACTION_VALUE.members["multiBinary"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_boolean_list(deserializer, _SCHEMA_ACTION_VALUE.members["multiBinary"]))

@dataclass
class ActionValueBox:

    value: list[list[float]]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_float_list_list(serializer, _SCHEMA_ACTION_VALUE.members["box"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_float_list_list(deserializer, _SCHEMA_ACTION_VALUE.members["box"]))

@dataclass
class ActionValueDict:

    value: dict[str, ObservationValue]

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_ACTION_VALUE, self)

    def serialize_members(self, serializer: ShapeSerializer):
        _serialize_value_map(serializer, _SCHEMA_ACTION_VALUE.members["dict"], self.value)

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        return cls(value=_deserialize_value_map(deserializer, _SCHEMA_ACTION_VALUE.members["dict"]))

@dataclass
class ActionValueUnknown:
    """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 SmithyException("Unknown union variants may not be serialized.")

    def serialize_members(self, serializer: ShapeSerializer):
        raise SmithyException("Unknown union variants may not be serialized.")

    @classmethod
    def deserialize(cls, deserializer: ShapeDeserializer) -> Self:
        raise NotImplementedError()

ActionValue = Union[ActionValueDiscrete | ActionValueContinuous | ActionValueMultiDiscrete | ActionValueMultiBinary | ActionValueBox | ActionValueDict | ActionValueUnknown]

class _ActionValueDeserializer:
    _result: ActionValue | None = None

    def deserialize(self, deserializer: ShapeDeserializer) -> ActionValue:
        self._result = None
        deserializer.read_struct(_SCHEMA_ACTION_VALUE, self._consumer)

        if self._result is None:
            raise SmithyException("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(ActionValueDiscrete.deserialize(de))

            case 1:
                self._set_result(ActionValueContinuous.deserialize(de))

            case 2:
                self._set_result(ActionValueMultiDiscrete.deserialize(de))

            case 3:
                self._set_result(ActionValueMultiBinary.deserialize(de))

            case 4:
                self._set_result(ActionValueBox.deserialize(de))

            case 5:
                self._set_result(ActionValueDict.deserialize(de))

            case _:
                logger.debug("Unexpected member schema: %s", schema)

    def _set_result(self, value: ActionValue) -> None:
        if self._result is not None:
            raise SmithyException("Unions must have exactly one value, but found more than one.")
        self._result = value

@dataclass(kw_only=True)
class QueryAgentInput:

    experiment_id: str | None = None
    observations: 'ObservationValue | None' = None

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_QUERY_AGENT_INPUT, self)

    def serialize_members(self, serializer: ShapeSerializer):
        if self.observations is not None:
            serializer.write_struct(_SCHEMA_QUERY_AGENT_INPUT.members["observations"], self.observations)

    @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["experiment_id"] = de.read_string(_SCHEMA_QUERY_AGENT_INPUT.members["experimentId"])

                case 1:
                    kwargs["observations"] = _ObservationValueDeserializer().deserialize(de)

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_QUERY_AGENT_INPUT, consumer=_consumer)
        return kwargs

@dataclass(kw_only=True)
class QueryAgentOutput:

    actions: 'ActionValue'

    def serialize(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_QUERY_AGENT_OUTPUT, self)

    def serialize_members(self, serializer: ShapeSerializer):
        serializer.write_struct(_SCHEMA_QUERY_AGENT_OUTPUT.members["actions"], self.actions)

    @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["actions"] = _ActionValueDeserializer().deserialize(de)

                case _:
                    logger.debug("Unexpected member schema: %s", schema)

        deserializer.read_struct(_SCHEMA_QUERY_AGENT_OUTPUT, consumer=_consumer)
        return kwargs

QUERY_AGENT = APIOperation(
        input = QueryAgentInput,
        output = QueryAgentOutput,
        schema = _SCHEMA_QUERY_AGENT,
        input_schema = _SCHEMA_QUERY_AGENT_INPUT,
        output_schema = _SCHEMA_QUERY_AGENT_OUTPUT,
        error_registry = TypeRegistry({
            ShapeID("vibe.astar.public.api.shared#UnauthorizedException"): UnauthorizedException,
ShapeID("smithy.framework#ValidationException"): ValidationException,
ShapeID("vibe.astar.public.api.shared#VibeValidationException"): VibeValidationException,
ShapeID("vibe.astar.public.api.shared#ForbiddenException"): ForbiddenException,
        }),
        effective_auth_schemes = [
            ShapeID("smithy.api#noAuth")
        ]
)
