# Generated by ariadne-codegen
# Source: metasrht/graphql/

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

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

from .base_model import BaseModel


class OAuthDashboard(BaseModel):
    personal_access_tokens: list["OAuthDashboardPersonalAccessTokens"] = Field(
        alias="personalAccessTokens"
    )
    oauth_clients: list["OAuthDashboardOauthClients"] = Field(alias="oauthClients")
    oauth_grants: list["OAuthDashboardOauthGrants"] = Field(alias="oauthGrants")


class OAuthDashboardPersonalAccessTokens(BaseModel):
    id: int
    comment: Optional[str]
    issued: Annotated[datetime, BeforeValidator(gql_time)]
    expires: Annotated[datetime, BeforeValidator(gql_time)]


class OAuthDashboardOauthClients(BaseModel):
    id: int
    uuid: str
    name: str
    url: Optional[str]


class OAuthDashboardOauthGrants(BaseModel):
    id: int
    issued: Annotated[datetime, BeforeValidator(gql_time)]
    expires: Annotated[datetime, BeforeValidator(gql_time)]
    token_hash: str = Field(alias="tokenHash")
    client: "OAuthDashboardOauthGrantsClient"


class OAuthDashboardOauthGrantsClient(BaseModel):
    name: str
    url: Optional[str]
    owner: "OAuthDashboardOauthGrantsClientOwner"


class OAuthDashboardOauthGrantsClientOwner(BaseModel):
    typename__: Literal["Entity", "User"] = Field(alias="__typename")
    canonical_name: str = Field(alias="canonicalName")


OAuthDashboard.model_rebuild()
OAuthDashboardOauthGrants.model_rebuild()
OAuthDashboardOauthGrantsClient.model_rebuild()
