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

from __future__ import annotations

from enum import Enum
from typing import Any, Literal, Optional, Union

from pydantic import BaseModel, ConfigDict, Field, RootModel, conint, constr


class CommonDefinitions(BaseModel):
    pass


class TestCase(BaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    scenario: str
    run: Optional[str] = None
    with_: Optional[dict[str, Any]] = Field(None, alias='with')
    expect: Optional[list[str]] = None
    timeout_seconds: Optional[conint(ge=1)] = Field(
        None, description='Optional per-scenario timeout in seconds'
    )
    services: Optional[list[str]] = Field(
        None, description="Logical services this test exercises (e.g. ['users','orders'])"
    )


class ServiceProvisioningOverrides(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    env: Optional[dict[str, str]] = None
    health_endpoint: Optional[str] = None
    wait_timeout_seconds: Optional[conint(ge=1)] = None


class ResourceProvisionRequest(BaseModel):
    kind: str
    name: Optional[str] = None
    config: Optional[dict[str, Any]] = None


class Status(Enum):
    pending = 'pending'
    in_progress = 'in-progress'
    done = 'done'
    blocked = 'blocked'


class TodoItem(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    description: str
    status: Status
    owner: Optional[str] = None
    tags: Optional[list[str]] = None
    link: Optional[str] = None


class Todo(RootModel[list[TodoItem]]):
    root: list[TodoItem]


class Duration(RootModel[constr(pattern=r'^(?:[0-9]+(?:\.[0-9]+)?)(ms|s|m|h|d)$')]):
    root: constr(pattern=r'^(?:[0-9]+(?:\.[0-9]+)?)(ms|s|m|h|d)$')


class Action(BaseModel):
    model_config = ConfigDict(
        extra='allow',
    )
    name: Optional[str] = None
    uses: Union[
        constr(pattern=r'^(component://|workflow://|process://|library://|knot0/).+'),
        constr(pattern=r'^\.{1,2}/.+$'),
    ]
    with_: Optional[dict[str, Any]] = Field(None, alias='with')


class PostgresDBResource(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    type: Literal['PostgresDB']
    connection_string: str


class ObjectStoreResource(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    type: Literal['ObjectStore']
    endpoint_url: str
    bucket: str
    access_key: str
    secret_key: str
    region: Optional[str] = None


class VectorDBResource(BaseModel):
    model_config = ConfigDict(
        extra='forbid',
    )
    type: Literal['VectorDB']
    provider: str
    api_key: str
    environment: Optional[str] = None
    index_name: Optional[str] = None


class Resource(RootModel[Union[PostgresDBResource, ObjectStoreResource, VectorDBResource]]):
    root: Union[PostgresDBResource, ObjectStoreResource, VectorDBResource]
