# ruff: noqa
# generated by datamodel-codegen:
#   filename:  https://api.glassflow.dev/v1/openapi.yaml
#   version:   0.26.0

from __future__ import annotations
from dataclasses_json import dataclass_json

from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, List, Optional, Union


@dataclass_json
@dataclass
class Error:
    detail: str


@dataclass_json
@dataclass
class CreateOrganization:
    name: str


@dataclass_json
@dataclass
class Organization(CreateOrganization):
    id: str


@dataclass_json
@dataclass
class OrganizationScope(Organization):
    role: str


OrganizationScopes = List[OrganizationScope]


@dataclass_json
@dataclass
class SignUp:
    access_token: str
    id_token: str


@dataclass_json
@dataclass
class BasePipeline:
    name: str
    space_id: str
    metadata: Dict[str, Any]


class PipelineState(str, Enum):
    running = "running"
    paused = "paused"


@dataclass_json
@dataclass
class FunctionEnvironment:
    name: str
    value: str


FunctionEnvironments = Optional[List[FunctionEnvironment]]


class Kind(str, Enum):
    google_pubsub = "google_pubsub"


@dataclass_json
@dataclass
class Config:
    project_id: str
    subscription_id: str
    credentials_json: str


@dataclass_json
@dataclass
class SourceConnector1:
    kind: Kind
    config: Config


class Kind1(str, Enum):
    amazon_sqs = "amazon_sqs"


@dataclass_json
@dataclass
class Config1:
    queue_url: str
    aws_region: str
    aws_access_key: str
    aws_secret_key: str


@dataclass_json
@dataclass
class SourceConnector2:
    kind: Kind1
    config: Config1


class Kind2(str, Enum):
    postgres = "postgres"


@dataclass_json
@dataclass
class Config2:
    db_host: str
    db_user: str
    db_pass: str
    db_name: str
    replication_slot: str
    db_port: Optional[str] = "5432"
    db_sslmode: Optional[str] = None
    publication: Optional[str] = None
    replication_output_plugin_name: Optional[str] = "wal2json"
    replication_output_plugin_args: Optional[List[str]] = None


@dataclass_json
@dataclass
class SourceConnector3:
    kind: Kind2
    config: Config2


SourceConnector = Optional[Union[SourceConnector1, SourceConnector2, SourceConnector3]]


class Kind3(str, Enum):
    webhook = "webhook"


class Method(str, Enum):
    get = "GET"
    post = "POST"
    put = "PUT"
    patch = "PATCH"
    delete = "DELETE"


@dataclass_json
@dataclass
class Header:
    name: str
    value: str


@dataclass_json
@dataclass
class Config3:
    url: str
    method: Method
    headers: List[Header]


@dataclass_json
@dataclass
class SinkConnector1:
    kind: Kind3
    config: Config3


class Kind4(str, Enum):
    clickhouse = "clickhouse"


@dataclass_json
@dataclass
class Config4:
    addr: str
    database: str
    username: str
    password: str
    table: str


@dataclass_json
@dataclass
class SinkConnector2:
    kind: Kind4
    config: Config4


class Kind5(str, Enum):
    amazon_s3 = "amazon_s3"


@dataclass_json
@dataclass
class Config5:
    s3_bucket: str
    s3_key: str
    aws_region: str
    aws_access_key: str
    aws_secret_key: str


@dataclass_json
@dataclass
class SinkConnector3:
    kind: Kind5
    config: Config5


class Kind6(str, Enum):
    snowflake_cdc_json = "snowflake_cdc_json"


@dataclass_json
@dataclass
class Config6:
    account: str
    warehouse: str
    db_user: str
    db_pass: str
    db_name: str
    db_schema: str
    db_host: Optional[str] = None
    db_port: Optional[str] = "443"
    db_role: Optional[str] = None


@dataclass_json
@dataclass
class SinkConnector4:
    kind: Kind6
    config: Config6


SinkConnector = Optional[
    Union[SinkConnector1, SinkConnector2, SinkConnector3, SinkConnector4]
]


@dataclass_json
@dataclass
class Pipeline(BasePipeline):
    id: str
    created_at: str
    state: PipelineState


@dataclass_json
@dataclass
class SpacePipeline(Pipeline):
    space_name: str


@dataclass_json
@dataclass
class GetDetailedSpacePipeline(SpacePipeline):
    source_connector: SourceConnector
    sink_connector: SinkConnector
    environments: FunctionEnvironments


@dataclass_json
@dataclass
class PipelineFunctionOutput:
    environments: FunctionEnvironments


SpacePipelines = List[SpacePipeline]


@dataclass_json
@dataclass
class CreateSpace:
    name: str


@dataclass_json
@dataclass
class UpdateSpace:
    name: str


@dataclass_json
@dataclass
class Space(CreateSpace):
    id: str
    created_at: str


@dataclass_json
@dataclass
class SpaceScope(Space):
    permission: str


SpaceScopes = List[SpaceScope]


@dataclass_json
@dataclass
class Payload:
    message: str


class SeverityCodeInput(int, Enum):
    integer_100 = 100
    integer_200 = 200
    integer_400 = 400
    integer_500 = 500


SeverityCode = int


@dataclass_json
@dataclass
class CreateAccessToken:
    name: str


@dataclass_json
@dataclass
class AccessToken(CreateAccessToken):
    id: str
    token: str
    created_at: str


AccessTokens = List[AccessToken]


@dataclass_json
@dataclass
class PaginationResponse:
    total_amount: int


@dataclass_json
@dataclass
class SourceFile:
    name: str
    content: str


SourceFiles = List[SourceFile]


@dataclass_json
@dataclass
class EventContext:
    request_id: str
    receive_time: str
    external_id: Optional[str] = None


PersonalAccessToken = str


QueryRangeMatrix = Optional[Any]


@dataclass_json
@dataclass
class Profile:
    id: str
    home_organization: Organization
    name: str
    email: str
    provider: str
    external_settings: Any
    subscriber_id: str


@dataclass_json
@dataclass
class ListOrganizationScopes(PaginationResponse):
    organizations: OrganizationScopes


@dataclass_json
@dataclass
class UpdatePipeline:
    name: str
    transformation_function: Optional[str] = None
    transformation_requirements: Optional[List[str]] = None
    requirements_txt: Optional[str] = None
    metadata: Optional[Dict[str, Any]] = None
    source_connector: Optional[SourceConnector] = None
    sink_connector: Optional[SinkConnector] = None
    environments: Optional[FunctionEnvironments] = None


@dataclass_json
@dataclass
class CreatePipeline(BasePipeline):
    transformation_function: Optional[str] = None
    transformation_requirements: Optional[List[str]] = None
    requirements_txt: Optional[str] = None
    source_connector: Optional[SourceConnector] = None
    sink_connector: Optional[SinkConnector] = None
    environments: Optional[FunctionEnvironments] = None
    state: Optional[PipelineState] = None


@dataclass_json
@dataclass
class ListPipelines(PaginationResponse):
    pipelines: SpacePipelines


@dataclass_json
@dataclass
class ListSpaceScopes(PaginationResponse):
    spaces: SpaceScopes


@dataclass_json
@dataclass
class FunctionLogEntry:
    level: str
    severity_code: SeverityCode
    timestamp: str
    payload: Payload


@dataclass_json
@dataclass
class ListAccessTokens(PaginationResponse):
    access_tokens: AccessTokens


@dataclass_json
@dataclass
class ConsumeInputEvent:
    payload: Any
    event_context: EventContext
    req_id: Optional[str] = None
    receive_time: Optional[str] = None


@dataclass_json
@dataclass
class ConsumeOutputEvent:
    payload: Any
    event_context: EventContext
    status: str
    req_id: Optional[str] = None
    receive_time: Optional[str] = None
    response: Optional[Any] = None
    error_details: Optional[str] = None
    stack_trace: Optional[str] = None


@dataclass_json
@dataclass
class ListPersonalAccessTokens:
    tokens: List[PersonalAccessToken]


@dataclass_json
@dataclass
class PipelineInputQueueRelativeLatencyMetricsResponse:
    input_queue_total_push_events: QueryRangeMatrix
    input_queue_latency: QueryRangeMatrix


FunctionLogs = List[FunctionLogEntry]
