# generated by datamodel-codegen:
#   filename:  a2a.json

from __future__ import annotations

from datetime import datetime
from enum import Enum
from typing import Any, Dict, List, Optional, Union

from pydantic import BaseModel, Field


class A2AProtocolSchema(BaseModel):
    __root__: Any = Field(..., title='A2A Protocol Schema')
    """
    JSON Schema for A2A Protocol
    """


class AgentAuthentication(BaseModel):
    schemes: List[str] = Field(..., title='Schemes')
    credentials: Optional[str] = Field(None, title='Credentials')


class AgentCapabilities(BaseModel):
    streaming: Optional[bool] = Field(False, title='Streaming')
    pushNotifications: Optional[bool] = Field(False, title='PushNotifications')
    stateTransitionHistory: Optional[bool] = Field(
        False, title='Statetransitionhistory'
    )


class AgentProvider(BaseModel):
    organization: str = Field(..., title='Organization')
    url: Optional[str] = Field(None, title='Url')


class AgentSkill(BaseModel):
    id: str = Field(..., title='Id')
    name: str = Field(..., title='Name')
    description: Optional[str] = Field(None, title='Description')
    tags: Optional[List[str]] = Field(None, title='Tags')
    examples: Optional[List[str]] = Field(None, title='Examples')
    inputModes: Optional[List[str]] = Field(None, title='Inputmodes')
    outputModes: Optional[List[str]] = Field(None, title='Outputmodes')


class AuthenticationInfo(BaseModel):
    schemes: List[str] = Field(..., title='Schemes')
    credentials: Optional[str] = Field(None, title='Credentials')


class PushNotificationNotSupportedError(BaseModel):
    code: int = Field(-32003, const=True, examples=[-32003], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Push Notification is not supported',
        const=True,
        examples=['Push Notification is not supported'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Any = Field(None, const=True, title='Data')


class DataPart(BaseModel):
    type: str = Field('data', const=True, examples=['data'], title='Type')
    """
    Type of the part
    """
    data: Dict[str, Any] = Field(..., title='Data')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class FileContent(BaseModel):
    """
    Represents the content of a file, either as base64 encoded bytes or a URI.

    Ensures that either 'bytes' or 'uri' is provided, but not both.
    """

    name: Optional[str] = Field(None, title='Name')
    mimeType: Optional[str] = Field(None, title='Mimetype')
    bytes: Optional[str] = Field(None, title='Bytes')
    uri: Optional[str] = Field(None, title='Uri')


class FilePart(BaseModel):
    type: str = Field('file', const=True, examples=['file'], title='Type')
    """
    Type of the part
    """
    file: FileContent
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class InternalError(BaseModel):
    code: int = Field(-32603, const=True, examples=[-32603], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Internal error', const=True, examples=['Internal error'], title='Message'
    )
    """
    A short description of the error
    """
    data: Optional[Dict[str, Any]] = Field(None, title='Data')


class InvalidParamsError(BaseModel):
    code: int = Field(-32602, const=True, examples=[-32602], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Invalid parameters',
        const=True,
        examples=['Invalid parameters'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Optional[Dict[str, Any]] = Field(None, title='Data')


class InvalidRequestError(BaseModel):
    code: int = Field(-32600, const=True, examples=[-32600], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Request payload validation error',
        const=True,
        examples=['Request payload validation error'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Optional[Dict[str, Any]] = Field(None, title='Data')


class JSONParseError(BaseModel):
    code: int = Field(-32700, const=True, examples=[-32700], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Invalid JSON payload',
        const=True,
        examples=['Invalid JSON payload'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Optional[Dict[str, Any]] = Field(None, title='Data')


class JSONRPCError(BaseModel):
    code: int = Field(..., title='Code')
    message: str = Field(..., title='Message')
    data: Optional[Dict[str, Any]] = Field(None, title='Data')


class JSONRPCMessage(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')


class JSONRPCRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field(..., title='Method')
    params: Optional[Dict[str, Any]] = Field(None, title='Params')


class JSONRPCResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[Dict[str, Any]] = Field(None, title='Result')
    error: Optional[JSONRPCError] = None


class Role(Enum):
    user = 'user'
    agent = 'agent'


class MethodNotFoundError(BaseModel):
    code: int = Field(-32601, const=True, examples=[-32601], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Method not found', const=True, examples=['Method not found'], title='Message'
    )
    """
    A short description of the error
    """
    data: Any = Field(None, const=True, title='Data')


class PushNotificationConfig(BaseModel):
    url: str = Field(..., title='Url')
    token: Optional[str] = Field(None, title='Token')
    authentication: Optional[AuthenticationInfo] = None


class TaskPushNotificationConfig(BaseModel):
    id: str = Field(..., title='Id')
    pushNotificationConfig: PushNotificationConfig


class TaskNotCancelableError(BaseModel):
    code: int = Field(-32002, const=True, examples=[-32002], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Task cannot be canceled',
        const=True,
        examples=['Task cannot be canceled'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Any = Field(None, const=True, title='Data')


class TaskNotFoundError(BaseModel):
    code: int = Field(-32001, const=True, examples=[-32001], title='Code')
    """
    Error code
    """
    message: str = Field(
        'Task not found', const=True, examples=['Task not found'], title='Message'
    )
    """
    A short description of the error
    """
    data: Any = Field(None, const=True, title='Data')


class TaskIdParams(BaseModel):
    id: str = Field(..., title='Id')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class TaskQueryParams(BaseModel):
    id: str = Field(..., title='Id')
    historyLength: Optional[int] = Field(None, title='HistoryLength')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class TaskState(Enum):
    """
    An enumeration.
    """

    submitted = 'submitted'
    working = 'working'
    input_required = 'input-required'
    completed = 'completed'
    canceled = 'canceled'
    failed = 'failed'
    unknown = 'unknown'


class TaskResubscriptionRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/resubscribe', const=True, title='Method')
    params: TaskQueryParams


class TextPart(BaseModel):
    type: str = Field('text', const=True, examples=['text'], title='Type')
    """
    Type of the part
    """
    text: str = Field(..., title='Text')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class UnsupportedOperationError(BaseModel):
    code: int = Field(-32004, const=True, examples=[-32004], title='Code')
    """
    Error code
    """
    message: str = Field(
        'This operation is not supported',
        const=True,
        examples=['This operation is not supported'],
        title='Message',
    )
    """
    A short description of the error
    """
    data: Any = Field(None, const=True, title='Data')


class AgentCard(BaseModel):
    name: str = Field(..., title='Name')
    description: Optional[str] = Field(None, title='Description')
    url: str = Field(..., title='Url')
    provider: Optional[AgentProvider] = None
    version: str = Field(..., title='Version')
    documentationUrl: Optional[str] = Field(None, title='Documentationurl')
    capabilities: AgentCapabilities
    authentication: Optional[AgentAuthentication] = None
    defaultInputModes: Optional[List[str]] = Field(['text'], title='Defaultinputmodes')
    defaultOutputModes: Optional[List[str]] = Field(
        ['text'], title='Defaultoutputmodes'
    )
    skills: List[AgentSkill] = Field(..., title='Skills')


class CancelTaskRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/cancel', const=True, title='Method')
    params: TaskIdParams


class GetTaskPushNotificationRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/pushNotification/get', const=True, title='Method')
    params: TaskIdParams


class GetTaskPushNotificationResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[TaskPushNotificationConfig] = None
    error: Optional[JSONRPCError] = None


class GetTaskRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/get', const=True, title='Method')
    params: TaskQueryParams


class Part(BaseModel):
    __root__: Union[TextPart, FilePart, DataPart] = Field(..., title='Part')


class SetTaskPushNotificationRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/pushNotification/set', const=True, title='Method')
    params: TaskPushNotificationConfig


class SetTaskPushNotificationResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[TaskPushNotificationConfig] = None
    error: Optional[JSONRPCError] = None


class Artifact(BaseModel):
    name: Optional[str] = Field(None, title='Name')
    description: Optional[str] = Field(None, title='Description')
    parts: List[Part] = Field(..., title='Parts')
    index: Optional[int] = Field(0, title='Index')
    append: Optional[bool] = Field(None, title='Append')
    lastChunk: Optional[bool] = Field(None, title='LastChunk')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class Message(BaseModel):
    role: Role = Field(..., title='Role')
    parts: List[Part] = Field(..., title='Parts')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class TaskSendParams(BaseModel):
    id: str = Field(..., title='Id')
    sessionId: Optional[str] = Field(None, title='Sessionid')
    message: Message
    pushNotification: Optional[PushNotificationConfig] = None
    historyLength: Optional[int] = Field(None, title='HistoryLength')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class TaskStatus(BaseModel):
    state: TaskState
    message: Optional[Message] = None
    timestamp: Optional[datetime] = Field(None, title='Timestamp')


class TaskStatusUpdateEvent(BaseModel):
    id: str = Field(..., title='Id')
    status: TaskStatus
    final: Optional[bool] = Field(False, title='Final')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class TaskArtifactUpdateEvent(BaseModel):
    id: str = Field(..., title='Id')
    artifact: Artifact
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class SendTaskRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/send', const=True, title='Method')
    params: TaskSendParams


class SendTaskStreamingRequest(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    method: str = Field('tasks/sendSubscribe', const=True, title='Method')
    params: TaskSendParams


class SendTaskStreamingResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[Union[TaskStatusUpdateEvent, TaskArtifactUpdateEvent]] = None
    error: Optional[JSONRPCError] = None


class Task(BaseModel):
    id: str = Field(..., title='Id')
    sessionId: Optional[str] = Field(None, title='Sessionid')
    status: TaskStatus
    artifacts: Optional[List[Artifact]] = Field(None, title='Artifacts')
    history: Optional[List[Message]] = Field(None, title='History')
    metadata: Optional[Dict[str, Any]] = Field(None, title='Metadata')


class A2ARequest(BaseModel):
    __root__: Union[
        SendTaskRequest,
        GetTaskRequest,
        CancelTaskRequest,
        SetTaskPushNotificationRequest,
        GetTaskPushNotificationRequest,
        TaskResubscriptionRequest,
    ] = Field(..., title='A2ARequest')


class CancelTaskResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None


class GetTaskResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None


class SendTaskResponse(BaseModel):
    jsonrpc: str = Field('2.0', const=True, title='Jsonrpc')
    id: Optional[Union[int, str]] = Field(None, title='Id')
    result: Optional[Task] = None
    error: Optional[JSONRPCError] = None
