# Generated by ariadne-codegen
# Source: operations/

from typing import Any, Optional

from pydantic import Field

from .base_model import BaseModel
from .enums import (
    DeploymentStatus,
    DomainStatus,
    GitProvider,
    NetworkType,
    ServiceSpecHealthCheckType,
    ServiceStatus,
    ServiceTemplate,
)


class Service(BaseModel):
    service: "ServiceService"


class ServiceService(BaseModel):
    id: Any = Field(alias="_id")
    name: str
    template: ServiceTemplate
    project: "ServiceServiceProject"
    watch_paths: list[str] = Field(alias="watchPaths")
    root_directory: str = Field(alias="rootDirectory")
    custom_build_command: Optional[str] = Field(alias="customBuildCommand")
    custom_start_command: Optional[str] = Field(alias="customStartCommand")
    output_dir: Optional[str] = Field(alias="outputDir")
    resource_limit: Optional["ServiceServiceResourceLimit"] = Field(
        alias="resourceLimit"
    )
    created_at: Any = Field(alias="createdAt")
    market_item_code: Optional[str] = Field(alias="marketItemCode")
    spec: Optional["ServiceServiceSpec"]
    marketplace_item: Optional["ServiceServiceMarketplaceItem"] = Field(
        alias="marketplaceItem"
    )
    status: ServiceStatus
    dns_name: str = Field(alias="dnsName")
    port_forwarded_host: str = Field(alias="portForwardedHost")
    health_check_v_2: Optional["ServiceServiceHealthCheckV2"] = Field(
        alias="healthCheckV2"
    )
    suspended_at: Optional[Any] = Field(alias="suspendedAt")
    once_product: Optional[str] = Field(alias="onceProduct")
    failure_threshold: int = Field(alias="failureThreshold")
    deployments: list["ServiceServiceDeployments"]
    domains: list["ServiceServiceDomains"]


class ServiceServiceProject(BaseModel):
    id: Any = Field(alias="_id")
    name: str
    description: Optional[str]
    icon_url: Optional[str] = Field(alias="iconURL")
    created_at: Any = Field(alias="createdAt")
    owner: Optional["ServiceServiceProjectOwner"]
    collaborators: list["ServiceServiceProjectCollaborators"]
    invitations: list["ServiceServiceProjectInvitations"]
    region: "ServiceServiceProjectRegion"
    pull_request: Optional[str] = Field(alias="pullRequest")
    environments: list["ServiceServiceProjectEnvironments"]
    services: list["ServiceServiceProjectServices"]


class ServiceServiceProjectOwner(BaseModel):
    id: Any = Field(alias="_id")


class ServiceServiceProjectCollaborators(BaseModel):
    id: Any = Field(alias="_id")


class ServiceServiceProjectInvitations(BaseModel):
    id: Any = Field(alias="_id")


class ServiceServiceProjectRegion(BaseModel):
    id: str


class ServiceServiceProjectEnvironments(BaseModel):
    id: Any = Field(alias="_id")


class ServiceServiceProjectServices(BaseModel):
    id: Any = Field(alias="_id")


class ServiceServiceResourceLimit(BaseModel):
    cpu: Optional[int]
    memory: Optional[int]


class ServiceServiceSpec(BaseModel):
    id: Optional[str]
    name: str
    icon: Optional[str]
    ports: Optional[list["ServiceServiceSpecPorts"]]
    volumes: Optional[list["ServiceServiceSpecVolumes"]]
    init_rules: Optional[list["ServiceServiceSpecInitRules"]] = Field(alias="initRules")


class ServiceServiceSpecPorts(BaseModel):
    id: str


class ServiceServiceSpecVolumes(BaseModel):
    id: str


class ServiceServiceSpecInitRules(BaseModel):
    id: str


class ServiceServiceMarketplaceItem(BaseModel):
    code: str
    name: str
    icon_url: str = Field(alias="iconURL")
    description: str
    network_type: NetworkType = Field(alias="networkType")


class ServiceServiceHealthCheckV2(BaseModel):
    type: ServiceSpecHealthCheckType
    port: str


class ServiceServiceDeployments(BaseModel):
    id: Any = Field(alias="_id")
    git_provider: GitProvider = Field(alias="gitProvider")
    repo_owner: str = Field(alias="repoOwner")
    repo_name: str = Field(alias="repoName")
    ref: str
    commit_sha: str = Field(alias="commitSHA")
    commit_message: str = Field(alias="commitMessage")
    project_id: Any = Field(alias="projectID")
    service_id: Any = Field(alias="serviceID")
    environment_id: Any = Field(alias="environmentID")
    status: DeploymentStatus
    created_at: Any = Field(alias="createdAt")
    plan_type: Optional[str] = Field(alias="planType")
    plan_meta: Optional[Any] = Field(alias="planMeta")
    scheduled_at: Optional[Any] = Field(alias="scheduledAt")
    started_at: Optional[Any] = Field(alias="startedAt")
    finished_at: Optional[Any] = Field(alias="finishedAt")
    canceled_at: Optional[Any] = Field(alias="canceledAt")
    serverless: Optional[bool]


class ServiceServiceDomains(BaseModel):
    id: Any = Field(alias="_id")
    domain: str
    redirect_to: Optional[str] = Field(alias="redirectTo")
    service_id: Any = Field(alias="serviceID")
    project_id: Any = Field(alias="projectID")
    environment_id: Any = Field(alias="environmentID")
    status: DomainStatus
    status_reason: Optional[str] = Field(alias="statusReason")
    created_at: Any = Field(alias="createdAt")
    port_name: Optional[str] = Field(alias="portName")
    is_generated: bool = Field(alias="isGenerated")


Service.model_rebuild()
ServiceService.model_rebuild()
ServiceServiceProject.model_rebuild()
ServiceServiceSpec.model_rebuild()
