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

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 AccessMode


class Acl(BaseModel):
    id: int
    created: Annotated[datetime, BeforeValidator(gql_time)]
    mode: Optional[AccessMode]
    entity: Union["AclEntityEntity", "AclEntityUser"] = Field(
        discriminator="typename__"
    )


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


class AclEntityUser(BaseModel):
    typename__: Literal["User"] = Field(alias="__typename")
    canonical_name: str = Field(alias="canonicalName")
    username: str


class Sshkey(BaseModel):
    rid: str
    key: str
    key_type: str = Field(alias="keyType")
    fingerprint_sha_256: str = Field(alias="fingerprintSHA256")
    comment: Optional[str]
    created: Annotated[datetime, BeforeValidator(gql_time)]
    last_used: Optional[Annotated[datetime, BeforeValidator(gql_time)]] = Field(
        alias="lastUsed"
    )
    access: AccessMode


Acl.model_rebuild()
Sshkey.model_rebuild()
