# Generated by ariadne-codegen
# Source: hubsrht/services/hg/

from datetime import datetime
from typing import Annotated, Literal, Optional, Union

from pydantic import BeforeValidator, Field
from srht.graphql import gql_time

from .base_model import BaseModel
from .enums import Visibility, WebhookEvent


class EventWebhook(BaseModel):
    webhook: Union[
        "EventWebhookWebhookWebhookPayload", "EventWebhookWebhookRepositoryEvent"
    ] = Field(discriminator="typename__")


class EventWebhookWebhookWebhookPayload(BaseModel):
    typename__: Literal["WebhookPayload"] = Field(alias="__typename")
    uuid: str
    event: WebhookEvent
    date: Annotated[datetime, BeforeValidator(gql_time)]


class EventWebhookWebhookRepositoryEvent(BaseModel):
    typename__: Literal["RepositoryEvent"] = Field(alias="__typename")
    uuid: str
    event: WebhookEvent
    date: Annotated[datetime, BeforeValidator(gql_time)]
    repository: "EventWebhookWebhookRepositoryEventRepository"


class EventWebhookWebhookRepositoryEventRepository(BaseModel):
    id: int
    rid: str
    name: str
    description: Optional[str]
    visibility: Visibility


EventWebhook.model_rebuild()
EventWebhookWebhookRepositoryEvent.model_rebuild()
