# This file was auto-generated by Fern from our API Definition.

import typing

import pydantic
import typing_extensions
from ..core.pydantic_utilities import IS_PYDANTIC_V2
from ..core.serialization import FieldMetadata
from ..core.unchecked_base_model import UncheckedBaseModel
from .branch_protection_status import BranchProtectionStatus
from .resource_access_info import ResourceAccessInfo


class AgentBranchSummary(UncheckedBaseModel):
    id: str
    name: str
    agent_id: str
    description: str
    created_at: int
    last_committed_at: int
    is_archived: bool
    protection_status: typing.Optional[BranchProtectionStatus] = None
    access_info: typing.Optional[ResourceAccessInfo] = pydantic.Field(default=None)
    """
    Access information for the branch
    """

    current_live_percentage: typing.Optional[float] = pydantic.Field(default=None)
    """
    Percentage of traffic live on the branch
    """

    parent_branch_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the parent branch
    """

    draft_exists: typing.Optional[bool] = pydantic.Field(default=None)
    """
    Whether a draft exists for the branch
    """

    calls_7_d: typing_extensions.Annotated[
        typing.Optional[int],
        FieldMetadata(alias="calls_7d"),
        pydantic.Field(alias="calls_7d", description="Number of calls in the last 7 days"),
    ] = None
    commits_ahead: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of commits on this branch not yet on main, relative to their common ancestor. Null if it could not be computed (e.g. no common ancestor, or the branch history exceeds the comparison budget).
    """

    commits_behind: typing.Optional[int] = pydantic.Field(default=None)
    """
    Number of commits on main not yet incorporated into this branch, relative to their common ancestor. Null if it could not be computed (e.g. no common ancestor, or the branch history exceeds the comparison budget).
    """

    merged_into_branch_id: typing.Optional[str] = pydantic.Field(default=None)
    """
    ID of the branch this branch's tip version was merged into, if any
    """

    if IS_PYDANTIC_V2:
        model_config: typing.ClassVar[pydantic.ConfigDict] = pydantic.ConfigDict(extra="allow", frozen=True)  # type: ignore # Pydantic v2
    else:

        class Config:
            frozen = True
            smart_union = True
            extra = pydantic.Extra.allow
