# Generated by ariadne-codegen
# Source: /usr/share/sourcehut/todo.sr.ht.graphqls

from datetime import datetime
from typing import Optional

from pydantic import Field

from .base_model import BaseModel
from .enums import EmailCmd, TicketResolution, TicketStatus, Visibility, WebhookEvent


class TrackerInput(BaseModel):
    """You may omit any fields to leave them unchanged."""

    name: Optional[str] = None
    description: Optional[str] = None
    visibility: Optional[Visibility] = None


class UpdateLabelInput(BaseModel):
    """You may omit any fields to leave them unchanged."""

    name: Optional[str] = None
    foreground_color: Optional[str] = Field(alias="foregroundColor", default=None)
    background_color: Optional[str] = Field(alias="backgroundColor", default=None)


class ACLInput(BaseModel):
    browse: bool
    "Permission to view tickets"
    submit: bool
    "Permission to submit tickets"
    comment: bool
    "Permission to comment on tickets"
    edit: bool
    "Permission to edit tickets"
    triage: bool
    "Permission to resolve, re-open, transfer, or label tickets"


class ImportInput(BaseModel):
    """This is used for importing tickets from third-party services, and may only be
    used by the tracker owner. It causes a ticket submission, update, or comment
    to be attributed to an external user and appear as if it were submitted at a
    specific time."""

    created: datetime
    external_id: str = Field(alias="externalId")
    'External user ID. By convention this should be "service:username", e.g.\n"codeberg:ddevault".'
    external_url: str = Field(alias="externalUrl")
    'A URL at which the user\'s external profile may be found, e.g.\n"https://codeberg.org/ddevault".'


class SubmitTicketInput(BaseModel):
    subject: str
    body: Optional[str] = None
    created: Optional[datetime] = None
    external_id: Optional[str] = Field(alias="externalId", default=None)
    external_url: Optional[str] = Field(alias="externalUrl", default=None)


class SubmitTicketEmailInput(BaseModel):
    subject: str
    body: Optional[str] = None
    sender_id: int = Field(alias="senderId")
    message_id: str = Field(alias="messageId")


class SubmitCommentEmailInput(BaseModel):
    text: str
    sender_id: int = Field(alias="senderId")
    cmd: Optional[EmailCmd] = None
    resolution: Optional[TicketResolution] = None
    label_ids: Optional[list[int]] = Field(alias="labelIds", default=None)
    message_id: str = Field(alias="messageId")


class UpdateTicketInput(BaseModel):
    """You may omit any fields to leave them unchanged. To remove the ticket body,
    set it to null."""

    subject: Optional[str] = None
    body: Optional[str] = None
    import_: Optional["ImportInput"] = Field(alias="import", default=None)
    "For use by the tracker owner only"


class SubmitCommentInput(BaseModel):
    """You may omit the status or resolution fields to leave them unchanged (or if
    you do not have permission to change them). "resolution" is required if
    status is RESOLVED."""

    text: str
    status: Optional[TicketStatus] = None
    resolution: Optional[TicketResolution] = None
    import_: Optional["ImportInput"] = Field(alias="import", default=None)
    "For use by the tracker owner only"


class UpdateStatusInput(BaseModel):
    """ "resolution" is required if status is RESOLVED."""

    status: TicketStatus
    resolution: Optional[TicketResolution] = None
    import_: Optional["ImportInput"] = Field(alias="import", default=None)
    "For use by the tracker owner only"


class UserWebhookInput(BaseModel):
    url: str
    events: list[WebhookEvent]
    query: str


class TrackerWebhookInput(BaseModel):
    url: str
    events: list[WebhookEvent]
    query: str


class TicketWebhookInput(BaseModel):
    url: str
    events: list[WebhookEvent]
    query: str


class PreferencesInput(BaseModel):
    notify_self: bool = Field(alias="notifySelf")


UpdateTicketInput.model_rebuild()
SubmitCommentInput.model_rebuild()
UpdateStatusInput.model_rebuild()
