# Generated by ariadne-codegen
# Source: operations/

from typing import Any, Optional, Union

from .add_domain import AddDomain
from .async_base_client import AsyncBaseClient
from .backup import Backup
from .backups import Backups
from .base_model import UNSET, UnsetType
from .buckets import Buckets
from .build_logs import BuildLogs
from .build_plan import BuildPlan
from .cancel_invitation import CancelInvitation
from .cancel_ongoing_deployment import CancelOngoingDeployment
from .check_docker_image import CheckDockerImage
from .check_domain_available import CheckDomainAvailable
from .cleanup_logs import CleanupLogs
from .clone_git_repo_of_service import CloneGitRepoOfService
from .clone_project import CloneProject
from .clone_project_status import CloneProjectStatus
from .create_backup import CreateBackup
from .create_bucket import CreateBucket
from .create_environment_variable import CreateEnvironmentVariable
from .create_my_sql_database import CreateMySQLDatabase
from .create_postgres_database import CreatePostgresDatabase
from .create_prebuilt_service import CreatePrebuiltService
from .create_project import CreateProject
from .create_service import CreateService
from .create_template import CreateTemplate
from .create_template_from_file import CreateTemplateFromFile
from .dedicated_server_plans import DedicatedServerPlans
from .dedicated_server_providers import DedicatedServerProviders
from .dedicated_server_regions import DedicatedServerRegions
from .delete_bucket import DeleteBucket
from .delete_environment import DeleteEnvironment
from .delete_my_sql_database import DeleteMySQLDatabase
from .delete_object import DeleteObject
from .delete_postgres_database import DeletePostgresDatabase
from .delete_project import DeleteProject
from .delete_service import DeleteService
from .delete_service_config import DeleteServiceConfig
from .delete_template import DeleteTemplate
from .deploy import Deploy
from .deploy_from_specification import DeployFromSpecification
from .deploy_template import DeployTemplate
from .deployment import Deployment
from .deployments import Deployments
from .enums import (
    DeploymentStatus,
    GitProvider,
    GroupByEntity,
    GroupByTime,
    GroupByType,
    PaymentMethodType,
    PortForwardingMode,
    ServiceTemplate,
    UsageGroupByEntity,
)
from .environment import Environment
from .environments import Environments
from .execute_command import ExecuteCommand
from .execute_database_command import ExecuteDatabaseCommand
from .export_runtime_logs import ExportRuntimeLogs
from .file_content import FileContent
from .files import Files
from .get_object_presigned_url import GetObjectPresignedURL
from .git_repo_branches import GitRepoBranches
from .git_repositories import GitRepositories
from .input_types import (
    DeploymentSpecification,
    GitRef,
    GroupInput,
    ResourceLimitInput,
    ServiceSpecHealthCheckInput,
    ServiceSpecPortInput,
    ServiceSpecSchemaInput,
    TemplateVariableInput,
    TriggerInput,
    VariablePropertyInput,
    createServiceInput,
)
from .instructions import Instructions
from .invite_user_to_project import InviteUserToProject
from .is_template_author import IsTemplateAuthor
from .kick_collaborator import KickCollaborator
from .latest_git_repositories import LatestGitRepositories
from .leave_project import LeaveProject
from .me import Me
from .mount_volume import MountVolume
from .mysql_databases import MysqlDatabases
from .object import Object
from .objects import Objects
from .postgres_databases import PostgresDatabases
from .poweroff_server import PoweroffServer
from .poweron_server import PoweronServer
from .prebuilt_marketplace_items import PrebuiltMarketplaceItems
from .project import Project
from .project_usage import ProjectUsage
from .projects import Projects
from .put_object import PutObject
from .reboot_server import RebootServer
from .recharge import Recharge
from .reconcile_server import ReconcileServer
from .redeploy_service import RedeployService
from .referrer import Referrer
from .regions import Regions
from .register_server import RegisterServer
from .reinstall_server import ReinstallServer
from .reload_k_3_s_config import ReloadK3sConfig
from .remove_domain import RemoveDomain
from .rename_environment import RenameEnvironment
from .rename_project import RenameProject
from .rename_service import RenameService
from .renew_server import RenewServer
from .rent_server import RentServer
from .request_phone_verification import RequestPhoneVerification
from .restart_service import RestartService
from .reveal_managed_server_initial_password import RevealManagedServerInitialPassword
from .rollback_deployment import RollbackDeployment
from .runtime_logs import RuntimeLogs
from .search_git_repositories import SearchGitRepositories
from .server import Server
from .servers import Servers
from .service import Service
from .service_plan_type_plan_meta import ServicePlanTypePlanMeta
from .services import Services
from .set_auto_backup import SetAutoBackup
from .set_auto_restart import SetAutoRestart
from .set_budget import SetBudget
from .set_variable_property import SetVariableProperty
from .suspend_service import SuspendService
from .template import Template
from .templates import Templates
from .unmount_volume import UnmountVolume
from .unregister_server import UnregisterServer
from .update_dockerfile import UpdateDockerfile
from .update_environment_variable import UpdateEnvironmentVariable
from .update_git_trigger import UpdateGitTrigger
from .update_groups import UpdateGroups
from .update_port_forwarding_mode import UpdatePortForwardingMode
from .update_project_description import UpdateProjectDescription
from .update_project_icon import UpdateProjectIcon
from .update_root_directory import UpdateRootDirectory
from .update_server_auto_renew import UpdateServerAutoRenew
from .update_server_credentials import UpdateServerCredentials
from .update_server_name import UpdateServerName
from .update_service_command import UpdateServiceCommand
from .update_service_config import UpdateServiceConfig
from .update_service_description import UpdateServiceDescription
from .update_service_dns_name import UpdateServiceDNSName
from .update_service_failure_threshold import UpdateServiceFailureThreshold
from .update_service_health_check_v_2 import UpdateServiceHealthCheckV2
from .update_service_icon import UpdateServiceIcon
from .update_service_image_credential import UpdateServiceImageCredential
from .update_service_image_repo import UpdateServiceImageRepo
from .update_service_image_tag import UpdateServiceImageTag
from .update_service_ports import UpdateServicePorts
from .update_service_resource_limit import UpdateServiceResourceLimit
from .update_template import UpdateTemplate
from .update_template_from_file import UpdateTemplateFromFile
from .update_user_email_preference import UpdateUserEmailPreference
from .update_user_profile import UpdateUserProfile
from .update_watch_paths import UpdateWatchPaths
from .usages import Usages
from .user import User
from .user_templates import UserTemplates
from .users import Users
from .verify_phone_verification import VerifyPhoneVerification


def gql(q: str) -> str:
    return q


class ZeaburGraphQLClient(AsyncBaseClient):
    async def create_postgres_database(
        self, environment_id: Any, service_id: Any, name: str, **kwargs: Any
    ) -> CreatePostgresDatabase:
        query = gql("""
            mutation createPostgresDatabase($environmentID: ObjectID!, $serviceID: ObjectID!, $name: String!) {
              createPostgresDatabase(
                environmentID: $environmentID
                serviceID: $serviceID
                name: $name
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "name": name,
        }
        response = await self.execute(
            query=query,
            operation_name="createPostgresDatabase",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreatePostgresDatabase.model_validate(data)

    async def delete_postgres_database(
        self, environment_id: Any, service_id: Any, name: str, **kwargs: Any
    ) -> DeletePostgresDatabase:
        query = gql("""
            mutation deletePostgresDatabase($environmentID: ObjectID!, $serviceID: ObjectID!, $name: String!) {
              deletePostgresDatabase(
                environmentID: $environmentID
                serviceID: $serviceID
                name: $name
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "name": name,
        }
        response = await self.execute(
            query=query,
            operation_name="deletePostgresDatabase",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeletePostgresDatabase.model_validate(data)

    async def create_my_sql_database(
        self, environment_id: Any, service_id: Any, name: str, **kwargs: Any
    ) -> CreateMySQLDatabase:
        query = gql("""
            mutation createMySQLDatabase($environmentID: ObjectID!, $serviceID: ObjectID!, $name: String!) {
              createMySQLDatabase(
                environmentID: $environmentID
                serviceID: $serviceID
                name: $name
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "name": name,
        }
        response = await self.execute(
            query=query,
            operation_name="createMySQLDatabase",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreateMySQLDatabase.model_validate(data)

    async def delete_my_sql_database(
        self, environment_id: Any, service_id: Any, name: str, **kwargs: Any
    ) -> DeleteMySQLDatabase:
        query = gql("""
            mutation deleteMySQLDatabase($environmentID: ObjectID!, $serviceID: ObjectID!, $name: String!) {
              deleteMySQLDatabase(
                environmentID: $environmentID
                serviceID: $serviceID
                name: $name
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "name": name,
        }
        response = await self.execute(
            query=query,
            operation_name="deleteMySQLDatabase",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteMySQLDatabase.model_validate(data)

    async def create_backup(
        self, environment_id: Any, service_id: Any, **kwargs: Any
    ) -> CreateBackup:
        query = gql("""
            mutation createBackup($environmentID: ObjectID!, $serviceID: ObjectID!) {
              createBackup(environmentID: $environmentID, serviceID: $serviceID)
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
        }
        response = await self.execute(
            query=query, operation_name="createBackup", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateBackup.model_validate(data)

    async def set_auto_backup(
        self,
        environment_id: Any,
        service_id: Any,
        enabled: bool,
        backup_hour: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> SetAutoBackup:
        query = gql("""
            mutation setAutoBackup($environmentID: ObjectID!, $serviceID: ObjectID!, $enabled: Boolean!, $backupHour: Int) {
              setAutoBackup(
                environmentID: $environmentID
                serviceID: $serviceID
                enabled: $enabled
                backupHour: $backupHour
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "enabled": enabled,
            "backupHour": backup_hour,
        }
        response = await self.execute(
            query=query, operation_name="setAutoBackup", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SetAutoBackup.model_validate(data)

    async def execute_database_command(
        self,
        environment_id: Any,
        service_id: Any,
        command: str,
        database_name: str,
        **kwargs: Any
    ) -> ExecuteDatabaseCommand:
        query = gql("""
            mutation executeDatabaseCommand($environmentID: ObjectID!, $serviceID: ObjectID!, $command: String!, $databaseName: String!) {
              executeDatabaseCommand(
                environmentID: $environmentID
                serviceID: $serviceID
                command: $command
                databaseName: $databaseName
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "command": command,
            "databaseName": database_name,
        }
        response = await self.execute(
            query=query,
            operation_name="executeDatabaseCommand",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return ExecuteDatabaseCommand.model_validate(data)

    async def mount_volume(
        self, service_id: Any, id: str, dir: str, **kwargs: Any
    ) -> MountVolume:
        query = gql("""
            mutation mountVolume($serviceID: ObjectID!, $id: String!, $dir: String!) {
              mountVolume(serviceID: $serviceID, id: $id, dir: $dir)
            }
            """)
        variables: dict[str, object] = {"serviceID": service_id, "id": id, "dir": dir}
        response = await self.execute(
            query=query, operation_name="mountVolume", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return MountVolume.model_validate(data)

    async def unmount_volume(
        self, service_id: Any, id: str, **kwargs: Any
    ) -> UnmountVolume:
        query = gql("""
            mutation unmountVolume($serviceID: ObjectID!, $id: String!) {
              unmountVolume(serviceID: $serviceID, id: $id)
            }
            """)
        variables: dict[str, object] = {"serviceID": service_id, "id": id}
        response = await self.execute(
            query=query, operation_name="unmountVolume", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UnmountVolume.model_validate(data)

    async def create_bucket(
        self, environment_id: Any, service_id: Any, bucket_name: str, **kwargs: Any
    ) -> CreateBucket:
        query = gql("""
            mutation createBucket($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!) {
              createBucket(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
        }
        response = await self.execute(
            query=query, operation_name="createBucket", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateBucket.model_validate(data)

    async def delete_bucket(
        self, environment_id: Any, service_id: Any, bucket_name: str, **kwargs: Any
    ) -> DeleteBucket:
        query = gql("""
            mutation deleteBucket($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!) {
              deleteBucket(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
        }
        response = await self.execute(
            query=query, operation_name="deleteBucket", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteBucket.model_validate(data)

    async def put_object(
        self,
        environment_id: Any,
        service_id: Any,
        bucket_name: str,
        object_key: str,
        content: str,
        content_type: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> PutObject:
        query = gql("""
            mutation putObject($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!, $objectKey: String!, $content: String!, $contentType: String) {
              putObject(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
                objectKey: $objectKey
                content: $content
                contentType: $contentType
              ) {
                key
                size
                etag
                lastModified
                storageClass
                contentType
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
            "objectKey": object_key,
            "content": content,
            "contentType": content_type,
        }
        response = await self.execute(
            query=query, operation_name="putObject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return PutObject.model_validate(data)

    async def delete_object(
        self,
        environment_id: Any,
        service_id: Any,
        bucket_name: str,
        object_key: str,
        **kwargs: Any
    ) -> DeleteObject:
        query = gql("""
            mutation deleteObject($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!, $objectKey: String!) {
              deleteObject(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
                objectKey: $objectKey
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
            "objectKey": object_key,
        }
        response = await self.execute(
            query=query, operation_name="deleteObject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteObject.model_validate(data)

    async def get_object_presigned_url(
        self,
        environment_id: Any,
        service_id: Any,
        bucket_name: str,
        object_key: str,
        expire_seconds: int,
        method: str,
        **kwargs: Any
    ) -> GetObjectPresignedURL:
        query = gql("""
            mutation getObjectPresignedURL($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!, $objectKey: String!, $expireSeconds: Int!, $method: String!) {
              getObjectPresignedURL(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
                objectKey: $objectKey
                expireSeconds: $expireSeconds
                method: $method
              ) {
                url
                expiration
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
            "objectKey": object_key,
            "expireSeconds": expire_seconds,
            "method": method,
        }
        response = await self.execute(
            query=query,
            operation_name="getObjectPresignedURL",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return GetObjectPresignedURL.model_validate(data)

    async def deploy(
        self,
        service_id: Any,
        environment_id: Union[Optional[Any], UnsetType] = UNSET,
        upload_id: Union[Optional[Any], UnsetType] = UNSET,
        git_ref: Union[Optional[GitRef], UnsetType] = UNSET,
        vars: Union[Optional[Any], UnsetType] = UNSET,
        root_directory: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Deploy:
        query = gql("""
            mutation deploy($serviceID: ObjectID!, $environmentID: ObjectID, $uploadID: ObjectID, $gitRef: GitRef, $vars: Map, $rootDirectory: String) {
              deploy(
                serviceID: $serviceID
                environmentID: $environmentID
                uploadID: $uploadID
                gitRef: $gitRef
                vars: $vars
                rootDirectory: $rootDirectory
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "uploadID": upload_id,
            "gitRef": git_ref,
            "vars": vars,
            "rootDirectory": root_directory,
        }
        response = await self.execute(
            query=query, operation_name="deploy", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Deploy.model_validate(data)

    async def deploy_from_specification(
        self, service_id: Any, specification: DeploymentSpecification, **kwargs: Any
    ) -> DeployFromSpecification:
        query = gql("""
            mutation deployFromSpecification($serviceID: ObjectID!, $specification: DeploymentSpecification!) {
              deployFromSpecification(serviceID: $serviceID, specification: $specification) {
                deploymentID
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "specification": specification,
        }
        response = await self.execute(
            query=query,
            operation_name="deployFromSpecification",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeployFromSpecification.model_validate(data)

    async def cancel_ongoing_deployment(
        self, deployment_id: Any, **kwargs: Any
    ) -> CancelOngoingDeployment:
        query = gql("""
            mutation cancelOngoingDeployment($deploymentID: ObjectID!) {
              cancelOngoingDeployment(deploymentID: $deploymentID)
            }
            """)
        variables: dict[str, object] = {"deploymentID": deployment_id}
        response = await self.execute(
            query=query,
            operation_name="cancelOngoingDeployment",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CancelOngoingDeployment.model_validate(data)

    async def rollback_deployment(
        self, deployment_id: Any, **kwargs: Any
    ) -> RollbackDeployment:
        query = gql("""
            mutation rollbackDeployment($deploymentID: ObjectID!) {
              rollbackDeployment(deploymentID: $deploymentID)
            }
            """)
        variables: dict[str, object] = {"deploymentID": deployment_id}
        response = await self.execute(
            query=query,
            operation_name="rollbackDeployment",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return RollbackDeployment.model_validate(data)

    async def add_domain(
        self,
        service_id: Any,
        domain: str,
        is_generated: bool,
        environment_id: Union[Optional[Any], UnsetType] = UNSET,
        redirect_to: Union[Optional[str], UnsetType] = UNSET,
        port_name: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> AddDomain:
        query = gql("""
            mutation addDomain($serviceID: ObjectID!, $environmentID: ObjectID, $domain: String!, $isGenerated: Boolean!, $redirectTo: String, $portName: String) {
              addDomain(
                serviceID: $serviceID
                environmentID: $environmentID
                domain: $domain
                isGenerated: $isGenerated
                redirectTo: $redirectTo
                portName: $portName
              ) {
                _id
                domain
                redirectTo
                serviceID
                projectID
                environmentID
                status
                statusReason
                createdAt
                portName
                isGenerated
                dnsRecords {
                  recordType
                  recordName
                  recordValue
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "domain": domain,
            "isGenerated": is_generated,
            "redirectTo": redirect_to,
            "portName": port_name,
        }
        response = await self.execute(
            query=query, operation_name="addDomain", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return AddDomain.model_validate(data)

    async def remove_domain(self, domain: str, **kwargs: Any) -> RemoveDomain:
        query = gql("""
            mutation removeDomain($domain: String!) {
              removeDomain(domain: $domain)
            }
            """)
        variables: dict[str, object] = {"domain": domain}
        response = await self.execute(
            query=query, operation_name="removeDomain", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RemoveDomain.model_validate(data)

    async def check_domain_available(
        self, domain: str, is_generated: bool, region: str, **kwargs: Any
    ) -> CheckDomainAvailable:
        query = gql("""
            mutation checkDomainAvailable($domain: String!, $isGenerated: Boolean!, $region: String!) {
              checkDomainAvailable(
                domain: $domain
                isGenerated: $isGenerated
                region: $region
              ) {
                isAvailable
                reason
                availableSuffixes
              }
            }
            """)
        variables: dict[str, object] = {
            "domain": domain,
            "isGenerated": is_generated,
            "region": region,
        }
        response = await self.execute(
            query=query,
            operation_name="checkDomainAvailable",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CheckDomainAvailable.model_validate(data)

    async def delete_environment(self, id: Any, **kwargs: Any) -> DeleteEnvironment:
        query = gql("""
            mutation deleteEnvironment($_id: ObjectID!) {
              deleteEnvironment(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query,
            operation_name="deleteEnvironment",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteEnvironment.model_validate(data)

    async def rename_environment(
        self, id: Any, name: str, **kwargs: Any
    ) -> RenameEnvironment:
        query = gql("""
            mutation renameEnvironment($_id: ObjectID!, $name: String!) {
              renameEnvironment(_id: $_id, name: $name)
            }
            """)
        variables: dict[str, object] = {"_id": id, "name": name}
        response = await self.execute(
            query=query,
            operation_name="renameEnvironment",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return RenameEnvironment.model_validate(data)

    async def create_environment_variable(
        self, service_id: Any, environment_id: Any, key: str, value: str, **kwargs: Any
    ) -> CreateEnvironmentVariable:
        query = gql("""
            mutation createEnvironmentVariable($serviceID: ObjectID!, $environmentID: ObjectID!, $key: String!, $value: String!) {
              createEnvironmentVariable(
                serviceID: $serviceID
                environmentID: $environmentID
                key: $key
                value: $value
              ) {
                _id
                key
                value
                environmentID
                createdAt
                exposed
                readonly
                serviceID
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "key": key,
            "value": value,
        }
        response = await self.execute(
            query=query,
            operation_name="createEnvironmentVariable",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreateEnvironmentVariable.model_validate(data)

    async def update_environment_variable(
        self, service_id: Any, environment_id: Any, data: Any, **kwargs: Any
    ) -> UpdateEnvironmentVariable:
        query = gql("""
            mutation updateEnvironmentVariable($serviceID: ObjectID!, $environmentID: ObjectID!, $data: Map!) {
              updateEnvironmentVariable(
                serviceID: $serviceID
                environmentID: $environmentID
                data: $data
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "data": data,
        }
        response = await self.execute(
            query=query,
            operation_name="updateEnvironmentVariable",
            variables=variables,
            **kwargs
        )
        _data = self.get_data(response)
        return UpdateEnvironmentVariable.model_validate(_data)

    async def set_variable_property(
        self,
        service_id: Any,
        environment_id: Any,
        key: str,
        property: VariablePropertyInput,
        **kwargs: Any
    ) -> SetVariableProperty:
        query = gql("""
            mutation setVariableProperty($serviceID: ObjectID!, $environmentID: ObjectID!, $key: String!, $property: VariablePropertyInput!) {
              setVariableProperty(
                serviceID: $serviceID
                environmentID: $environmentID
                key: $key
                property: $property
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "key": key,
            "property": property,
        }
        response = await self.execute(
            query=query,
            operation_name="setVariableProperty",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return SetVariableProperty.model_validate(data)

    async def clone_git_repo_of_service(
        self,
        service_id: Any,
        github_o_auth_code: str,
        repo_name: str,
        is_private: bool,
        **kwargs: Any
    ) -> CloneGitRepoOfService:
        query = gql("""
            mutation cloneGitRepoOfService($serviceID: ObjectID!, $githubOAuthCode: String!, $repoName: String!, $isPrivate: Boolean!) {
              cloneGitRepoOfService(
                serviceID: $serviceID
                githubOAuthCode: $githubOAuthCode
                repoName: $repoName
                isPrivate: $isPrivate
              ) {
                projectID
                serviceID
                repoURL
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "githubOAuthCode": github_o_auth_code,
            "repoName": repo_name,
            "isPrivate": is_private,
        }
        response = await self.execute(
            query=query,
            operation_name="cloneGitRepoOfService",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CloneGitRepoOfService.model_validate(data)

    async def export_runtime_logs(
        self,
        environment_id: Any,
        service_id: Any,
        start_at: Any,
        deployment_id: Union[Optional[Any], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> ExportRuntimeLogs:
        query = gql("""
            mutation exportRuntimeLogs($environmentID: ObjectID!, $serviceID: ObjectID!, $deploymentID: ObjectID, $startAt: Time!, $limit: Int) {
              exportRuntimeLogs(
                environmentID: $environmentID
                serviceID: $serviceID
                deploymentID: $deploymentID
                startAt: $startAt
                limit: $limit
              ) {
                url
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "deploymentID": deployment_id,
            "startAt": start_at,
            "limit": limit,
        }
        response = await self.execute(
            query=query,
            operation_name="exportRuntimeLogs",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return ExportRuntimeLogs.model_validate(data)

    async def cleanup_logs(
        self,
        environment_id: Any,
        service_id: Any,
        days: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CleanupLogs:
        query = gql("""
            mutation cleanupLogs($environmentID: ObjectID!, $serviceID: ObjectID!, $days: Int) {
              cleanupLogs(environmentID: $environmentID, serviceID: $serviceID, days: $days) {
                status
                count
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "days": days,
        }
        response = await self.execute(
            query=query, operation_name="cleanupLogs", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CleanupLogs.model_validate(data)

    async def create_project(
        self,
        name: Union[Optional[str], UnsetType] = UNSET,
        region: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CreateProject:
        query = gql("""
            mutation createProject($name: String, $region: String) {
              createProject(name: $name, region: $region) {
                _id
                name
                description
                iconURL
                createdAt
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                collaborators {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                invitations {
                  _id
                  inviter {
                    _id
                  }
                  invitee {
                    _id
                  }
                  email
                  project {
                    _id
                  }
                  invitedAt
                  acceptedAt
                  cancelledAt
                  leavedAt
                }
                region {
                  id
                  code
                  name
                  description
                  available
                  coordinates
                  continent
                  country
                  city
                }
                pullRequest
                groups {
                  name
                  serviceIDs
                }
                environments {
                  _id
                  name
                  projectID
                  createdAt
                }
                services {
                  _id
                  name
                  template
                  project {
                    _id
                  }
                  watchPaths
                  rootDirectory
                  customBuildCommand
                  customStartCommand
                  outputDir
                  createdAt
                  marketItemCode
                  spec {
                    id
                  }
                  status
                  dnsName
                  portForwardedHost
                  suspendedAt
                  onceProduct
                  failureThreshold
                  deployments {
                    _id
                  }
                  domains {
                    _id
                  }
                }
              }
            }
            """)
        variables: dict[str, object] = {"name": name, "region": region}
        response = await self.execute(
            query=query, operation_name="createProject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CreateProject.model_validate(data)

    async def delete_project(self, id: Any, **kwargs: Any) -> DeleteProject:
        query = gql("""
            mutation deleteProject($_id: ObjectID!) {
              deleteProject(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="deleteProject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteProject.model_validate(data)

    async def rename_project(self, id: Any, name: str, **kwargs: Any) -> RenameProject:
        query = gql("""
            mutation renameProject($_id: ObjectID!, $name: String!) {
              renameProject(_id: $_id, name: $name)
            }
            """)
        variables: dict[str, object] = {"_id": id, "name": name}
        response = await self.execute(
            query=query, operation_name="renameProject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RenameProject.model_validate(data)

    async def update_project_description(
        self, id: Any, description: str, **kwargs: Any
    ) -> UpdateProjectDescription:
        query = gql("""
            mutation updateProjectDescription($_id: ObjectID!, $description: String!) {
              updateProjectDescription(_id: $_id, description: $description)
            }
            """)
        variables: dict[str, object] = {"_id": id, "description": description}
        response = await self.execute(
            query=query,
            operation_name="updateProjectDescription",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateProjectDescription.model_validate(data)

    async def update_groups(
        self, project_id: Any, groups: list[GroupInput], **kwargs: Any
    ) -> UpdateGroups:
        query = gql("""
            mutation updateGroups($projectID: ObjectID!, $groups: [GroupInput!]!) {
              updateGroups(projectID: $projectID, groups: $groups)
            }
            """)
        variables: dict[str, object] = {"projectID": project_id, "groups": groups}
        response = await self.execute(
            query=query, operation_name="updateGroups", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateGroups.model_validate(data)

    async def invite_user_to_project(
        self, project_id: Any, invitee_email: str, **kwargs: Any
    ) -> InviteUserToProject:
        query = gql("""
            mutation inviteUserToProject($projectID: ObjectID!, $inviteeEmail: String!) {
              inviteUserToProject(projectID: $projectID, inviteeEmail: $inviteeEmail)
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "inviteeEmail": invitee_email,
        }
        response = await self.execute(
            query=query,
            operation_name="inviteUserToProject",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return InviteUserToProject.model_validate(data)

    async def leave_project(self, project_id: Any, **kwargs: Any) -> LeaveProject:
        query = gql("""
            mutation leaveProject($projectID: ObjectID!) {
              leaveProject(projectID: $projectID)
            }
            """)
        variables: dict[str, object] = {"projectID": project_id}
        response = await self.execute(
            query=query, operation_name="leaveProject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return LeaveProject.model_validate(data)

    async def kick_collaborator(
        self, project_id: Any, collaborator_id: Any, **kwargs: Any
    ) -> KickCollaborator:
        query = gql("""
            mutation kickCollaborator($projectID: ObjectID!, $collaboratorID: ObjectID!) {
              kickCollaborator(projectID: $projectID, collaboratorID: $collaboratorID)
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "collaboratorID": collaborator_id,
        }
        response = await self.execute(
            query=query,
            operation_name="kickCollaborator",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return KickCollaborator.model_validate(data)

    async def cancel_invitation(
        self, invitation_id: Any, **kwargs: Any
    ) -> CancelInvitation:
        query = gql("""
            mutation cancelInvitation($invitationID: ObjectID!) {
              cancelInvitation(invitationID: $invitationID)
            }
            """)
        variables: dict[str, object] = {"invitationID": invitation_id}
        response = await self.execute(
            query=query,
            operation_name="cancelInvitation",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CancelInvitation.model_validate(data)

    async def update_project_icon(
        self, project_id: Any, icon_url: str, **kwargs: Any
    ) -> UpdateProjectIcon:
        query = gql("""
            mutation updateProjectIcon($projectID: ObjectID!, $iconURL: String!) {
              updateProjectIcon(projectID: $projectID, iconURL: $iconURL)
            }
            """)
        variables: dict[str, object] = {"projectID": project_id, "iconURL": icon_url}
        response = await self.execute(
            query=query,
            operation_name="updateProjectIcon",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateProjectIcon.model_validate(data)

    async def set_budget(
        self, project_id: Any, budget: int, **kwargs: Any
    ) -> SetBudget:
        query = gql("""
            mutation setBudget($projectID: ObjectID!, $budget: Int!) {
              setBudget(projectID: $projectID, budget: $budget)
            }
            """)
        variables: dict[str, object] = {"projectID": project_id, "budget": budget}
        response = await self.execute(
            query=query, operation_name="setBudget", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SetBudget.model_validate(data)

    async def clone_project(
        self,
        environment_id: Any,
        project_id: Any,
        target_region: str,
        suspend_old_project: bool,
        **kwargs: Any
    ) -> CloneProject:
        query = gql("""
            mutation cloneProject($environmentId: ObjectID!, $projectId: ObjectID!, $targetRegion: String!, $suspendOldProject: Boolean!) {
              cloneProject(
                environmentId: $environmentId
                projectId: $projectId
                targetRegion: $targetRegion
                suspendOldProject: $suspendOldProject
              ) {
                newProjectId
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentId": environment_id,
            "projectId": project_id,
            "targetRegion": target_region,
            "suspendOldProject": suspend_old_project,
        }
        response = await self.execute(
            query=query, operation_name="cloneProject", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return CloneProject.model_validate(data)

    async def register_server(
        self,
        ip: str,
        ssh_port: int,
        ssh_root_private_key: Union[Optional[str], UnsetType] = UNSET,
        ssh_root_password: Union[Optional[str], UnsetType] = UNSET,
        ssh_username: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> RegisterServer:
        query = gql("""
            mutation registerServer($ip: String!, $sshPort: Int!, $sshRootPrivateKey: String, $sshRootPassword: String, $sshUsername: String) {
              registerServer(
                ip: $ip
                sshPort: $sshPort
                sshRootPrivateKey: $sshRootPrivateKey
                sshRootPassword: $sshRootPassword
                sshUsername: $sshUsername
              ) {
                _id
                name
                ip
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                sshPort
                sshUsername
                status {
                  isOnline
                  totalCPU
                  usedCPU
                  totalMemory
                  usedMemory
                  warnings
                  vmStatus
                }
                createdAt
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                country
                city
                continent
                events {
                  message
                  time
                  severity
                }
                gpuInfo {
                  hasGPU
                  isReady
                  name
                }
                zeaburletStatus {
                  lastUpdatedAt
                }
                isManaged
                isAutoRenewDisabled
                expiresAt
                price
              }
            }
            """)
        variables: dict[str, object] = {
            "ip": ip,
            "sshPort": ssh_port,
            "sshRootPrivateKey": ssh_root_private_key,
            "sshRootPassword": ssh_root_password,
            "sshUsername": ssh_username,
        }
        response = await self.execute(
            query=query, operation_name="registerServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RegisterServer.model_validate(data)

    async def unregister_server(self, id: Any, **kwargs: Any) -> UnregisterServer:
        query = gql("""
            mutation unregisterServer($_id: ObjectID!) {
              unregisterServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query,
            operation_name="unregisterServer",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UnregisterServer.model_validate(data)

    async def update_server_name(
        self, id: Any, name: str, **kwargs: Any
    ) -> UpdateServerName:
        query = gql("""
            mutation updateServerName($_id: ObjectID!, $name: String!) {
              updateServerName(_id: $_id, name: $name)
            }
            """)
        variables: dict[str, object] = {"_id": id, "name": name}
        response = await self.execute(
            query=query,
            operation_name="updateServerName",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServerName.model_validate(data)

    async def update_server_credentials(
        self,
        id: Any,
        ssh_root_private_key: Union[Optional[str], UnsetType] = UNSET,
        ssh_root_password: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateServerCredentials:
        query = gql("""
            mutation updateServerCredentials($_id: ObjectID!, $sshRootPrivateKey: String, $sshRootPassword: String) {
              updateServerCredentials(
                _id: $_id
                sshRootPrivateKey: $sshRootPrivateKey
                sshRootPassword: $sshRootPassword
              )
            }
            """)
        variables: dict[str, object] = {
            "_id": id,
            "sshRootPrivateKey": ssh_root_private_key,
            "sshRootPassword": ssh_root_password,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServerCredentials",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServerCredentials.model_validate(data)

    async def rent_server(
        self, provider: str, region: str, plan: str, **kwargs: Any
    ) -> RentServer:
        query = gql("""
            mutation rentServer($provider: String!, $region: String!, $plan: String!) {
              rentServer(provider: $provider, region: $region, plan: $plan) {
                _id
                name
                ip
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                sshPort
                sshUsername
                status {
                  isOnline
                  totalCPU
                  usedCPU
                  totalMemory
                  usedMemory
                  warnings
                  vmStatus
                }
                createdAt
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                country
                city
                continent
                events {
                  message
                  time
                  severity
                }
                gpuInfo {
                  hasGPU
                  isReady
                  name
                }
                zeaburletStatus {
                  lastUpdatedAt
                }
                isManaged
                isAutoRenewDisabled
                expiresAt
                price
              }
            }
            """)
        variables: dict[str, object] = {
            "provider": provider,
            "region": region,
            "plan": plan,
        }
        response = await self.execute(
            query=query, operation_name="rentServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RentServer.model_validate(data)

    async def reconcile_server(self, id: Any, **kwargs: Any) -> ReconcileServer:
        query = gql("""
            mutation reconcileServer($_id: ObjectID!) {
              reconcileServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="reconcileServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return ReconcileServer.model_validate(data)

    async def poweroff_server(self, id: Any, **kwargs: Any) -> PoweroffServer:
        query = gql("""
            mutation poweroffServer($_id: ObjectID!) {
              poweroffServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="poweroffServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return PoweroffServer.model_validate(data)

    async def poweron_server(self, id: Any, **kwargs: Any) -> PoweronServer:
        query = gql("""
            mutation poweronServer($_id: ObjectID!) {
              poweronServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="poweronServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return PoweronServer.model_validate(data)

    async def reboot_server(self, id: Any, **kwargs: Any) -> RebootServer:
        query = gql("""
            mutation rebootServer($_id: ObjectID!) {
              rebootServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="rebootServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RebootServer.model_validate(data)

    async def reinstall_server(self, id: Any, **kwargs: Any) -> ReinstallServer:
        query = gql("""
            mutation reinstallServer($_id: ObjectID!) {
              reinstallServer(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="reinstallServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return ReinstallServer.model_validate(data)

    async def reveal_managed_server_initial_password(
        self, server_id: Any, **kwargs: Any
    ) -> RevealManagedServerInitialPassword:
        query = gql("""
            mutation revealManagedServerInitialPassword($serverID: ObjectID!) {
              revealManagedServerInitialPassword(serverID: $serverID)
            }
            """)
        variables: dict[str, object] = {"serverID": server_id}
        response = await self.execute(
            query=query,
            operation_name="revealManagedServerInitialPassword",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return RevealManagedServerInitialPassword.model_validate(data)

    async def reload_k_3_s_config(
        self, server_id: Any, **kwargs: Any
    ) -> ReloadK3sConfig:
        query = gql("""
            mutation reloadK3sConfig($serverID: ObjectID!) {
              reloadK3sConfig(serverID: $serverID)
            }
            """)
        variables: dict[str, object] = {"serverID": server_id}
        response = await self.execute(
            query=query, operation_name="reloadK3sConfig", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return ReloadK3sConfig.model_validate(data)

    async def update_server_auto_renew(
        self, server_id: Any, auto_renew: bool, **kwargs: Any
    ) -> UpdateServerAutoRenew:
        query = gql("""
            mutation updateServerAutoRenew($serverID: ObjectID!, $autoRenew: Boolean!) {
              updateServerAutoRenew(serverID: $serverID, autoRenew: $autoRenew)
            }
            """)
        variables: dict[str, object] = {"serverID": server_id, "autoRenew": auto_renew}
        response = await self.execute(
            query=query,
            operation_name="updateServerAutoRenew",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServerAutoRenew.model_validate(data)

    async def renew_server(self, server_id: Any, **kwargs: Any) -> RenewServer:
        query = gql("""
            mutation renewServer($serverID: ObjectID!) {
              renewServer(serverID: $serverID)
            }
            """)
        variables: dict[str, object] = {"serverID": server_id}
        response = await self.execute(
            query=query, operation_name="renewServer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RenewServer.model_validate(data)

    async def create_service(
        self,
        name: str,
        template: ServiceTemplate,
        project_id: Any,
        git_provider: Union[Optional[GitProvider], UnsetType] = UNSET,
        repo_id: Union[Optional[int], UnsetType] = UNSET,
        root_directory: Union[Optional[str], UnsetType] = UNSET,
        branch_name: Union[Optional[str], UnsetType] = UNSET,
        custom_build_command: Union[Optional[str], UnsetType] = UNSET,
        custom_start_command: Union[Optional[str], UnsetType] = UNSET,
        variables: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CreateService:
        query = gql("""
            mutation createService($name: String!, $template: ServiceTemplate!, $projectID: ObjectID!, $gitProvider: GitProvider, $repoID: Int, $rootDirectory: String, $branchName: String, $customBuildCommand: String, $customStartCommand: String, $variables: Map) {
              createService(
                name: $name
                template: $template
                projectID: $projectID
                gitProvider: $gitProvider
                repoID: $repoID
                rootDirectory: $rootDirectory
                branchName: $branchName
                customBuildCommand: $customBuildCommand
                customStartCommand: $customStartCommand
                variables: $variables
              ) {
                _id
                name
                template
                project {
                  _id
                  name
                  description
                  iconURL
                  createdAt
                  owner {
                    _id
                  }
                  collaborators {
                    _id
                  }
                  invitations {
                    _id
                  }
                  region {
                    id
                  }
                  pullRequest
                  environments {
                    _id
                  }
                  services {
                    _id
                  }
                }
                watchPaths
                rootDirectory
                customBuildCommand
                customStartCommand
                outputDir
                resourceLimit {
                  cpu
                  memory
                }
                createdAt
                marketItemCode
                spec {
                  id
                  name
                  icon
                  ports {
                    id
                  }
                  volumes {
                    id
                  }
                  initRules {
                    id
                  }
                }
                marketplaceItem {
                  code
                  name
                  iconURL
                  description
                  networkType
                }
                status
                dnsName
                portForwardedHost
                healthCheckV2 {
                  type
                  port
                }
                suspendedAt
                onceProduct
                failureThreshold
                deployments {
                  _id
                  gitProvider
                  repoOwner
                  repoName
                  ref
                  commitSHA
                  commitMessage
                  projectID
                  serviceID
                  environmentID
                  status
                  createdAt
                  planType
                  planMeta
                  scheduledAt
                  startedAt
                  finishedAt
                  canceledAt
                  serverless
                }
                domains {
                  _id
                  domain
                  redirectTo
                  serviceID
                  projectID
                  environmentID
                  status
                  statusReason
                  createdAt
                  portName
                  isGenerated
                }
              }
            }
            """)
        _variables: dict[str, object] = {
            "name": name,
            "template": template,
            "projectID": project_id,
            "gitProvider": git_provider,
            "repoID": repo_id,
            "rootDirectory": root_directory,
            "branchName": branch_name,
            "customBuildCommand": custom_build_command,
            "customStartCommand": custom_start_command,
            "variables": variables,
        }
        response = await self.execute(
            query=query, operation_name="createService", variables=_variables, **kwargs
        )
        data = self.get_data(response)
        return CreateService.model_validate(data)

    async def create_prebuilt_service(
        self,
        project_id: Any,
        schema: Union[Optional[ServiceSpecSchemaInput], UnsetType] = UNSET,
        raw_schema: Union[Optional[str], UnsetType] = UNSET,
        marketplace_code: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CreatePrebuiltService:
        query = gql("""
            mutation createPrebuiltService($projectID: ObjectID!, $schema: ServiceSpecSchemaInput, $rawSchema: String, $marketplaceCode: String) {
              createPrebuiltService(
                projectID: $projectID
                schema: $schema
                rawSchema: $rawSchema
                marketplaceCode: $marketplaceCode
              ) {
                _id
                name
                template
                project {
                  _id
                  name
                  description
                  iconURL
                  createdAt
                  owner {
                    _id
                  }
                  collaborators {
                    _id
                  }
                  invitations {
                    _id
                  }
                  region {
                    id
                  }
                  pullRequest
                  environments {
                    _id
                  }
                  services {
                    _id
                  }
                }
                watchPaths
                rootDirectory
                customBuildCommand
                customStartCommand
                outputDir
                resourceLimit {
                  cpu
                  memory
                }
                createdAt
                marketItemCode
                spec {
                  id
                  name
                  icon
                  ports {
                    id
                  }
                  volumes {
                    id
                  }
                  initRules {
                    id
                  }
                }
                marketplaceItem {
                  code
                  name
                  iconURL
                  description
                  networkType
                }
                status
                dnsName
                portForwardedHost
                healthCheckV2 {
                  type
                  port
                }
                suspendedAt
                onceProduct
                failureThreshold
                deployments {
                  _id
                  gitProvider
                  repoOwner
                  repoName
                  ref
                  commitSHA
                  commitMessage
                  projectID
                  serviceID
                  environmentID
                  status
                  createdAt
                  planType
                  planMeta
                  scheduledAt
                  startedAt
                  finishedAt
                  canceledAt
                  serverless
                }
                domains {
                  _id
                  domain
                  redirectTo
                  serviceID
                  projectID
                  environmentID
                  status
                  statusReason
                  createdAt
                  portName
                  isGenerated
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "schema": schema,
            "rawSchema": raw_schema,
            "marketplaceCode": marketplace_code,
        }
        response = await self.execute(
            query=query,
            operation_name="createPrebuiltService",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreatePrebuiltService.model_validate(data)

    async def delete_service(self, id: Any, **kwargs: Any) -> DeleteService:
        query = gql("""
            mutation deleteService($_id: ObjectID!) {
              deleteService(_id: $_id)
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="deleteService", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteService.model_validate(data)

    async def update_watch_paths(
        self, service_id: Any, watch_paths: list[str], **kwargs: Any
    ) -> UpdateWatchPaths:
        query = gql("""
            mutation updateWatchPaths($serviceID: ObjectID!, $watchPaths: [String!]!) {
              updateWatchPaths(serviceID: $serviceID, watchPaths: $watchPaths) {
                _id
                name
                template
                project {
                  _id
                  name
                  description
                  iconURL
                  createdAt
                  owner {
                    _id
                  }
                  collaborators {
                    _id
                  }
                  invitations {
                    _id
                  }
                  region {
                    id
                  }
                  pullRequest
                  environments {
                    _id
                  }
                  services {
                    _id
                  }
                }
                watchPaths
                rootDirectory
                customBuildCommand
                customStartCommand
                outputDir
                resourceLimit {
                  cpu
                  memory
                }
                createdAt
                marketItemCode
                spec {
                  id
                  name
                  icon
                  ports {
                    id
                  }
                  volumes {
                    id
                  }
                  initRules {
                    id
                  }
                }
                marketplaceItem {
                  code
                  name
                  iconURL
                  description
                  networkType
                }
                status
                dnsName
                portForwardedHost
                healthCheckV2 {
                  type
                  port
                }
                suspendedAt
                onceProduct
                failureThreshold
                deployments {
                  _id
                  gitProvider
                  repoOwner
                  repoName
                  ref
                  commitSHA
                  commitMessage
                  projectID
                  serviceID
                  environmentID
                  status
                  createdAt
                  planType
                  planMeta
                  scheduledAt
                  startedAt
                  finishedAt
                  canceledAt
                  serverless
                }
                domains {
                  _id
                  domain
                  redirectTo
                  serviceID
                  projectID
                  environmentID
                  status
                  statusReason
                  createdAt
                  portName
                  isGenerated
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "watchPaths": watch_paths,
        }
        response = await self.execute(
            query=query,
            operation_name="updateWatchPaths",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateWatchPaths.model_validate(data)

    async def update_git_trigger(
        self,
        service_id: Any,
        environment_id: Any,
        trigger: Union[Optional[TriggerInput], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateGitTrigger:
        query = gql("""
            mutation updateGitTrigger($serviceID: ObjectID!, $environmentID: ObjectID!, $trigger: TriggerInput) {
              updateGitTrigger(
                serviceID: $serviceID
                environmentID: $environmentID
                trigger: $trigger
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "trigger": trigger,
        }
        response = await self.execute(
            query=query,
            operation_name="updateGitTrigger",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateGitTrigger.model_validate(data)

    async def update_root_directory(
        self, service_id: Any, root_directory: str, **kwargs: Any
    ) -> UpdateRootDirectory:
        query = gql("""
            mutation updateRootDirectory($serviceID: ObjectID!, $rootDirectory: String!) {
              updateRootDirectory(serviceID: $serviceID, rootDirectory: $rootDirectory)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "rootDirectory": root_directory,
        }
        response = await self.execute(
            query=query,
            operation_name="updateRootDirectory",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateRootDirectory.model_validate(data)

    async def update_service_image_tag(
        self, service_id: Any, environment_id: Any, tag: str, **kwargs: Any
    ) -> UpdateServiceImageTag:
        query = gql("""
            mutation updateServiceImageTag($serviceID: ObjectID!, $environmentID: ObjectID!, $tag: String!) {
              updateServiceImageTag(
                serviceID: $serviceID
                environmentID: $environmentID
                tag: $tag
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "tag": tag,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceImageTag",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceImageTag.model_validate(data)

    async def update_service_command(
        self, service_id: Any, command: str, **kwargs: Any
    ) -> UpdateServiceCommand:
        query = gql("""
            mutation updateServiceCommand($serviceID: ObjectID!, $command: String!) {
              updateServiceCommand(serviceID: $serviceID, command: $command)
            }
            """)
        variables: dict[str, object] = {"serviceID": service_id, "command": command}
        response = await self.execute(
            query=query,
            operation_name="updateServiceCommand",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceCommand.model_validate(data)

    async def update_service_image_repo(
        self, service_id: Any, environment_id: Any, repository: str, **kwargs: Any
    ) -> UpdateServiceImageRepo:
        query = gql("""
            mutation updateServiceImageRepo($serviceID: ObjectID!, $environmentID: ObjectID!, $repository: String!) {
              updateServiceImageRepo(
                serviceID: $serviceID
                environmentID: $environmentID
                repository: $repository
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "repository": repository,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceImageRepo",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceImageRepo.model_validate(data)

    async def update_service_image_credential(
        self,
        service_id: Any,
        environment_id: Any,
        username: str,
        password: str,
        **kwargs: Any
    ) -> UpdateServiceImageCredential:
        query = gql("""
            mutation updateServiceImageCredential($serviceID: ObjectID!, $environmentID: ObjectID!, $username: String!, $password: String!) {
              updateServiceImageCredential(
                serviceID: $serviceID
                environmentID: $environmentID
                username: $username
                password: $password
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "username": username,
            "password": password,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceImageCredential",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceImageCredential.model_validate(data)

    async def update_service_dns_name(
        self, service_id: Any, dns_name: str, **kwargs: Any
    ) -> UpdateServiceDNSName:
        query = gql("""
            mutation updateServiceDNSName($serviceID: ObjectID!, $dnsName: String!) {
              updateServiceDNSName(serviceID: $serviceID, dnsName: $dnsName)
            }
            """)
        variables: dict[str, object] = {"serviceID": service_id, "dnsName": dns_name}
        response = await self.execute(
            query=query,
            operation_name="updateServiceDNSName",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceDNSName.model_validate(data)

    async def redeploy_service(
        self, service_id: Any, environment_id: Any, **kwargs: Any
    ) -> RedeployService:
        query = gql("""
            mutation redeployService($serviceID: ObjectID!, $environmentID: ObjectID!) {
              redeployService(serviceID: $serviceID, environmentID: $environmentID)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
        }
        response = await self.execute(
            query=query, operation_name="redeployService", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RedeployService.model_validate(data)

    async def rename_service(self, id: Any, name: str, **kwargs: Any) -> RenameService:
        query = gql("""
            mutation renameService($_id: ObjectID!, $name: String!) {
              renameService(_id: $_id, name: $name)
            }
            """)
        variables: dict[str, object] = {"_id": id, "name": name}
        response = await self.execute(
            query=query, operation_name="renameService", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RenameService.model_validate(data)

    async def update_service_description(
        self, id: Any, description: str, **kwargs: Any
    ) -> UpdateServiceDescription:
        query = gql("""
            mutation updateServiceDescription($_id: ObjectID!, $description: String!) {
              updateServiceDescription(_id: $_id, description: $description)
            }
            """)
        variables: dict[str, object] = {"_id": id, "description": description}
        response = await self.execute(
            query=query,
            operation_name="updateServiceDescription",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceDescription.model_validate(data)

    async def restart_service(
        self, service_id: Any, environment_id: Any, **kwargs: Any
    ) -> RestartService:
        query = gql("""
            mutation restartService($serviceID: ObjectID!, $environmentID: ObjectID!) {
              restartService(serviceID: $serviceID, environmentID: $environmentID)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
        }
        response = await self.execute(
            query=query, operation_name="restartService", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RestartService.model_validate(data)

    async def suspend_service(
        self, service_id: Any, environment_id: Any, **kwargs: Any
    ) -> SuspendService:
        query = gql("""
            mutation suspendService($serviceID: ObjectID!, $environmentID: ObjectID!) {
              suspendService(serviceID: $serviceID, environmentID: $environmentID)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
        }
        response = await self.execute(
            query=query, operation_name="suspendService", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SuspendService.model_validate(data)

    async def update_service_config(
        self,
        service_id: Any,
        environment_id: Any,
        path: str,
        content: str,
        fill_current_content: bool,
        permission: Union[Optional[int], UnsetType] = UNSET,
        envsubst: Union[Optional[bool], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateServiceConfig:
        query = gql("""
            mutation updateServiceConfig($serviceID: ObjectID!, $environmentID: ObjectID!, $path: String!, $content: String!, $permission: Int, $envsubst: Boolean, $fillCurrentContent: Boolean!) {
              updateServiceConfig(
                serviceID: $serviceID
                environmentID: $environmentID
                path: $path
                content: $content
                permission: $permission
                envsubst: $envsubst
                fillCurrentContent: $fillCurrentContent
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "path": path,
            "content": content,
            "permission": permission,
            "envsubst": envsubst,
            "fillCurrentContent": fill_current_content,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceConfig",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceConfig.model_validate(data)

    async def delete_service_config(
        self, service_id: Any, environment_id: Any, path: str, **kwargs: Any
    ) -> DeleteServiceConfig:
        query = gql("""
            mutation deleteServiceConfig($serviceID: ObjectID!, $environmentID: ObjectID!, $path: String!) {
              deleteServiceConfig(
                serviceID: $serviceID
                environmentID: $environmentID
                path: $path
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "path": path,
        }
        response = await self.execute(
            query=query,
            operation_name="deleteServiceConfig",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DeleteServiceConfig.model_validate(data)

    async def check_docker_image(
        self,
        registry: str,
        image: str,
        tag: str,
        username: Union[Optional[str], UnsetType] = UNSET,
        password: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CheckDockerImage:
        query = gql("""
            mutation checkDockerImage($registry: String!, $image: String!, $tag: String!, $username: String, $password: String) {
              checkDockerImage(
                registry: $registry
                image: $image
                tag: $tag
                username: $username
                password: $password
              )
            }
            """)
        variables: dict[str, object] = {
            "registry": registry,
            "image": image,
            "tag": tag,
            "username": username,
            "password": password,
        }
        response = await self.execute(
            query=query,
            operation_name="checkDockerImage",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CheckDockerImage.model_validate(data)

    async def execute_command(
        self, service_id: Any, environment_id: Any, command: list[str], **kwargs: Any
    ) -> ExecuteCommand:
        query = gql("""
            mutation executeCommand($serviceID: ObjectID!, $environmentID: ObjectID!, $command: [String!]!) {
              executeCommand(
                serviceID: $serviceID
                environmentID: $environmentID
                command: $command
              ) {
                exitCode
                output
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "command": command,
        }
        response = await self.execute(
            query=query, operation_name="executeCommand", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return ExecuteCommand.model_validate(data)

    async def update_service_icon(
        self, service_id: Any, icon_url: str, **kwargs: Any
    ) -> UpdateServiceIcon:
        query = gql("""
            mutation updateServiceIcon($serviceID: ObjectID!, $iconURL: String!) {
              updateServiceIcon(serviceID: $serviceID, iconURL: $iconURL)
            }
            """)
        variables: dict[str, object] = {"serviceID": service_id, "iconURL": icon_url}
        response = await self.execute(
            query=query,
            operation_name="updateServiceIcon",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceIcon.model_validate(data)

    async def update_service_failure_threshold(
        self, service_id: Any, failure_threshold: int, **kwargs: Any
    ) -> UpdateServiceFailureThreshold:
        query = gql("""
            mutation updateServiceFailureThreshold($serviceID: ObjectID!, $failureThreshold: Int!) {
              updateServiceFailureThreshold(
                serviceID: $serviceID
                failureThreshold: $failureThreshold
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "failureThreshold": failure_threshold,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceFailureThreshold",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceFailureThreshold.model_validate(data)

    async def set_auto_restart(
        self,
        environment_id: Any,
        service_id: Any,
        enabled: bool,
        restart_hour: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> SetAutoRestart:
        query = gql("""
            mutation setAutoRestart($environmentID: ObjectID!, $serviceID: ObjectID!, $enabled: Boolean!, $restartHour: Int) {
              setAutoRestart(
                environmentID: $environmentID
                serviceID: $serviceID
                enabled: $enabled
                restartHour: $restartHour
              )
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "enabled": enabled,
            "restartHour": restart_hour,
        }
        response = await self.execute(
            query=query, operation_name="setAutoRestart", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return SetAutoRestart.model_validate(data)

    async def update_service_ports(
        self,
        service_id: Any,
        environment_id: Any,
        ports: list[ServiceSpecPortInput],
        **kwargs: Any
    ) -> UpdateServicePorts:
        query = gql("""
            mutation updateServicePorts($serviceID: ObjectID!, $environmentID: ObjectID!, $ports: [ServiceSpecPortInput!]!) {
              updateServicePorts(
                serviceID: $serviceID
                environmentID: $environmentID
                ports: $ports
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "ports": ports,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServicePorts",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServicePorts.model_validate(data)

    async def update_service_health_check_v_2(
        self,
        service_id: Any,
        health_check: Union[Optional[ServiceSpecHealthCheckInput], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateServiceHealthCheckV2:
        query = gql("""
            mutation updateServiceHealthCheckV2($serviceID: ObjectID!, $healthCheck: ServiceSpecHealthCheckInput) {
              updateServiceHealthCheckV2(serviceID: $serviceID, healthCheck: $healthCheck)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "healthCheck": health_check,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceHealthCheckV2",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceHealthCheckV2.model_validate(data)

    async def update_port_forwarding_mode(
        self,
        service_id: Any,
        environment_id: Any,
        mode: PortForwardingMode,
        **kwargs: Any
    ) -> UpdatePortForwardingMode:
        query = gql("""
            mutation updatePortForwardingMode($serviceID: ObjectID!, $environmentID: ObjectID!, $mode: PortForwardingMode!) {
              updatePortForwardingMode(
                serviceID: $serviceID
                environmentID: $environmentID
                mode: $mode
              )
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "mode": mode,
        }
        response = await self.execute(
            query=query,
            operation_name="updatePortForwardingMode",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdatePortForwardingMode.model_validate(data)

    async def update_dockerfile(
        self, service_id: Any, dockerfile: str, **kwargs: Any
    ) -> UpdateDockerfile:
        query = gql("""
            mutation updateDockerfile($serviceID: ObjectID!, $dockerfile: String!) {
              updateDockerfile(serviceID: $serviceID, dockerfile: $dockerfile)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "dockerfile": dockerfile,
        }
        response = await self.execute(
            query=query,
            operation_name="updateDockerfile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateDockerfile.model_validate(data)

    async def update_service_resource_limit(
        self, service_id: Any, resource_limit: ResourceLimitInput, **kwargs: Any
    ) -> UpdateServiceResourceLimit:
        query = gql("""
            mutation updateServiceResourceLimit($serviceID: ObjectID!, $resourceLimit: ResourceLimitInput!) {
              updateServiceResourceLimit(serviceID: $serviceID, resourceLimit: $resourceLimit)
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "resourceLimit": resource_limit,
        }
        response = await self.execute(
            query=query,
            operation_name="updateServiceResourceLimit",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateServiceResourceLimit.model_validate(data)

    async def create_template(
        self,
        name: str,
        description: str,
        create_service_inputs: list[createServiceInput],
        readme: str,
        cover_url: Union[Optional[str], UnsetType] = UNSET,
        icon_url: Union[Optional[str], UnsetType] = UNSET,
        preview_url: Union[Optional[str], UnsetType] = UNSET,
        variables: Union[Optional[list[TemplateVariableInput]], UnsetType] = UNSET,
        tags: Union[Optional[list[str]], UnsetType] = UNSET,
        **kwargs: Any
    ) -> CreateTemplate:
        query = gql("""
            mutation createTemplate($name: String!, $description: String!, $coverURL: String, $iconURL: String, $previewURL: String, $createServiceInputs: [createServiceInput!]!, $readme: String!, $variables: [TemplateVariableInput!], $tags: [String!]) {
              createTemplate(
                name: $name
                description: $description
                coverURL: $coverURL
                iconURL: $iconURL
                previewURL: $previewURL
                createServiceInputs: $createServiceInputs
                readme: $readme
                variables: $variables
                tags: $tags
              ) {
                code
                name
                description
                coverURL
                iconURL
                previewURL
                author {
                  username
                  avatarURL
                }
                createdAt
                readme
                resourceUsage {
                  cpu
                  memory
                }
                services {
                  name
                  template
                  gitRepoID
                  gitRepo {
                    id
                  }
                  branchName
                  customBuildCommand
                  customStartCommand
                  outputDir
                  rootDirectory
                  watchPaths
                  planType
                  planMeta
                  prebuiltItem {
                    id
                  }
                  variables
                  spec {
                    id
                  }
                }
                deploymentCnt
                tags
                variables {
                  type
                  question
                  key
                  desc
                }
              }
            }
            """)
        _variables: dict[str, object] = {
            "name": name,
            "description": description,
            "coverURL": cover_url,
            "iconURL": icon_url,
            "previewURL": preview_url,
            "createServiceInputs": create_service_inputs,
            "readme": readme,
            "variables": variables,
            "tags": tags,
        }
        response = await self.execute(
            query=query, operation_name="createTemplate", variables=_variables, **kwargs
        )
        data = self.get_data(response)
        return CreateTemplate.model_validate(data)

    async def update_template(
        self,
        code: str,
        name: Union[Optional[str], UnsetType] = UNSET,
        description: Union[Optional[str], UnsetType] = UNSET,
        cover_url: Union[Optional[str], UnsetType] = UNSET,
        icon_url: Union[Optional[str], UnsetType] = UNSET,
        preview_url: Union[Optional[str], UnsetType] = UNSET,
        create_service_inputs: Union[
            Optional[list[createServiceInput]], UnsetType
        ] = UNSET,
        readme: Union[Optional[str], UnsetType] = UNSET,
        variables: Union[Optional[list[TemplateVariableInput]], UnsetType] = UNSET,
        tags: Union[Optional[list[str]], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateTemplate:
        query = gql("""
            mutation updateTemplate($code: String!, $name: String, $description: String, $coverURL: String, $iconURL: String, $previewURL: String, $createServiceInputs: [createServiceInput!], $readme: String, $variables: [TemplateVariableInput!], $tags: [String!]) {
              updateTemplate(
                code: $code
                name: $name
                description: $description
                coverURL: $coverURL
                iconURL: $iconURL
                previewURL: $previewURL
                createServiceInputs: $createServiceInputs
                readme: $readme
                variables: $variables
                tags: $tags
              )
            }
            """)
        _variables: dict[str, object] = {
            "code": code,
            "name": name,
            "description": description,
            "coverURL": cover_url,
            "iconURL": icon_url,
            "previewURL": preview_url,
            "createServiceInputs": create_service_inputs,
            "readme": readme,
            "variables": variables,
            "tags": tags,
        }
        response = await self.execute(
            query=query, operation_name="updateTemplate", variables=_variables, **kwargs
        )
        data = self.get_data(response)
        return UpdateTemplate.model_validate(data)

    async def delete_template(self, code: str, **kwargs: Any) -> DeleteTemplate:
        query = gql("""
            mutation deleteTemplate($code: String!) {
              deleteTemplate(code: $code)
            }
            """)
        variables: dict[str, object] = {"code": code}
        response = await self.execute(
            query=query, operation_name="deleteTemplate", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return DeleteTemplate.model_validate(data)

    async def create_template_from_file(
        self, raw_spec_yaml: str, **kwargs: Any
    ) -> CreateTemplateFromFile:
        query = gql("""
            mutation createTemplateFromFile($rawSpecYaml: String!) {
              createTemplateFromFile(rawSpecYaml: $rawSpecYaml) {
                code
                name
                description
                coverURL
                iconURL
                previewURL
                author {
                  username
                  avatarURL
                }
                createdAt
                readme
                resourceUsage {
                  cpu
                  memory
                }
                services {
                  name
                  template
                  gitRepoID
                  gitRepo {
                    id
                  }
                  branchName
                  customBuildCommand
                  customStartCommand
                  outputDir
                  rootDirectory
                  watchPaths
                  planType
                  planMeta
                  prebuiltItem {
                    id
                  }
                  variables
                  spec {
                    id
                  }
                }
                deploymentCnt
                tags
                variables {
                  type
                  question
                  key
                  desc
                }
              }
            }
            """)
        variables: dict[str, object] = {"rawSpecYaml": raw_spec_yaml}
        response = await self.execute(
            query=query,
            operation_name="createTemplateFromFile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CreateTemplateFromFile.model_validate(data)

    async def update_template_from_file(
        self, code: str, raw_spec_yaml: str, **kwargs: Any
    ) -> UpdateTemplateFromFile:
        query = gql("""
            mutation updateTemplateFromFile($code: String!, $rawSpecYaml: String!) {
              updateTemplateFromFile(code: $code, rawSpecYaml: $rawSpecYaml)
            }
            """)
        variables: dict[str, object] = {"code": code, "rawSpecYaml": raw_spec_yaml}
        response = await self.execute(
            query=query,
            operation_name="updateTemplateFromFile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateTemplateFromFile.model_validate(data)

    async def deploy_template(
        self,
        code: Union[Optional[str], UnsetType] = UNSET,
        raw_spec_yaml: Union[Optional[str], UnsetType] = UNSET,
        variables: Union[Optional[Any], UnsetType] = UNSET,
        region: Union[Optional[str], UnsetType] = UNSET,
        project_id: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> DeployTemplate:
        query = gql("""
            mutation deployTemplate($code: String, $rawSpecYaml: String, $variables: Map, $region: String, $projectID: ObjectID) {
              deployTemplate(
                code: $code
                rawSpecYaml: $rawSpecYaml
                variables: $variables
                region: $region
                projectID: $projectID
              ) {
                _id
                name
                description
                iconURL
                createdAt
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                collaborators {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                invitations {
                  _id
                  inviter {
                    _id
                  }
                  invitee {
                    _id
                  }
                  email
                  project {
                    _id
                  }
                  invitedAt
                  acceptedAt
                  cancelledAt
                  leavedAt
                }
                region {
                  id
                  code
                  name
                  description
                  available
                  coordinates
                  continent
                  country
                  city
                }
                pullRequest
                groups {
                  name
                  serviceIDs
                }
                environments {
                  _id
                  name
                  projectID
                  createdAt
                }
                services {
                  _id
                  name
                  template
                  project {
                    _id
                  }
                  watchPaths
                  rootDirectory
                  customBuildCommand
                  customStartCommand
                  outputDir
                  createdAt
                  marketItemCode
                  spec {
                    id
                  }
                  status
                  dnsName
                  portForwardedHost
                  suspendedAt
                  onceProduct
                  failureThreshold
                  deployments {
                    _id
                  }
                  domains {
                    _id
                  }
                }
              }
            }
            """)
        _variables: dict[str, object] = {
            "code": code,
            "rawSpecYaml": raw_spec_yaml,
            "variables": variables,
            "region": region,
            "projectID": project_id,
        }
        response = await self.execute(
            query=query, operation_name="deployTemplate", variables=_variables, **kwargs
        )
        data = self.get_data(response)
        return DeployTemplate.model_validate(data)

    async def update_user_profile(
        self,
        name: Union[Optional[str], UnsetType] = UNSET,
        avatar_url: Union[Optional[str], UnsetType] = UNSET,
        language: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateUserProfile:
        query = gql("""
            mutation updateUserProfile($name: String, $avatarURL: String, $language: String) {
              updateUserProfile(name: $name, avatarURL: $avatarURL, language: $language)
            }
            """)
        variables: dict[str, object] = {
            "name": name,
            "avatarURL": avatar_url,
            "language": language,
        }
        response = await self.execute(
            query=query,
            operation_name="updateUserProfile",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateUserProfile.model_validate(data)

    async def request_phone_verification(
        self, phone_number: str, **kwargs: Any
    ) -> RequestPhoneVerification:
        query = gql("""
            mutation requestPhoneVerification($phoneNumber: String!) {
              requestPhoneVerification(phoneNumber: $phoneNumber) {
                verificationID
              }
            }
            """)
        variables: dict[str, object] = {"phoneNumber": phone_number}
        response = await self.execute(
            query=query,
            operation_name="requestPhoneVerification",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return RequestPhoneVerification.model_validate(data)

    async def verify_phone_verification(
        self, verification_id: str, code: str, phone_number: str, **kwargs: Any
    ) -> VerifyPhoneVerification:
        query = gql("""
            mutation verifyPhoneVerification($verificationID: String!, $code: String!, $phoneNumber: String!) {
              verifyPhoneVerification(
                verificationID: $verificationID
                code: $code
                phoneNumber: $phoneNumber
              )
            }
            """)
        variables: dict[str, object] = {
            "verificationID": verification_id,
            "code": code,
            "phoneNumber": phone_number,
        }
        response = await self.execute(
            query=query,
            operation_name="verifyPhoneVerification",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return VerifyPhoneVerification.model_validate(data)

    async def update_user_email_preference(
        self,
        build_failed: Union[Optional[bool], UnsetType] = UNSET,
        deployment_crashed: Union[Optional[bool], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UpdateUserEmailPreference:
        query = gql("""
            mutation updateUserEmailPreference($buildFailed: Boolean, $deploymentCrashed: Boolean) {
              updateUserEmailPreference(
                buildFailed: $buildFailed
                deploymentCrashed: $deploymentCrashed
              )
            }
            """)
        variables: dict[str, object] = {
            "buildFailed": build_failed,
            "deploymentCrashed": deployment_crashed,
        }
        response = await self.execute(
            query=query,
            operation_name="updateUserEmailPreference",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return UpdateUserEmailPreference.model_validate(data)

    async def recharge(
        self, quantity: int, payment_method_type: PaymentMethodType, **kwargs: Any
    ) -> Recharge:
        query = gql("""
            mutation recharge($quantity: Int!, $paymentMethodType: PaymentMethodType!) {
              recharge(quantity: $quantity, paymentMethodType: $paymentMethodType)
            }
            """)
        variables: dict[str, object] = {
            "quantity": quantity,
            "paymentMethodType": payment_method_type,
        }
        response = await self.execute(
            query=query, operation_name="recharge", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Recharge.model_validate(data)

    async def postgres_databases(
        self, environment_id: Any, service_id: Any, **kwargs: Any
    ) -> PostgresDatabases:
        query = gql("""
            query postgresDatabases($environmentID: ObjectID!, $serviceID: ObjectID!) {
              postgresDatabases(environmentID: $environmentID, serviceID: $serviceID) {
                name
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
        }
        response = await self.execute(
            query=query,
            operation_name="postgresDatabases",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return PostgresDatabases.model_validate(data)

    async def mysql_databases(
        self, environment_id: Any, service_id: Any, **kwargs: Any
    ) -> MysqlDatabases:
        query = gql("""
            query mysqlDatabases($environmentID: ObjectID!, $serviceID: ObjectID!) {
              mysqlDatabases(environmentID: $environmentID, serviceID: $serviceID) {
                name
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
        }
        response = await self.execute(
            query=query, operation_name="mysqlDatabases", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return MysqlDatabases.model_validate(data)

    async def backups(
        self, environment_id: Any, service_id: Any, **kwargs: Any
    ) -> Backups:
        query = gql("""
            query backups($environmentID: ObjectID!, $serviceID: ObjectID!) {
              backups(environmentID: $environmentID, serviceID: $serviceID) {
                _id
                environmentID
                serviceID
                fileSize
                downloadURL
                status
                createdAt
                finishedAt
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
        }
        response = await self.execute(
            query=query, operation_name="backups", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Backups.model_validate(data)

    async def backup(self, backup_job_id: Any, **kwargs: Any) -> Backup:
        query = gql("""
            query backup($backupJobID: ObjectID!) {
              backup(backupJobID: $backupJobID) {
                _id
                environmentID
                serviceID
                fileSize
                downloadURL
                status
                createdAt
                finishedAt
              }
            }
            """)
        variables: dict[str, object] = {"backupJobID": backup_job_id}
        response = await self.execute(
            query=query, operation_name="backup", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Backup.model_validate(data)

    async def buckets(
        self, environment_id: Any, service_id: Any, **kwargs: Any
    ) -> Buckets:
        query = gql("""
            query buckets($environmentID: ObjectID!, $serviceID: ObjectID!) {
              buckets(environmentID: $environmentID, serviceID: $serviceID) {
                name
                creationDate
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
        }
        response = await self.execute(
            query=query, operation_name="buckets", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Buckets.model_validate(data)

    async def objects(
        self,
        environment_id: Any,
        service_id: Any,
        bucket_name: str,
        prefix: Union[Optional[str], UnsetType] = UNSET,
        max_keys: Union[Optional[int], UnsetType] = UNSET,
        continuation_token: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Objects:
        query = gql("""
            query objects($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!, $prefix: String, $maxKeys: Int, $continuationToken: String) {
              objects(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
                prefix: $prefix
                maxKeys: $maxKeys
                continuationToken: $continuationToken
              ) {
                objects {
                  key
                  size
                  etag
                  lastModified
                  storageClass
                  contentType
                }
                isTruncated
                nextContinuationToken
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
            "prefix": prefix,
            "maxKeys": max_keys,
            "continuationToken": continuation_token,
        }
        response = await self.execute(
            query=query, operation_name="objects", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Objects.model_validate(data)

    async def object(
        self,
        environment_id: Any,
        service_id: Any,
        bucket_name: str,
        object_key: str,
        **kwargs: Any
    ) -> Object:
        query = gql("""
            query object($environmentID: ObjectID!, $serviceID: ObjectID!, $bucketName: String!, $objectKey: String!) {
              object(
                environmentID: $environmentID
                serviceID: $serviceID
                bucketName: $bucketName
                objectKey: $objectKey
              ) {
                key
                size
                etag
                lastModified
                storageClass
                contentType
              }
            }
            """)
        variables: dict[str, object] = {
            "environmentID": environment_id,
            "serviceID": service_id,
            "bucketName": bucket_name,
            "objectKey": object_key,
        }
        response = await self.execute(
            query=query, operation_name="object", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Object.model_validate(data)

    async def deployments(
        self,
        service_id: Any,
        environment_id: Any,
        cursor: Union[Optional[str], UnsetType] = UNSET,
        per_page: Union[Optional[int], UnsetType] = UNSET,
        filter: Union[Optional[DeploymentStatus], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Deployments:
        query = gql("""
            query deployments($serviceID: ObjectID!, $environmentID: ObjectID!, $cursor: String, $perPage: Int, $filter: DeploymentStatus) {
              deployments(
                serviceID: $serviceID
                environmentID: $environmentID
                cursor: $cursor
                perPage: $perPage
                filter: $filter
              ) {
                edges {
                  node {
                    _id
                  }
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
            "cursor": cursor,
            "perPage": per_page,
            "filter": filter,
        }
        response = await self.execute(
            query=query, operation_name="deployments", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Deployments.model_validate(data)

    async def deployment(self, id: Any, **kwargs: Any) -> Deployment:
        query = gql("""
            query deployment($_id: ObjectID!) {
              deployment(_id: $_id) {
                _id
                gitProvider
                repoOwner
                repoName
                ref
                commitSHA
                commitMessage
                projectID
                serviceID
                environmentID
                status
                createdAt
                planType
                planMeta
                scheduledAt
                startedAt
                finishedAt
                canceledAt
                serverless
              }
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="deployment", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Deployment.model_validate(data)

    async def build_plan(
        self,
        upload_id: Union[Optional[Any], UnsetType] = UNSET,
        deployment_id: Union[Optional[Any], UnsetType] = UNSET,
        git_ref: Union[Optional[GitRef], UnsetType] = UNSET,
        submodule_name: Union[Optional[str], UnsetType] = UNSET,
        variables: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> BuildPlan:
        query = gql("""
            query buildPlan($uploadID: ObjectID, $deploymentID: ObjectID, $gitRef: GitRef, $submoduleName: String, $variables: Map) {
              buildPlan(
                uploadID: $uploadID
                deploymentID: $deploymentID
                gitRef: $gitRef
                submoduleName: $submoduleName
                variables: $variables
              ) {
                key
                value
                name
                description
                icon
              }
            }
            """)
        _variables: dict[str, object] = {
            "uploadID": upload_id,
            "deploymentID": deployment_id,
            "gitRef": git_ref,
            "submoduleName": submodule_name,
            "variables": variables,
        }
        response = await self.execute(
            query=query, operation_name="buildPlan", variables=_variables, **kwargs
        )
        data = self.get_data(response)
        return BuildPlan.model_validate(data)

    async def files(
        self,
        upload_id: Union[Optional[Any], UnsetType] = UNSET,
        git_ref: Union[Optional[GitRef], UnsetType] = UNSET,
        path: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Files:
        query = gql("""
            query files($uploadID: ObjectID, $gitRef: GitRef, $path: String) {
              files(uploadID: $uploadID, gitRef: $gitRef, path: $path)
            }
            """)
        variables: dict[str, object] = {
            "uploadID": upload_id,
            "gitRef": git_ref,
            "path": path,
        }
        response = await self.execute(
            query=query, operation_name="files", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Files.model_validate(data)

    async def file_content(
        self,
        upload_id: Union[Optional[Any], UnsetType] = UNSET,
        git_ref: Union[Optional[GitRef], UnsetType] = UNSET,
        path: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> FileContent:
        query = gql("""
            query fileContent($uploadID: ObjectID, $gitRef: GitRef, $path: String) {
              fileContent(uploadID: $uploadID, gitRef: $gitRef, path: $path)
            }
            """)
        variables: dict[str, object] = {
            "uploadID": upload_id,
            "gitRef": git_ref,
            "path": path,
        }
        response = await self.execute(
            query=query, operation_name="fileContent", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return FileContent.model_validate(data)

    async def environments(self, project_id: Any, **kwargs: Any) -> Environments:
        query = gql("""
            query environments($projectID: ObjectID!) {
              environments(projectID: $projectID) {
                _id
                name
                projectID
                createdAt
              }
            }
            """)
        variables: dict[str, object] = {"projectID": project_id}
        response = await self.execute(
            query=query, operation_name="environments", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Environments.model_validate(data)

    async def environment(self, id: Any, **kwargs: Any) -> Environment:
        query = gql("""
            query environment($_id: ObjectID!) {
              environment(_id: $_id) {
                _id
                name
                projectID
                createdAt
              }
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="environment", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Environment.model_validate(data)

    async def git_repositories(
        self, git_namespace_id: int, provider: GitProvider, **kwargs: Any
    ) -> GitRepositories:
        query = gql("""
            query gitRepositories($gitNamespaceID: Int!, $provider: GitProvider!) {
              gitRepositories(gitNamespaceID: $gitNamespaceID, provider: $provider) {
                id
                name
                provider
                url
                pushedAt
                updatedAt
                owner
              }
            }
            """)
        variables: dict[str, object] = {
            "gitNamespaceID": git_namespace_id,
            "provider": provider,
        }
        response = await self.execute(
            query=query, operation_name="gitRepositories", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return GitRepositories.model_validate(data)

    async def latest_git_repositories(
        self,
        provider: GitProvider,
        limit: int,
        git_namespace_id: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> LatestGitRepositories:
        query = gql("""
            query latestGitRepositories($provider: GitProvider!, $limit: Int!, $gitNamespaceID: Int) {
              latestGitRepositories(
                provider: $provider
                limit: $limit
                gitNamespaceID: $gitNamespaceID
              ) {
                id
                name
                provider
                url
                pushedAt
                updatedAt
                owner
              }
            }
            """)
        variables: dict[str, object] = {
            "provider": provider,
            "limit": limit,
            "gitNamespaceID": git_namespace_id,
        }
        response = await self.execute(
            query=query,
            operation_name="latestGitRepositories",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return LatestGitRepositories.model_validate(data)

    async def search_git_repositories(
        self,
        provider: GitProvider,
        limit: int,
        git_namespace_id: Union[Optional[int], UnsetType] = UNSET,
        keyword: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> SearchGitRepositories:
        query = gql("""
            query searchGitRepositories($provider: GitProvider!, $Limit: Int!, $gitNamespaceID: Int, $keyword: String) {
              searchGitRepositories(
                provider: $provider
                Limit: $Limit
                gitNamespaceID: $gitNamespaceID
                keyword: $keyword
              ) {
                id
                name
                provider
                url
                pushedAt
                updatedAt
                owner
              }
            }
            """)
        variables: dict[str, object] = {
            "provider": provider,
            "Limit": limit,
            "gitNamespaceID": git_namespace_id,
            "keyword": keyword,
        }
        response = await self.execute(
            query=query,
            operation_name="searchGitRepositories",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return SearchGitRepositories.model_validate(data)

    async def git_repo_branches(self, repo_id: int, **kwargs: Any) -> GitRepoBranches:
        query = gql("""
            query gitRepoBranches($repoID: Int!) {
              gitRepoBranches(repoID: $repoID)
            }
            """)
        variables: dict[str, object] = {"repoID": repo_id}
        response = await self.execute(
            query=query, operation_name="gitRepoBranches", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return GitRepoBranches.model_validate(data)

    async def build_logs(
        self,
        deployment_id: Any,
        project_id: Union[Optional[Any], UnsetType] = UNSET,
        timestamp_cursor: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> BuildLogs:
        query = gql("""
            query buildLogs($projectID: ObjectID, $deploymentID: ObjectID!, $timestampCursor: Time) {
              buildLogs(
                projectID: $projectID
                deploymentID: $deploymentID
                timestampCursor: $timestampCursor
              ) {
                message
                timestamp
              }
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "deploymentID": deployment_id,
            "timestampCursor": timestamp_cursor,
        }
        response = await self.execute(
            query=query, operation_name="buildLogs", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return BuildLogs.model_validate(data)

    async def runtime_logs(
        self,
        service_id: Any,
        project_id: Union[Optional[Any], UnsetType] = UNSET,
        environment_id: Union[Optional[Any], UnsetType] = UNSET,
        deployment_id: Union[Optional[Any], UnsetType] = UNSET,
        timestamp_cursor: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> RuntimeLogs:
        query = gql("""
            query runtimeLogs($projectID: ObjectID, $serviceID: ObjectID!, $environmentID: ObjectID, $deploymentID: ObjectID, $timestampCursor: Time) {
              runtimeLogs(
                projectID: $projectID
                serviceID: $serviceID
                environmentID: $environmentID
                deploymentID: $deploymentID
                timestampCursor: $timestampCursor
              ) {
                message
                timestamp
                region
                stream
                zeaburUID
              }
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "serviceID": service_id,
            "environmentID": environment_id,
            "deploymentID": deployment_id,
            "timestampCursor": timestamp_cursor,
        }
        response = await self.execute(
            query=query, operation_name="runtimeLogs", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return RuntimeLogs.model_validate(data)

    async def project_usage(
        self, project_id: Any, usage_group_by_entity: UsageGroupByEntity, **kwargs: Any
    ) -> ProjectUsage:
        query = gql("""
            query projectUsage($projectID: ObjectID!, $usageGroupByEntity: UsageGroupByEntity!) {
              projectUsage(projectID: $projectID, usageGroupByEntity: $usageGroupByEntity) {
                usages {
                  usage
                  entity
                }
                budget
                periodStart
                periodEnd
              }
            }
            """)
        variables: dict[str, object] = {
            "projectID": project_id,
            "usageGroupByEntity": usage_group_by_entity,
        }
        response = await self.execute(
            query=query, operation_name="projectUsage", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return ProjectUsage.model_validate(data)

    async def usages(
        self,
        from_: str,
        to: str,
        user_id: Any,
        group_by_entity: Union[Optional[GroupByEntity], UnsetType] = UNSET,
        group_by_time: Union[Optional[GroupByTime], UnsetType] = UNSET,
        group_by_type: Union[Optional[GroupByType], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Usages:
        query = gql("""
            query usages($from: String!, $to: String!, $userID: ObjectID!, $groupByEntity: GroupByEntity, $groupByTime: GroupByTime, $groupByType: GroupByType) {
              usages(
                from: $from
                to: $to
                userID: $userID
                groupByEntity: $groupByEntity
                groupByTime: $groupByTime
                groupByType: $groupByType
              ) {
                data {
                  id
                  name
                  groupByEntity
                  usageOfEntity
                }
                categories
              }
            }
            """)
        variables: dict[str, object] = {
            "from": from_,
            "to": to,
            "userID": user_id,
            "groupByEntity": group_by_entity,
            "groupByTime": group_by_time,
            "groupByType": group_by_type,
        }
        response = await self.execute(
            query=query, operation_name="usages", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Usages.model_validate(data)

    async def projects(
        self,
        skip: Union[Optional[int], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        region: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Projects:
        query = gql("""
            query projects($skip: Int, $limit: Int, $region: String) {
              projects(skip: $skip, limit: $limit, region: $region) {
                pageInfo {
                  totalCount
                  hasNextPage
                  hasPreviousPage
                  startCursor
                  endCursor
                }
                edges {
                  node {
                    _id
                  }
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {"skip": skip, "limit": limit, "region": region}
        response = await self.execute(
            query=query, operation_name="projects", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Projects.model_validate(data)

    async def project(
        self,
        id: Union[Optional[Any], UnsetType] = UNSET,
        owner: Union[Optional[str], UnsetType] = UNSET,
        name: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Project:
        query = gql("""
            query project($_id: ObjectID, $owner: String, $name: String) {
              project(_id: $_id, owner: $owner, name: $name) {
                _id
                name
                description
                iconURL
                createdAt
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                collaborators {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                invitations {
                  _id
                  inviter {
                    _id
                  }
                  invitee {
                    _id
                  }
                  email
                  project {
                    _id
                  }
                  invitedAt
                  acceptedAt
                  cancelledAt
                  leavedAt
                }
                region {
                  id
                  code
                  name
                  description
                  available
                  coordinates
                  continent
                  country
                  city
                }
                pullRequest
                groups {
                  name
                  serviceIDs
                }
                environments {
                  _id
                  name
                  projectID
                  createdAt
                }
                services {
                  _id
                  name
                  template
                  project {
                    _id
                  }
                  watchPaths
                  rootDirectory
                  customBuildCommand
                  customStartCommand
                  outputDir
                  createdAt
                  marketItemCode
                  spec {
                    id
                  }
                  status
                  dnsName
                  portForwardedHost
                  suspendedAt
                  onceProduct
                  failureThreshold
                  deployments {
                    _id
                  }
                  domains {
                    _id
                  }
                }
              }
            }
            """)
        variables: dict[str, object] = {"_id": id, "owner": owner, "name": name}
        response = await self.execute(
            query=query, operation_name="project", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Project.model_validate(data)

    async def regions(self, **kwargs: Any) -> Regions:
        query = gql("""
            query regions {
              regions {
                id
                code
                name
                description
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                available
                coordinates
                continent
                country
                city
              }
            }
            """)
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query, operation_name="regions", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Regions.model_validate(data)

    async def clone_project_status(
        self, new_project_id: Any, **kwargs: Any
    ) -> CloneProjectStatus:
        query = gql("""
            query cloneProjectStatus($newProjectId: ObjectID!) {
              cloneProjectStatus(newProjectId: $newProjectId) {
                newProjectId
                events {
                  type
                  createdAt
                  message
                }
                error
              }
            }
            """)
        variables: dict[str, object] = {"newProjectId": new_project_id}
        response = await self.execute(
            query=query,
            operation_name="cloneProjectStatus",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return CloneProjectStatus.model_validate(data)

    async def server(self, id: Any, **kwargs: Any) -> Server:
        query = gql("""
            query server($_id: ObjectID!) {
              server(_id: $_id) {
                _id
                name
                ip
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                sshPort
                sshUsername
                status {
                  isOnline
                  totalCPU
                  usedCPU
                  totalMemory
                  usedMemory
                  warnings
                  vmStatus
                }
                createdAt
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                country
                city
                continent
                events {
                  message
                  time
                  severity
                }
                gpuInfo {
                  hasGPU
                  isReady
                  name
                }
                zeaburletStatus {
                  lastUpdatedAt
                }
                isManaged
                isAutoRenewDisabled
                expiresAt
                price
              }
            }
            """)
        variables: dict[str, object] = {"_id": id}
        response = await self.execute(
            query=query, operation_name="server", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Server.model_validate(data)

    async def servers(self, **kwargs: Any) -> Servers:
        query = gql("""
            query servers {
              servers {
                _id
                name
                ip
                owner {
                  _id
                  name
                  email
                  language
                  githubID
                  discordID
                  avatarURL
                  createdAt
                  emailPreference
                  referralCode
                  username
                  referralRewardRedeemed
                  passedChinaIdentityVerification
                  phone
                }
                sshPort
                sshUsername
                status {
                  isOnline
                  totalCPU
                  usedCPU
                  totalMemory
                  usedMemory
                  warnings
                  vmStatus
                }
                createdAt
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                country
                city
                continent
                events {
                  message
                  time
                  severity
                }
                gpuInfo {
                  hasGPU
                  isReady
                  name
                }
                zeaburletStatus {
                  lastUpdatedAt
                }
                isManaged
                isAutoRenewDisabled
                expiresAt
                price
              }
            }
            """)
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query, operation_name="servers", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Servers.model_validate(data)

    async def dedicated_server_providers(
        self, **kwargs: Any
    ) -> DedicatedServerProviders:
        query = gql("""
            query dedicatedServerProviders {
              dedicatedServerProviders {
                code
                name
                icon
                homepage
                console
                canRefund
              }
            }
            """)
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query,
            operation_name="dedicatedServerProviders",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DedicatedServerProviders.model_validate(data)

    async def dedicated_server_regions(
        self, provider: str, **kwargs: Any
    ) -> DedicatedServerRegions:
        query = gql("""
            query dedicatedServerRegions($provider: String!) {
              dedicatedServerRegions(provider: $provider) {
                id
                code
                name
                description
                providerInfo {
                  code
                  name
                  icon
                  homepage
                  console
                  canRefund
                }
                available
                coordinates
                continent
                country
                city
              }
            }
            """)
        variables: dict[str, object] = {"provider": provider}
        response = await self.execute(
            query=query,
            operation_name="dedicatedServerRegions",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DedicatedServerRegions.model_validate(data)

    async def dedicated_server_plans(
        self, provider: str, region: str, **kwargs: Any
    ) -> DedicatedServerPlans:
        query = gql("""
            query dedicatedServerPlans($provider: String!, $region: String!) {
              dedicatedServerPlans(provider: $provider, region: $region) {
                name
                cpu
                memory
                disk
                egress
                price
                originalPrice
                gpu
                features
                available
                maxOutboundBandwidth
              }
            }
            """)
        variables: dict[str, object] = {"provider": provider, "region": region}
        response = await self.execute(
            query=query,
            operation_name="dedicatedServerPlans",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return DedicatedServerPlans.model_validate(data)

    async def services(
        self,
        skip: Union[Optional[int], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        project_id: Union[Optional[Any], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Services:
        query = gql("""
            query services($skip: Int, $limit: Int, $projectID: ObjectID) {
              services(skip: $skip, limit: $limit, projectID: $projectID) {
                pageInfo {
                  totalCount
                  hasNextPage
                  hasPreviousPage
                  startCursor
                  endCursor
                }
                edges {
                  node {
                    _id
                  }
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "skip": skip,
            "limit": limit,
            "projectID": project_id,
        }
        response = await self.execute(
            query=query, operation_name="services", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Services.model_validate(data)

    async def service(
        self,
        id: Union[Optional[Any], UnsetType] = UNSET,
        owner: Union[Optional[str], UnsetType] = UNSET,
        project_name: Union[Optional[str], UnsetType] = UNSET,
        name: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Service:
        query = gql("""
            query service($_id: ObjectID, $owner: String, $projectName: String, $name: String) {
              service(_id: $_id, owner: $owner, projectName: $projectName, name: $name) {
                _id
                name
                template
                project {
                  _id
                  name
                  description
                  iconURL
                  createdAt
                  owner {
                    _id
                  }
                  collaborators {
                    _id
                  }
                  invitations {
                    _id
                  }
                  region {
                    id
                  }
                  pullRequest
                  environments {
                    _id
                  }
                  services {
                    _id
                  }
                }
                watchPaths
                rootDirectory
                customBuildCommand
                customStartCommand
                outputDir
                resourceLimit {
                  cpu
                  memory
                }
                createdAt
                marketItemCode
                spec {
                  id
                  name
                  icon
                  ports {
                    id
                  }
                  volumes {
                    id
                  }
                  initRules {
                    id
                  }
                }
                marketplaceItem {
                  code
                  name
                  iconURL
                  description
                  networkType
                }
                status
                dnsName
                portForwardedHost
                healthCheckV2 {
                  type
                  port
                }
                suspendedAt
                onceProduct
                failureThreshold
                deployments {
                  _id
                  gitProvider
                  repoOwner
                  repoName
                  ref
                  commitSHA
                  commitMessage
                  projectID
                  serviceID
                  environmentID
                  status
                  createdAt
                  planType
                  planMeta
                  scheduledAt
                  startedAt
                  finishedAt
                  canceledAt
                  serverless
                }
                domains {
                  _id
                  domain
                  redirectTo
                  serviceID
                  projectID
                  environmentID
                  status
                  statusReason
                  createdAt
                  portName
                  isGenerated
                }
              }
            }
            """)
        variables: dict[str, object] = {
            "_id": id,
            "owner": owner,
            "projectName": project_name,
            "name": name,
        }
        response = await self.execute(
            query=query, operation_name="service", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Service.model_validate(data)

    async def prebuilt_marketplace_items(
        self, **kwargs: Any
    ) -> PrebuiltMarketplaceItems:
        query = gql("""
            query prebuiltMarketplaceItems {
              prebuiltMarketplaceItems {
                id
                name
                icon
                source {
                  image
                  username
                  password
                  source
                  repoID
                  uploadID
                  branch
                  submoduleName
                  watchPaths
                  rootDirectory
                  dockerfile
                  command
                  args
                  runAsUserID
                }
                ports {
                  id
                  port
                  type
                }
                volumes {
                  id
                  dir
                }
                instructions {
                  title
                  content
                }
                env {
                  key
                  default
                  expose
                }
                initRules {
                  id
                  image
                  command
                  volumes {
                    id
                  }
                }
                configs {
                  path
                  template
                  permission
                  envsubst
                }
                gpu {
                  enabled
                }
                healthCheck {
                  type
                  port
                }
                portForwarding {
                  enabled
                }
              }
            }
            """)
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query,
            operation_name="prebuiltMarketplaceItems",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return PrebuiltMarketplaceItems.model_validate(data)

    async def instructions(
        self, service_id: Any, environment_id: Any, **kwargs: Any
    ) -> Instructions:
        query = gql("""
            query instructions($serviceID: ObjectID!, $environmentID: ObjectID!) {
              instructions(serviceID: $serviceID, environmentID: $environmentID) {
                title
                content
              }
            }
            """)
        variables: dict[str, object] = {
            "serviceID": service_id,
            "environmentID": environment_id,
        }
        response = await self.execute(
            query=query, operation_name="instructions", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Instructions.model_validate(data)

    async def service_plan_type_plan_meta(
        self, repo_id: int, **kwargs: Any
    ) -> ServicePlanTypePlanMeta:
        query = gql("""
            query servicePlanTypePlanMeta($repoID: Int!) {
              servicePlanTypePlanMeta(repoID: $repoID) {
                type
                meta
              }
            }
            """)
        variables: dict[str, object] = {"repoID": repo_id}
        response = await self.execute(
            query=query,
            operation_name="servicePlanTypePlanMeta",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return ServicePlanTypePlanMeta.model_validate(data)

    async def templates(
        self,
        skip: Union[Optional[int], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Templates:
        query = gql("""
            query templates($skip: Int, $limit: Int) {
              templates(skip: $skip, limit: $limit) {
                pageInfo {
                  totalCount
                  hasNextPage
                  hasPreviousPage
                  startCursor
                  endCursor
                }
                edges {
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {"skip": skip, "limit": limit}
        response = await self.execute(
            query=query, operation_name="templates", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Templates.model_validate(data)

    async def template(self, code: str, **kwargs: Any) -> Template:
        query = gql("""
            query template($code: String!) {
              template(code: $code) {
                code
                name
                description
                coverURL
                iconURL
                previewURL
                author {
                  username
                  avatarURL
                }
                createdAt
                readme
                resourceUsage {
                  cpu
                  memory
                }
                services {
                  name
                  template
                  gitRepoID
                  gitRepo {
                    id
                  }
                  branchName
                  customBuildCommand
                  customStartCommand
                  outputDir
                  rootDirectory
                  watchPaths
                  planType
                  planMeta
                  prebuiltItem {
                    id
                  }
                  variables
                  spec {
                    id
                  }
                }
                deploymentCnt
                tags
                variables {
                  type
                  question
                  key
                  desc
                }
              }
            }
            """)
        variables: dict[str, object] = {"code": code}
        response = await self.execute(
            query=query, operation_name="template", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Template.model_validate(data)

    async def user_templates(
        self,
        user_id: str,
        skip: Union[Optional[int], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> UserTemplates:
        query = gql("""
            query userTemplates($skip: Int, $limit: Int, $userID: String!) {
              userTemplates(skip: $skip, limit: $limit, userID: $userID) {
                pageInfo {
                  totalCount
                  hasNextPage
                  hasPreviousPage
                  startCursor
                  endCursor
                }
                edges {
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {"skip": skip, "limit": limit, "userID": user_id}
        response = await self.execute(
            query=query, operation_name="userTemplates", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return UserTemplates.model_validate(data)

    async def is_template_author(self, code: str, **kwargs: Any) -> IsTemplateAuthor:
        query = gql("""
            query isTemplateAuthor($code: String!) {
              isTemplateAuthor(code: $code)
            }
            """)
        variables: dict[str, object] = {"code": code}
        response = await self.execute(
            query=query,
            operation_name="isTemplateAuthor",
            variables=variables,
            **kwargs
        )
        data = self.get_data(response)
        return IsTemplateAuthor.model_validate(data)

    async def users(
        self,
        skip: Union[Optional[int], UnsetType] = UNSET,
        limit: Union[Optional[int], UnsetType] = UNSET,
        **kwargs: Any
    ) -> Users:
        query = gql("""
            query users($skip: Int, $limit: Int) {
              users(skip: $skip, limit: $limit) {
                pageInfo {
                  totalCount
                  hasNextPage
                  hasPreviousPage
                  startCursor
                  endCursor
                }
                edges {
                  node {
                    _id
                  }
                  cursor
                }
              }
            }
            """)
        variables: dict[str, object] = {"skip": skip, "limit": limit}
        response = await self.execute(
            query=query, operation_name="users", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Users.model_validate(data)

    async def user(
        self,
        id: Union[Optional[Any], UnsetType] = UNSET,
        username: Union[Optional[str], UnsetType] = UNSET,
        email: Union[Optional[str], UnsetType] = UNSET,
        discord_id: Union[Optional[str], UnsetType] = UNSET,
        **kwargs: Any
    ) -> User:
        query = gql("""
            query user($_id: ObjectID, $username: String, $email: String, $discordID: String) {
              user(_id: $_id, username: $username, email: $email, discordID: $discordID) {
                _id
                name
                email
                language
                githubID
                discordID
                avatarURL
                createdAt
                emailPreference
                referralCode
                username
                referredBy {
                  name
                  avatarURL
                }
                referralRewardRedeemed
                passedChinaIdentityVerification
                phone
              }
            }
            """)
        variables: dict[str, object] = {
            "_id": id,
            "username": username,
            "email": email,
            "discordID": discord_id,
        }
        response = await self.execute(
            query=query, operation_name="user", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return User.model_validate(data)

    async def me(self, **kwargs: Any) -> Me:
        query = gql("""
            query me {
              me {
                _id
                name
                email
                language
                githubID
                discordID
                avatarURL
                createdAt
                emailPreference
                referralCode
                username
                referredBy {
                  name
                  avatarURL
                }
                referralRewardRedeemed
                passedChinaIdentityVerification
                phone
              }
            }
            """)
        variables: dict[str, object] = {}
        response = await self.execute(
            query=query, operation_name="me", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Me.model_validate(data)

    async def referrer(self, referral_code: str, **kwargs: Any) -> Referrer:
        query = gql("""
            query referrer($referralCode: String!) {
              referrer(referralCode: $referralCode) {
                name
                avatarURL
              }
            }
            """)
        variables: dict[str, object] = {"referralCode": referral_code}
        response = await self.execute(
            query=query, operation_name="referrer", variables=variables, **kwargs
        )
        data = self.get_data(response)
        return Referrer.model_validate(data)
