# Generated by ariadne-codegen
# Source: mansrht/git/

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

from pydantic import Field

from .base_model import BaseModel
from .enums import ObjectType
from .fragments import CommitDetails, RepoDetails


class GetTree(BaseModel):
    me: "GetTreeMe"


class GetTreeMe(BaseModel):
    repository: Optional["GetTreeMeRepository"]


class GetTreeMeRepository(RepoDetails):
    path: Optional["GetTreeMeRepositoryPath"]
    reference: Optional["GetTreeMeRepositoryReference"]


class GetTreeMeRepositoryPath(BaseModel):
    name: str
    object_: Union[
        "GetTreeMeRepositoryPathObjectObject",
        "GetTreeMeRepositoryPathObjectBinaryBlob",
        "GetTreeMeRepositoryPathObjectTextBlob",
    ] = Field(alias="object", discriminator="typename__")


class GetTreeMeRepositoryPathObjectObject(BaseModel):
    typename__: Literal["Commit", "Object", "Tag", "Tree"] = Field(alias="__typename")
    id: str
    type_: ObjectType = Field(alias="type")


class GetTreeMeRepositoryPathObjectBinaryBlob(BaseModel):
    typename__: Literal["BinaryBlob"] = Field(alias="__typename")
    id: str
    type_: ObjectType = Field(alias="type")
    content: Any


class GetTreeMeRepositoryPathObjectTextBlob(BaseModel):
    typename__: Literal["TextBlob"] = Field(alias="__typename")
    id: str
    type_: ObjectType = Field(alias="type")
    text: str


class GetTreeMeRepositoryReference(BaseModel):
    commit: Optional[
        Annotated[
            Union[
                "GetTreeMeRepositoryReferenceCommitObject",
                "GetTreeMeRepositoryReferenceCommitCommit",
            ],
            Field(discriminator="typename__"),
        ]
    ]


class GetTreeMeRepositoryReferenceCommitObject(BaseModel):
    typename__: Literal["BinaryBlob", "Object", "Tag", "TextBlob", "Tree"] = Field(
        alias="__typename"
    )


class GetTreeMeRepositoryReferenceCommitCommit(CommitDetails):
    typename__: Literal["Commit"] = Field(alias="__typename")


GetTree.model_rebuild()
GetTreeMe.model_rebuild()
GetTreeMeRepository.model_rebuild()
GetTreeMeRepositoryPath.model_rebuild()
GetTreeMeRepositoryReference.model_rebuild()
