diff --git a/scaleway-async/scaleway_async/container/v1/__init__.py b/scaleway-async/scaleway_async/container/v1/__init__.py new file mode 100644 index 000000000..0aa584254 --- /dev/null +++ b/scaleway-async/scaleway_async/container/v1/__init__.py @@ -0,0 +1,143 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import ContainerPrivacy +from .types import ContainerProtocol +from .types import ContainerSandbox +from .types import ContainerStatus +from .content import CONTAINER_TRANSIENT_STATUSES +from .types import CreateTriggerRequestDestinationConfigHttpMethod +from .types import DomainStatus +from .content import DOMAIN_TRANSIENT_STATUSES +from .types import ListContainersRequestOrderBy +from .types import ListDomainsRequestOrderBy +from .types import ListNamespacesRequestOrderBy +from .types import ListTriggersRequestOrderBy +from .types import NamespaceStatus +from .content import NAMESPACE_TRANSIENT_STATUSES +from .types import TriggerDestinationConfigHttpMethod +from .types import TriggerSourceType +from .types import TriggerStatus +from .content import TRIGGER_TRANSIENT_STATUSES +from .types import UpdateTriggerRequestDestinationConfigHttpMethod +from .types import ContainerProbeHTTPProbe +from .types import ContainerProbeTCPProbe +from .types import ContainerProbe +from .types import ContainerScalingOption +from .types import TriggerCronConfig +from .types import TriggerDestinationConfig +from .types import TriggerNATSConfig +from .types import TriggerSQSConfig +from .types import UpdateContainerRequestProbeHTTPProbe +from .types import UpdateContainerRequestProbeTCPProbe +from .types import CreateTriggerRequestCronConfig +from .types import CreateTriggerRequestDestinationConfig +from .types import CreateTriggerRequestNATSConfig +from .types import CreateTriggerRequestSQSConfig +from .types import Container +from .types import Domain +from .types import Namespace +from .types import Trigger +from .types import UpdateContainerRequestProbe +from .types import UpdateTriggerRequestCronConfig +from .types import UpdateTriggerRequestDestinationConfig +from .types import UpdateTriggerRequestNATSConfig +from .types import UpdateTriggerRequestSQSConfig +from .types import CreateContainerRequest +from .types import CreateDomainRequest +from .types import CreateNamespaceRequest +from .types import CreateTriggerRequest +from .types import DeleteContainerRequest +from .types import DeleteDomainRequest +from .types import DeleteNamespaceRequest +from .types import DeleteTriggerRequest +from .types import GetContainerRequest +from .types import GetDomainRequest +from .types import GetNamespaceRequest +from .types import GetServiceInfoRequest +from .types import GetTriggerRequest +from .types import ListContainersRequest +from .types import ListContainersResponse +from .types import ListDomainsRequest +from .types import ListDomainsResponse +from .types import ListNamespacesRequest +from .types import ListNamespacesResponse +from .types import ListTriggersRequest +from .types import ListTriggersResponse +from .types import RedeployContainerRequest +from .types import UpdateContainerRequest +from .types import UpdateDomainRequest +from .types import UpdateNamespaceRequest +from .types import UpdateTriggerRequest +from .api import ContainerV1API + +__all__ = [ + "ContainerPrivacy", + "ContainerProtocol", + "ContainerSandbox", + "ContainerStatus", + "CONTAINER_TRANSIENT_STATUSES", + "CreateTriggerRequestDestinationConfigHttpMethod", + "DomainStatus", + "DOMAIN_TRANSIENT_STATUSES", + "ListContainersRequestOrderBy", + "ListDomainsRequestOrderBy", + "ListNamespacesRequestOrderBy", + "ListTriggersRequestOrderBy", + "NamespaceStatus", + "NAMESPACE_TRANSIENT_STATUSES", + "TriggerDestinationConfigHttpMethod", + "TriggerSourceType", + "TriggerStatus", + "TRIGGER_TRANSIENT_STATUSES", + "UpdateTriggerRequestDestinationConfigHttpMethod", + "ContainerProbeHTTPProbe", + "ContainerProbeTCPProbe", + "ContainerProbe", + "ContainerScalingOption", + "TriggerCronConfig", + "TriggerDestinationConfig", + "TriggerNATSConfig", + "TriggerSQSConfig", + "UpdateContainerRequestProbeHTTPProbe", + "UpdateContainerRequestProbeTCPProbe", + "CreateTriggerRequestCronConfig", + "CreateTriggerRequestDestinationConfig", + "CreateTriggerRequestNATSConfig", + "CreateTriggerRequestSQSConfig", + "Container", + "Domain", + "Namespace", + "Trigger", + "UpdateContainerRequestProbe", + "UpdateTriggerRequestCronConfig", + "UpdateTriggerRequestDestinationConfig", + "UpdateTriggerRequestNATSConfig", + "UpdateTriggerRequestSQSConfig", + "CreateContainerRequest", + "CreateDomainRequest", + "CreateNamespaceRequest", + "CreateTriggerRequest", + "DeleteContainerRequest", + "DeleteDomainRequest", + "DeleteNamespaceRequest", + "DeleteTriggerRequest", + "GetContainerRequest", + "GetDomainRequest", + "GetNamespaceRequest", + "GetServiceInfoRequest", + "GetTriggerRequest", + "ListContainersRequest", + "ListContainersResponse", + "ListDomainsRequest", + "ListDomainsResponse", + "ListNamespacesRequest", + "ListNamespacesResponse", + "ListTriggersRequest", + "ListTriggersResponse", + "RedeployContainerRequest", + "UpdateContainerRequest", + "UpdateDomainRequest", + "UpdateNamespaceRequest", + "UpdateTriggerRequest", + "ContainerV1API", +] diff --git a/scaleway-async/scaleway_async/container/v1/api.py b/scaleway-async/scaleway_async/container/v1/api.py new file mode 100644 index 000000000..0ad37364f --- /dev/null +++ b/scaleway-async/scaleway_async/container/v1/api.py @@ -0,0 +1,1542 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Awaitable, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + ServiceInfo, + unmarshal_ServiceInfo, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + ContainerPrivacy, + ContainerProtocol, + ContainerSandbox, + ListContainersRequestOrderBy, + ListDomainsRequestOrderBy, + ListNamespacesRequestOrderBy, + ListTriggersRequestOrderBy, + Container, + ContainerProbe, + ContainerScalingOption, + CreateContainerRequest, + CreateDomainRequest, + CreateNamespaceRequest, + CreateTriggerRequest, + CreateTriggerRequestCronConfig, + CreateTriggerRequestDestinationConfig, + CreateTriggerRequestNATSConfig, + CreateTriggerRequestSQSConfig, + Domain, + ListContainersResponse, + ListDomainsResponse, + ListNamespacesResponse, + ListTriggersResponse, + Namespace, + Trigger, + UpdateContainerRequest, + UpdateContainerRequestProbe, + UpdateDomainRequest, + UpdateNamespaceRequest, + UpdateTriggerRequest, + UpdateTriggerRequestCronConfig, + UpdateTriggerRequestDestinationConfig, + UpdateTriggerRequestNATSConfig, + UpdateTriggerRequestSQSConfig, +) +from .content import ( + CONTAINER_TRANSIENT_STATUSES, + DOMAIN_TRANSIENT_STATUSES, + NAMESPACE_TRANSIENT_STATUSES, + TRIGGER_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Container, + unmarshal_Domain, + unmarshal_Namespace, + unmarshal_Trigger, + unmarshal_ListContainersResponse, + unmarshal_ListDomainsResponse, + unmarshal_ListNamespacesResponse, + unmarshal_ListTriggersResponse, + marshal_CreateContainerRequest, + marshal_CreateDomainRequest, + marshal_CreateNamespaceRequest, + marshal_CreateTriggerRequest, + marshal_UpdateContainerRequest, + marshal_UpdateDomainRequest, + marshal_UpdateNamespaceRequest, + marshal_UpdateTriggerRequest, +) + + +class ContainerV1API(API): + """ + Easily run containers on the cloud with a single command. + """ + + async def get_service_info( + self, + *, + region: Optional[ScwRegion] = None, + ) -> ServiceInfo: + """ + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ServiceInfo ` + + Usage: + :: + + result = await api.get_service_info() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}", + ) + + self._throw_on_error(res) + return unmarshal_ServiceInfo(res.json()) + + async def create_namespace( + self, + *, + name: str, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + description: Optional[str] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + tags: Optional[list[str]] = None, + ) -> Namespace: + """ + Create a new namespace. + Namespace name must be unique inside a project. + :param name: Namespace name. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: Unique ID of the Project the namespace belongs to. + :param description: Namespace description. + :param environment_variables: Namespace environment variables. + :param secret_environment_variables: Namespace secret environment variables. + :param tags: A list of arbitrary tags associated with the namespace. + :return: :class:`Namespace ` + + Usage: + :: + + result = await api.create_namespace( + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/namespaces", + body=marshal_CreateNamespaceRequest( + CreateNamespaceRequest( + name=name, + region=region, + project_id=project_id, + description=description, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + async def get_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + ) -> Namespace: + """ + Get the namespace associated with the specified ID. + :param namespace_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = await api.get_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + async def wait_for_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + options: Optional[ + WaitForOptions[Namespace, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Namespace: + """ + Get the namespace associated with the specified ID. + :param namespace_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = await api.get_namespace( + namespace_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in NAMESPACE_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_namespace, + options=options, + args={ + "namespace_id": namespace_id, + "region": region, + }, + ) + + async def list_namespaces( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListNamespacesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListNamespacesResponse: + """ + List all namespaces the caller can access (read permission). + By default, the namespaces listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param name: + :return: :class:`ListNamespacesResponse ` + + Usage: + :: + + result = await api.list_namespaces() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/namespaces", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNamespacesResponse(res.json()) + + async def list_namespaces_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListNamespacesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + ) -> list[Namespace]: + """ + List all namespaces the caller can access (read permission). + By default, the namespaces listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param name: + :return: :class:`list[Namespace] ` + + Usage: + :: + + result = await api.list_namespaces_all() + """ + + return await fetch_all_pages_async( + type=ListNamespacesResponse, + key="namespaces", + fetcher=self.list_namespaces, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "name": name, + }, + ) + + async def update_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + description: Optional[str] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + tags: Optional[list[str]] = None, + ) -> Namespace: + """ + Update the namespace associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param namespace_id: UUID of the namespace to update. + :param region: Region to target. If none is passed will use default region from the config. + :param description: Namespace description. + :param environment_variables: Namespace environment variables. + :param secret_environment_variables: Namespace secret environment variables. + :param tags: A list of arbitrary tags associated with the namespace. + :return: :class:`Namespace ` + + Usage: + :: + + result = await api.update_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + body=marshal_UpdateNamespaceRequest( + UpdateNamespaceRequest( + namespace_id=namespace_id, + region=region, + description=description, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + async def delete_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + ) -> Namespace: + """ + Delete the namespace associated with the specified ID. + It also deletes in cascade any resource inside the namespace. + + This action **cannot** be undone. + :param namespace_id: UUID of the namespace to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = await api.delete_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + async def create_container( + self, + *, + namespace_id: str, + name: str, + region: Optional[ScwRegion] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + min_scale: Optional[int] = None, + max_scale: Optional[int] = None, + memory_limit_bytes: Optional[int] = None, + mvcpu_limit: Optional[int] = None, + timeout: Optional[str] = None, + privacy: Optional[ContainerPrivacy] = None, + description: Optional[str] = None, + image: str, + protocol: Optional[ContainerProtocol] = None, + port: Optional[int] = None, + https_connections_only: Optional[bool] = None, + sandbox: Optional[ContainerSandbox] = None, + local_storage_limit_bytes: Optional[int] = None, + scaling_option: Optional[ContainerScalingOption] = None, + liveness_probe: Optional[ContainerProbe] = None, + startup_probe: Optional[ContainerProbe] = None, + tags: Optional[list[str]] = None, + private_network_id: Optional[str] = None, + command: Optional[list[str]] = None, + args: Optional[list[str]] = None, + ) -> Container: + """ + Create a new container in a namespace. + Name must be unique inside the given namespace. + :param namespace_id: Unique ID of the namespace the container belongs to. + :param name: Container name. + :param region: Region to target. If none is passed will use default region from the config. + :param environment_variables: Environment variables of the container. + :param secret_environment_variables: Secret environment variables of the container. + :param min_scale: Minimum number of instances to scale the container to. + :param max_scale: Maximum number of instances to scale the container to. + :param memory_limit_bytes: Memory limit of the container in bytes. + :param mvcpu_limit: CPU limit of the container in mvCPU. + :param timeout: Processing time limit for the container. + :param privacy: Privacy policy of the container. + :param description: Container description. + :param image: Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + :param protocol: Protocol the container uses. + :param port: Port the container listens on. + :param https_connections_only: If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + :param sandbox: Execution environment of the container. + :param local_storage_limit_bytes: Local storage limit of the container (in bytes). + :param scaling_option: Parameter used to decide when to scale up or down. + :param liveness_probe: If the liveness probe fails, the container will be restarted. + It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param startup_probe: If the startup probe fails, the container will be restarted. + This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param tags: Tags of the Serverless Container. + :param private_network_id: When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + :param command: Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + :param args: Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + :return: :class:`Container ` + + Usage: + :: + + result = await api.create_container( + namespace_id="example", + name="example", + image="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/containers", + body=marshal_CreateContainerRequest( + CreateContainerRequest( + namespace_id=namespace_id, + name=name, + region=region, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + min_scale=min_scale, + max_scale=max_scale, + memory_limit_bytes=memory_limit_bytes, + mvcpu_limit=mvcpu_limit, + timeout=timeout, + privacy=privacy, + description=description, + image=image, + protocol=protocol, + port=port, + https_connections_only=https_connections_only, + sandbox=sandbox, + local_storage_limit_bytes=local_storage_limit_bytes, + scaling_option=scaling_option, + liveness_probe=liveness_probe, + startup_probe=startup_probe, + tags=tags, + private_network_id=private_network_id, + command=command, + args=args, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + async def get_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Get the container associated with the specified ID. + :param container_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = await api.get_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + async def wait_for_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + options: Optional[ + WaitForOptions[Container, Union[bool, Awaitable[bool]]] + ] = None, + ) -> Container: + """ + Get the container associated with the specified ID. + :param container_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = await api.get_container( + container_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in CONTAINER_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_container, + options=options, + args={ + "container_id": container_id, + "region": region, + }, + ) + + async def list_containers( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListContainersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListContainersResponse: + """ + List all containers the caller can access (read permission). + By default, the containers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param name: + :return: :class:`ListContainersResponse ` + + Usage: + :: + + result = await api.list_containers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/containers", + params={ + "name": name, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListContainersResponse(res.json()) + + async def list_containers_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListContainersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + name: Optional[str] = None, + ) -> list[Container]: + """ + List all containers the caller can access (read permission). + By default, the containers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param name: + :return: :class:`list[Container] ` + + Usage: + :: + + result = await api.list_containers_all() + """ + + return await fetch_all_pages_async( + type=ListContainersResponse, + key="containers", + fetcher=self.list_containers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "name": name, + }, + ) + + async def update_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + min_scale: Optional[int] = None, + max_scale: Optional[int] = None, + memory_limit_bytes: Optional[int] = None, + mvcpu_limit: Optional[int] = None, + timeout: Optional[str] = None, + privacy: Optional[ContainerPrivacy] = None, + description: Optional[str] = None, + image: Optional[str] = None, + protocol: Optional[ContainerProtocol] = None, + port: Optional[int] = None, + https_connection_only: Optional[bool] = None, + sandbox: Optional[ContainerSandbox] = None, + local_storage_limit_bytes: Optional[int] = None, + scaling_option: Optional[ContainerScalingOption] = None, + liveness_probe: Optional[ContainerProbe] = None, + startup_probe: Optional[UpdateContainerRequestProbe] = None, + tags: Optional[list[str]] = None, + private_network_id: Optional[str] = None, + command: Optional[list[str]] = None, + args: Optional[list[str]] = None, + ) -> Container: + """ + Update the container associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param container_id: UUID of the container to update. + :param region: Region to target. If none is passed will use default region from the config. + :param environment_variables: Environment variables of the container. + :param secret_environment_variables: Secret environment variables of the container. + :param min_scale: Minimum number of instances to scale the container to. + :param max_scale: Maximum number of instances to scale the container to. + :param memory_limit_bytes: Memory limit of the container in bytes. + :param mvcpu_limit: CPU limit of the container in mvCPU. + :param timeout: Processing time limit for the container. + :param privacy: Privacy policy of the container. + :param description: Container description. + :param image: Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + :param protocol: Protocol the container uses. + :param port: Port the container listens on. + :param https_connection_only: If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + :param sandbox: Execution environment of the container. + :param local_storage_limit_bytes: Local storage limit of the container (in bytes). + :param scaling_option: Parameter used to decide when to scale up or down. + :param liveness_probe: If the liveness probe fails, the container will be restarted. + It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param startup_probe: If the startup probe fails, the container will be restarted. + This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param tags: Tags of the Serverless Container. + :param private_network_id: When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + :param command: Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + :param args: Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + :return: :class:`Container ` + + Usage: + :: + + result = await api.update_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + body=marshal_UpdateContainerRequest( + UpdateContainerRequest( + container_id=container_id, + region=region, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + min_scale=min_scale, + max_scale=max_scale, + memory_limit_bytes=memory_limit_bytes, + mvcpu_limit=mvcpu_limit, + timeout=timeout, + privacy=privacy, + description=description, + image=image, + protocol=protocol, + port=port, + https_connection_only=https_connection_only, + sandbox=sandbox, + local_storage_limit_bytes=local_storage_limit_bytes, + scaling_option=scaling_option, + liveness_probe=liveness_probe, + startup_probe=startup_probe, + tags=tags, + private_network_id=private_network_id, + command=command, + args=args, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + async def delete_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Delete the container associated with the specified ID. + It also deletes in cascade any resource linked to the container (crons, tokens, etc.). + + This action **cannot** be undone. + :param container_id: UUID of the container to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = await api.delete_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + async def create_domain( + self, + *, + container_id: str, + hostname: str, + region: Optional[ScwRegion] = None, + tags: Optional[list[str]] = None, + ) -> Domain: + """ + Create a new custom domain for the container with the specified ID. + :param container_id: Unique ID of the container the domain will be assigned to. + :param hostname: Domain assigned to the container. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: A list of arbitrary tags associated with the domain. + :return: :class:`Domain ` + + Usage: + :: + + result = await api.create_domain( + container_id="example", + hostname="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/domains", + body=marshal_CreateDomainRequest( + CreateDomainRequest( + container_id=container_id, + hostname=hostname, + region=region, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + async def get_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + ) -> Domain: + """ + Get the custom domain associated with the specified ID. + :param domain_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = await api.get_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + async def wait_for_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Domain, Union[bool, Awaitable[bool]]]] = None, + ) -> Domain: + """ + Get the custom domain associated with the specified ID. + :param domain_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = await api.get_domain( + domain_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DOMAIN_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_domain, + options=options, + args={ + "domain_id": domain_id, + "region": region, + }, + ) + + async def list_domains( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDomainsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> ListDomainsResponse: + """ + List all custom domains the caller can access (read permission). + By default, the custom domains listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter the output, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`ListDomainsResponse ` + + Usage: + :: + + result = await api.list_domains() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/domains", + params={ + "container_id": container_id, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDomainsResponse(res.json()) + + async def list_domains_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDomainsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> list[Domain]: + """ + List all custom domains the caller can access (read permission). + By default, the custom domains listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter the output, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`list[Domain] ` + + Usage: + :: + + result = await api.list_domains_all() + """ + + return await fetch_all_pages_async( + type=ListDomainsResponse, + key="domains", + fetcher=self.list_domains, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "container_id": container_id, + }, + ) + + async def update_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + tags: Optional[list[str]] = None, + ) -> Domain: + """ + Update the domain associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param domain_id: UUID of the domain to update. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: A list of arbitrary tags associated with the domain. + :return: :class:`Domain ` + + Usage: + :: + + result = await api.update_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + body=marshal_UpdateDomainRequest( + UpdateDomainRequest( + domain_id=domain_id, + region=region, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + async def delete_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + ) -> Domain: + """ + Delete the custom domain associated with the specified ID. + :param domain_id: UUID of the domain to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = await api.delete_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + async def redeploy_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Redeploy a container. + Performs a rollout of the container by creating new instances with the latest image version and terminating the old instances. + When using mutable registry image references (e.g. `my-registry-namespace/image:tag`), this endpoint can be used to force the container to use + the most recent image version available in the registry. + :param container_id: ID of the container to redeploy. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = await api.redeploy_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}/redeploy", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + async def create_trigger( + self, + *, + container_id: str, + name: str, + region: Optional[ScwRegion] = None, + description: Optional[str] = None, + tags: Optional[list[str]] = None, + destination_config: Optional[CreateTriggerRequestDestinationConfig] = None, + cron_config: Optional[CreateTriggerRequestCronConfig] = None, + sqs_config: Optional[CreateTriggerRequestSQSConfig] = None, + nats_config: Optional[CreateTriggerRequestNATSConfig] = None, + ) -> Trigger: + """ + Create a new trigger for the container with the specified ID. + :param container_id: ID of the container to trigger. + :param name: Name of the trigger. + :param region: Region to target. If none is passed will use default region from the config. + :param description: Description of the trigger. + :param tags: Tags of the trigger. + :param destination_config: Configuration of the destination to trigger. + :param cron_config: Configuration for a cron source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param sqs_config: Configuration for an SQS queue source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param nats_config: Configuration for a NATS source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :return: :class:`Trigger ` + + Usage: + :: + + result = await api.create_trigger( + container_id="example", + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/triggers", + body=marshal_CreateTriggerRequest( + CreateTriggerRequest( + container_id=container_id, + name=name, + region=region, + description=description, + tags=tags, + destination_config=destination_config, + cron_config=cron_config, + sqs_config=sqs_config, + nats_config=nats_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + async def get_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + ) -> Trigger: + """ + Get the trigger associated with the specified ID. + :param trigger_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = await api.get_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + async def wait_for_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Trigger, Union[bool, Awaitable[bool]]]] = None, + ) -> Trigger: + """ + Get the trigger associated with the specified ID. + :param trigger_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = await api.get_trigger( + trigger_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in TRIGGER_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_trigger, + options=options, + args={ + "trigger_id": trigger_id, + "region": region, + }, + ) + + async def list_triggers( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListTriggersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> ListTriggersResponse: + """ + List all triggers the caller can access (read permission). + By default, the triggers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`ListTriggersResponse ` + + Usage: + :: + + result = await api.list_triggers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/triggers", + params={ + "container_id": container_id, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTriggersResponse(res.json()) + + async def list_triggers_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListTriggersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> list[Trigger]: + """ + List all triggers the caller can access (read permission). + By default, the triggers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`list[Trigger] ` + + Usage: + :: + + result = await api.list_triggers_all() + """ + + return await fetch_all_pages_async( + type=ListTriggersResponse, + key="triggers", + fetcher=self.list_triggers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "container_id": container_id, + }, + ) + + async def update_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + description: Optional[str] = None, + tags: Optional[list[str]] = None, + destination_config: Optional[UpdateTriggerRequestDestinationConfig] = None, + cron_config: Optional[UpdateTriggerRequestCronConfig] = None, + sqs_config: Optional[UpdateTriggerRequestSQSConfig] = None, + nats_config: Optional[UpdateTriggerRequestNATSConfig] = None, + ) -> Trigger: + """ + Update the trigger associated with the specified ID. + When updating a trigger, you cannot specify a different source type than the one already set. + Only fields present in the request are updated; others are left untouched. + :param trigger_id: ID of the trigger to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the trigger. + :param description: Description of the trigger. + :param tags: Tags of the trigger. + :param destination_config: Configuration of the destination to trigger. + :param cron_config: Configuration for a cron source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param sqs_config: Configuration for an SQS queue source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param nats_config: Configuration for a NATS source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :return: :class:`Trigger ` + + Usage: + :: + + result = await api.update_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + body=marshal_UpdateTriggerRequest( + UpdateTriggerRequest( + trigger_id=trigger_id, + region=region, + name=name, + description=description, + tags=tags, + destination_config=destination_config, + cron_config=cron_config, + sqs_config=sqs_config, + nats_config=nats_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + async def delete_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + ) -> Trigger: + """ + Delete the trigger associated with the specified ID. + This action **cannot** be undone. + :param trigger_id: ID of the trigger to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = await api.delete_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) diff --git a/scaleway-async/scaleway_async/container/v1/content.py b/scaleway-async/scaleway_async/container/v1/content.py new file mode 100644 index 000000000..f2c1dff3c --- /dev/null +++ b/scaleway-async/scaleway_async/container/v1/content.py @@ -0,0 +1,50 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from .types import ( + ContainerStatus, + DomainStatus, + NamespaceStatus, + TriggerStatus, +) + +CONTAINER_TRANSIENT_STATUSES: list[ContainerStatus] = [ + ContainerStatus.UPDATING, + ContainerStatus.DELETING, + ContainerStatus.LOCKING, + ContainerStatus.CREATING, + ContainerStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`ContainerStatus `. +""" +DOMAIN_TRANSIENT_STATUSES: list[DomainStatus] = [ + DomainStatus.CREATING, + DomainStatus.UPDATING, + DomainStatus.DELETING, + DomainStatus.LOCKING, + DomainStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`DomainStatus `. +""" +NAMESPACE_TRANSIENT_STATUSES: list[NamespaceStatus] = [ + NamespaceStatus.UPDATING, + NamespaceStatus.DELETING, + NamespaceStatus.LOCKING, + NamespaceStatus.CREATING, + NamespaceStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`NamespaceStatus `. +""" +TRIGGER_TRANSIENT_STATUSES: list[TriggerStatus] = [ + TriggerStatus.DELETING, + TriggerStatus.UPDATING, + TriggerStatus.CREATING, + TriggerStatus.LOCKING, + TriggerStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`TriggerStatus `. +""" diff --git a/scaleway-async/scaleway_async/container/v1/marshalling.py b/scaleway-async/scaleway_async/container/v1/marshalling.py new file mode 100644 index 000000000..cd73fbcca --- /dev/null +++ b/scaleway-async/scaleway_async/container/v1/marshalling.py @@ -0,0 +1,1456 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + ContainerPrivacy, + ContainerProtocol, + ContainerSandbox, + ContainerStatus, + DomainStatus, + NamespaceStatus, + TriggerDestinationConfigHttpMethod, + TriggerSourceType, + TriggerStatus, + ContainerProbeHTTPProbe, + ContainerProbeTCPProbe, + ContainerProbe, + ContainerScalingOption, + Container, + Domain, + Namespace, + TriggerCronConfig, + TriggerDestinationConfig, + TriggerNATSConfig, + TriggerSQSConfig, + Trigger, + ListContainersResponse, + ListDomainsResponse, + ListNamespacesResponse, + ListTriggersResponse, + CreateContainerRequest, + CreateDomainRequest, + CreateNamespaceRequest, + CreateTriggerRequestCronConfig, + CreateTriggerRequestDestinationConfig, + CreateTriggerRequestNATSConfig, + CreateTriggerRequestSQSConfig, + CreateTriggerRequest, + UpdateContainerRequestProbeHTTPProbe, + UpdateContainerRequestProbeTCPProbe, + UpdateContainerRequestProbe, + UpdateContainerRequest, + UpdateDomainRequest, + UpdateNamespaceRequest, + UpdateTriggerRequestCronConfig, + UpdateTriggerRequestDestinationConfig, + UpdateTriggerRequestNATSConfig, + UpdateTriggerRequestSQSConfig, + UpdateTriggerRequest, +) + + +def unmarshal_ContainerProbeHTTPProbe(data: Any) -> ContainerProbeHTTPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbeHTTPProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + else: + args["path"] = None + + return ContainerProbeHTTPProbe(**args) + + +def unmarshal_ContainerProbeTCPProbe(data: Any) -> ContainerProbeTCPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbeTCPProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + return ContainerProbeTCPProbe(**args) + + +def unmarshal_ContainerProbe(data: Any) -> ContainerProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("failure_threshold", None) + if field is not None: + args["failure_threshold"] = field + else: + args["failure_threshold"] = 0 + + field = data.get("interval", None) + if field is not None: + args["interval"] = field + else: + args["interval"] = None + + field = data.get("timeout", None) + if field is not None: + args["timeout"] = field + else: + args["timeout"] = None + + field = data.get("tcp", None) + if field is not None: + args["tcp"] = unmarshal_ContainerProbeTCPProbe(field) + else: + args["tcp"] = None + + field = data.get("http", None) + if field is not None: + args["http"] = unmarshal_ContainerProbeHTTPProbe(field) + else: + args["http"] = None + + return ContainerProbe(**args) + + +def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerScalingOption' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("concurrent_requests_threshold", None) + if field is not None: + args["concurrent_requests_threshold"] = field + else: + args["concurrent_requests_threshold"] = 0 + + field = data.get("cpu_usage_threshold", None) + if field is not None: + args["cpu_usage_threshold"] = field + else: + args["cpu_usage_threshold"] = 0 + + field = data.get("memory_usage_threshold", None) + if field is not None: + args["memory_usage_threshold"] = field + else: + args["memory_usage_threshold"] = 0 + + return ContainerScalingOption(**args) + + +def unmarshal_Container(data: Any) -> Container: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Container' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("namespace_id", None) + if field is not None: + args["namespace_id"] = field + else: + args["namespace_id"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = ContainerStatus.UNKNOWN_STATUS + + field = data.get("environment_variables", None) + if field is not None: + args["environment_variables"] = field + else: + args["environment_variables"] = {} + + field = data.get("secret_environment_variables", None) + if field is not None: + args["secret_environment_variables"] = field + else: + args["secret_environment_variables"] = {} + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("min_scale", None) + if field is not None: + args["min_scale"] = field + else: + args["min_scale"] = 0 + + field = data.get("max_scale", None) + if field is not None: + args["max_scale"] = field + else: + args["max_scale"] = 0 + + field = data.get("memory_limit_bytes", None) + if field is not None: + args["memory_limit_bytes"] = field + else: + args["memory_limit_bytes"] = 0 + + field = data.get("mvcpu_limit", None) + if field is not None: + args["mvcpu_limit"] = field + else: + args["mvcpu_limit"] = 0 + + field = data.get("local_storage_limit_bytes", None) + if field is not None: + args["local_storage_limit_bytes"] = field + else: + args["local_storage_limit_bytes"] = 0 + + field = data.get("privacy", None) + if field is not None: + args["privacy"] = field + else: + args["privacy"] = ContainerPrivacy.UNKNOWN_PRIVACY + + field = data.get("image", None) + if field is not None: + args["image"] = field + else: + args["image"] = None + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + else: + args["protocol"] = ContainerProtocol.UNKNOWN_PROTOCOL + + field = data.get("port", None) + if field is not None: + args["port"] = field + else: + args["port"] = 0 + + field = data.get("https_connections_only", None) + if field is not None: + args["https_connections_only"] = field + else: + args["https_connections_only"] = False + + field = data.get("timeout", None) + if field is not None: + args["timeout"] = field + else: + args["timeout"] = None + + field = data.get("sandbox", None) + if field is not None: + args["sandbox"] = field + else: + args["sandbox"] = ContainerSandbox.UNKNOWN_SANDBOX + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("command", None) + if field is not None: + args["command"] = field + else: + args["command"] = [] + + field = data.get("args", None) + if field is not None: + args["args"] = field + else: + args["args"] = [] + + field = data.get("public_endpoint", None) + if field is not None: + args["public_endpoint"] = field + else: + args["public_endpoint"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("scaling_option", None) + if field is not None: + args["scaling_option"] = unmarshal_ContainerScalingOption(field) + else: + args["scaling_option"] = None + + field = data.get("liveness_probe", None) + if field is not None: + args["liveness_probe"] = unmarshal_ContainerProbe(field) + else: + args["liveness_probe"] = None + + field = data.get("startup_probe", None) + if field is not None: + args["startup_probe"] = unmarshal_ContainerProbe(field) + else: + args["startup_probe"] = None + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + + return Container(**args) + + +def unmarshal_Domain(data: Any) -> Domain: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Domain' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("container_id", None) + if field is not None: + args["container_id"] = field + else: + args["container_id"] = None + + field = data.get("hostname", None) + if field is not None: + args["hostname"] = field + else: + args["hostname"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = DomainStatus.UNKNOWN_STATUS + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Domain(**args) + + +def unmarshal_Namespace(data: Any) -> Namespace: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Namespace' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = NamespaceStatus.UNKNOWN_STATUS + + field = data.get("environment_variables", None) + if field is not None: + args["environment_variables"] = field + else: + args["environment_variables"] = {} + + field = data.get("secret_environment_variables", None) + if field is not None: + args["secret_environment_variables"] = field + else: + args["secret_environment_variables"] = {} + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Namespace(**args) + + +def unmarshal_TriggerCronConfig(data: Any) -> TriggerCronConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerCronConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("schedule", None) + if field is not None: + args["schedule"] = field + else: + args["schedule"] = None + + field = data.get("timezone", None) + if field is not None: + args["timezone"] = field + else: + args["timezone"] = None + + field = data.get("body", None) + if field is not None: + args["body"] = field + else: + args["body"] = None + + field = data.get("headers", None) + if field is not None: + args["headers"] = field + else: + args["headers"] = {} + + return TriggerCronConfig(**args) + + +def unmarshal_TriggerDestinationConfig(data: Any) -> TriggerDestinationConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerDestinationConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("http_path", None) + if field is not None: + args["http_path"] = field + else: + args["http_path"] = None + + field = data.get("http_method", None) + if field is not None: + args["http_method"] = field + else: + args["http_method"] = TriggerDestinationConfigHttpMethod.UNKNOWN_HTTP_METHOD + + return TriggerDestinationConfig(**args) + + +def unmarshal_TriggerNATSConfig(data: Any) -> TriggerNATSConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerNATSConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("server_urls", None) + if field is not None: + args["server_urls"] = field + else: + args["server_urls"] = [] + + field = data.get("subject", None) + if field is not None: + args["subject"] = field + else: + args["subject"] = None + + return TriggerNATSConfig(**args) + + +def unmarshal_TriggerSQSConfig(data: Any) -> TriggerSQSConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerSQSConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("endpoint", None) + if field is not None: + args["endpoint"] = field + else: + args["endpoint"] = None + + field = data.get("access_key_id", None) + if field is not None: + args["access_key_id"] = field + else: + args["access_key_id"] = None + + field = data.get("queue_url", None) + if field is not None: + args["queue_url"] = field + else: + args["queue_url"] = None + + return TriggerSQSConfig(**args) + + +def unmarshal_Trigger(data: Any) -> Trigger: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Trigger' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = TriggerStatus.UNKNOWN_STATUS + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("container_id", None) + if field is not None: + args["container_id"] = field + else: + args["container_id"] = None + + field = data.get("source_type", None) + if field is not None: + args["source_type"] = field + else: + args["source_type"] = TriggerSourceType.UNKNOWN_SOURCE_TYPE + + field = data.get("destination_config", None) + if field is not None: + args["destination_config"] = unmarshal_TriggerDestinationConfig(field) + else: + args["destination_config"] = None + + field = data.get("cron_config", None) + if field is not None: + args["cron_config"] = unmarshal_TriggerCronConfig(field) + else: + args["cron_config"] = None + + field = data.get("sqs_config", None) + if field is not None: + args["sqs_config"] = unmarshal_TriggerSQSConfig(field) + else: + args["sqs_config"] = None + + field = data.get("nats_config", None) + if field is not None: + args["nats_config"] = unmarshal_TriggerNATSConfig(field) + else: + args["nats_config"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Trigger(**args) + + +def unmarshal_ListContainersResponse(data: Any) -> ListContainersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListContainersResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("containers", None) + if field is not None: + args["containers"] = ( + [unmarshal_Container(v) for v in field] if field is not None else None + ) + else: + args["containers"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListContainersResponse(**args) + + +def unmarshal_ListDomainsResponse(data: Any) -> ListDomainsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDomainsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("domains", None) + if field is not None: + args["domains"] = ( + [unmarshal_Domain(v) for v in field] if field is not None else None + ) + else: + args["domains"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListDomainsResponse(**args) + + +def unmarshal_ListNamespacesResponse(data: Any) -> ListNamespacesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNamespacesResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("namespaces", None) + if field is not None: + args["namespaces"] = ( + [unmarshal_Namespace(v) for v in field] if field is not None else None + ) + else: + args["namespaces"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListNamespacesResponse(**args) + + +def unmarshal_ListTriggersResponse(data: Any) -> ListTriggersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListTriggersResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("triggers", None) + if field is not None: + args["triggers"] = ( + [unmarshal_Trigger(v) for v in field] if field is not None else None + ) + else: + args["triggers"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListTriggersResponse(**args) + + +def marshal_ContainerProbeHTTPProbe( + request: ContainerProbeHTTPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_ContainerProbeTCPProbe( + request: ContainerProbeTCPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + return output + + +def marshal_ContainerProbe( + request: ContainerProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="tcp", + value=request.tcp, + marshal_func=marshal_ContainerProbeTCPProbe, + ), + OneOfPossibility( + param="http", + value=request.http, + marshal_func=marshal_ContainerProbeHTTPProbe, + ), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + if request.timeout is not None: + output["timeout"] = request.timeout + + return output + + +def marshal_ContainerScalingOption( + request: ContainerScalingOption, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="concurrent_requests_threshold", + value=request.concurrent_requests_threshold, + marshal_func=None, + ), + OneOfPossibility( + param="cpu_usage_threshold", + value=request.cpu_usage_threshold, + marshal_func=None, + ), + OneOfPossibility( + param="memory_usage_threshold", + value=request.memory_usage_threshold, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_CreateContainerRequest( + request: CreateContainerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.namespace_id is not None: + output["namespace_id"] = request.namespace_id + + if request.name is not None: + output["name"] = request.name + + if request.environment_variables is not None: + output["environment_variables"] = { + key: value for key, value in request.environment_variables.items() + } + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = { + key: value for key, value in request.secret_environment_variables.items() + } + + if request.min_scale is not None: + output["min_scale"] = request.min_scale + + if request.max_scale is not None: + output["max_scale"] = request.max_scale + + if request.memory_limit_bytes is not None: + output["memory_limit_bytes"] = request.memory_limit_bytes + + if request.mvcpu_limit is not None: + output["mvcpu_limit"] = request.mvcpu_limit + + if request.timeout is not None: + output["timeout"] = request.timeout + + if request.privacy is not None: + output["privacy"] = request.privacy + + if request.description is not None: + output["description"] = request.description + + if request.image is not None: + output["image"] = request.image + + if request.protocol is not None: + output["protocol"] = request.protocol + + if request.port is not None: + output["port"] = request.port + + if request.https_connections_only is not None: + output["https_connections_only"] = request.https_connections_only + + if request.sandbox is not None: + output["sandbox"] = request.sandbox + + if request.local_storage_limit_bytes is not None: + output["local_storage_limit_bytes"] = request.local_storage_limit_bytes + + if request.scaling_option is not None: + output["scaling_option"] = marshal_ContainerScalingOption( + request.scaling_option, defaults + ) + + if request.liveness_probe is not None: + output["liveness_probe"] = marshal_ContainerProbe( + request.liveness_probe, defaults + ) + + if request.startup_probe is not None: + output["startup_probe"] = marshal_ContainerProbe( + request.startup_probe, defaults + ) + + if request.tags is not None: + output["tags"] = request.tags + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.command is not None: + output["command"] = request.command + + if request.args is not None: + output["args"] = request.args + + return output + + +def marshal_CreateDomainRequest( + request: CreateDomainRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.container_id is not None: + output["container_id"] = request.container_id + + if request.hostname is not None: + output["hostname"] = request.hostname + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateNamespaceRequest( + request: CreateNamespaceRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.description is not None: + output["description"] = request.description + + if request.environment_variables is not None: + output["environment_variables"] = { + key: value for key, value in request.environment_variables.items() + } + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = { + key: value for key, value in request.secret_environment_variables.items() + } + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateTriggerRequestCronConfig( + request: CreateTriggerRequestCronConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.schedule is not None: + output["schedule"] = request.schedule + + if request.timezone is not None: + output["timezone"] = request.timezone + + if request.body is not None: + output["body"] = request.body + + if request.headers is not None: + output["headers"] = {key: value for key, value in request.headers.items()} + + return output + + +def marshal_CreateTriggerRequestDestinationConfig( + request: CreateTriggerRequestDestinationConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.http_path is not None: + output["http_path"] = request.http_path + + if request.http_method is not None: + output["http_method"] = request.http_method + + return output + + +def marshal_CreateTriggerRequestNATSConfig( + request: CreateTriggerRequestNATSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.server_urls is not None: + output["server_urls"] = request.server_urls + + if request.subject is not None: + output["subject"] = request.subject + + if request.credentials_file_content is not None: + output["credentials_file_content"] = request.credentials_file_content + + return output + + +def marshal_CreateTriggerRequestSQSConfig( + request: CreateTriggerRequestSQSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.region is not None: + output["region"] = request.region + else: + output["region"] = defaults.default_region + + if request.endpoint is not None: + output["endpoint"] = request.endpoint + + if request.access_key_id is not None: + output["access_key_id"] = request.access_key_id + + if request.secret_access_key is not None: + output["secret_access_key"] = request.secret_access_key + + if request.queue_url is not None: + output["queue_url"] = request.queue_url + + return output + + +def marshal_CreateTriggerRequest( + request: CreateTriggerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="cron_config", + value=request.cron_config, + marshal_func=marshal_CreateTriggerRequestCronConfig, + ), + OneOfPossibility( + param="sqs_config", + value=request.sqs_config, + marshal_func=marshal_CreateTriggerRequestSQSConfig, + ), + OneOfPossibility( + param="nats_config", + value=request.nats_config, + marshal_func=marshal_CreateTriggerRequestNATSConfig, + ), + ] + ), + ) + + if request.container_id is not None: + output["container_id"] = request.container_id + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.tags is not None: + output["tags"] = request.tags + + if request.destination_config is not None: + output["destination_config"] = marshal_CreateTriggerRequestDestinationConfig( + request.destination_config, defaults + ) + + return output + + +def marshal_UpdateContainerRequestProbeHTTPProbe( + request: UpdateContainerRequestProbeHTTPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_UpdateContainerRequestProbeTCPProbe( + request: UpdateContainerRequestProbeTCPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + return output + + +def marshal_UpdateContainerRequestProbe( + request: UpdateContainerRequestProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="http", + value=request.http, + marshal_func=marshal_UpdateContainerRequestProbeHTTPProbe, + ), + OneOfPossibility( + param="tcp", + value=request.tcp, + marshal_func=marshal_UpdateContainerRequestProbeTCPProbe, + ), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + if request.timeout is not None: + output["timeout"] = request.timeout + + return output + + +def marshal_UpdateContainerRequest( + request: UpdateContainerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.environment_variables is not None: + output["environment_variables"] = request.environment_variables + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = request.secret_environment_variables + + if request.min_scale is not None: + output["min_scale"] = request.min_scale + + if request.max_scale is not None: + output["max_scale"] = request.max_scale + + if request.memory_limit_bytes is not None: + output["memory_limit_bytes"] = request.memory_limit_bytes + + if request.mvcpu_limit is not None: + output["mvcpu_limit"] = request.mvcpu_limit + + if request.timeout is not None: + output["timeout"] = request.timeout + + if request.privacy is not None: + output["privacy"] = request.privacy + + if request.description is not None: + output["description"] = request.description + + if request.image is not None: + output["image"] = request.image + + if request.protocol is not None: + output["protocol"] = request.protocol + + if request.port is not None: + output["port"] = request.port + + if request.https_connection_only is not None: + output["https_connection_only"] = request.https_connection_only + + if request.sandbox is not None: + output["sandbox"] = request.sandbox + + if request.local_storage_limit_bytes is not None: + output["local_storage_limit_bytes"] = request.local_storage_limit_bytes + + if request.scaling_option is not None: + output["scaling_option"] = marshal_ContainerScalingOption( + request.scaling_option, defaults + ) + + if request.liveness_probe is not None: + output["liveness_probe"] = marshal_ContainerProbe( + request.liveness_probe, defaults + ) + + if request.startup_probe is not None: + output["startup_probe"] = marshal_UpdateContainerRequestProbe( + request.startup_probe, defaults + ) + + if request.tags is not None: + output["tags"] = request.tags + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.command is not None: + output["command"] = request.command + + if request.args is not None: + output["args"] = request.args + + return output + + +def marshal_UpdateDomainRequest( + request: UpdateDomainRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateNamespaceRequest( + request: UpdateNamespaceRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.description is not None: + output["description"] = request.description + + if request.environment_variables is not None: + output["environment_variables"] = request.environment_variables + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = request.secret_environment_variables + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateTriggerRequestCronConfig( + request: UpdateTriggerRequestCronConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.schedule is not None: + output["schedule"] = request.schedule + + if request.timezone is not None: + output["timezone"] = request.timezone + + if request.body is not None: + output["body"] = request.body + + if request.headers is not None: + output["headers"] = request.headers + + return output + + +def marshal_UpdateTriggerRequestDestinationConfig( + request: UpdateTriggerRequestDestinationConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.http_path is not None: + output["http_path"] = request.http_path + + if request.http_method is not None: + output["http_method"] = request.http_method + + return output + + +def marshal_UpdateTriggerRequestNATSConfig( + request: UpdateTriggerRequestNATSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.server_urls is not None: + output["server_urls"] = request.server_urls + + if request.subject is not None: + output["subject"] = request.subject + + if request.credentials_file_content is not None: + output["credentials_file_content"] = request.credentials_file_content + + return output + + +def marshal_UpdateTriggerRequestSQSConfig( + request: UpdateTriggerRequestSQSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.region is not None: + output["region"] = request.region + + if request.endpoint is not None: + output["endpoint"] = request.endpoint + + if request.access_key_id is not None: + output["access_key_id"] = request.access_key_id + + if request.secret_access_key is not None: + output["secret_access_key"] = request.secret_access_key + + if request.queue_url is not None: + output["queue_url"] = request.queue_url + + return output + + +def marshal_UpdateTriggerRequest( + request: UpdateTriggerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="cron_config", + value=request.cron_config, + marshal_func=marshal_UpdateTriggerRequestCronConfig, + ), + OneOfPossibility( + param="sqs_config", + value=request.sqs_config, + marshal_func=marshal_UpdateTriggerRequestSQSConfig, + ), + OneOfPossibility( + param="nats_config", + value=request.nats_config, + marshal_func=marshal_UpdateTriggerRequestNATSConfig, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.tags is not None: + output["tags"] = request.tags + + if request.destination_config is not None: + output["destination_config"] = marshal_UpdateTriggerRequestDestinationConfig( + request.destination_config, defaults + ) + + return output diff --git a/scaleway-async/scaleway_async/container/v1/types.py b/scaleway-async/scaleway_async/container/v1/types.py new file mode 100644 index 000000000..f931ca056 --- /dev/null +++ b/scaleway-async/scaleway_async/container/v1/types.py @@ -0,0 +1,1490 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum +from typing import Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class ContainerPrivacy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PRIVACY = "unknown_privacy" + PUBLIC = "public" + PRIVATE = "private" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerProtocol(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PROTOCOL = "unknown_protocol" + HTTP1 = "http1" + H2C = "h2c" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerSandbox(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SANDBOX = "unknown_sandbox" + V1 = "v1" + V2 = "v2" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UPDATING = "updating" + DELETING = "deleting" + LOCKING = "locking" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + CREATING = "creating" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class CreateTriggerRequestDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +class DomainStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + UPDATING = "updating" + DELETING = "deleting" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + LOCKING = "locking" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class ListContainersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDomainsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + HOSTNAME_ASC = "hostname_asc" + HOSTNAME_DESC = "hostname_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListNamespacesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTriggersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class NamespaceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UPDATING = "updating" + DELETING = "deleting" + LOCKING = "locking" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + CREATING = "creating" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerSourceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SOURCE_TYPE = "unknown_source_type" + CRON = "cron" + SQS = "sqs" + NATS = "nats" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + UPDATING = "updating" + CREATING = "creating" + LOCKING = "locking" + LOCKED = "locked" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class UpdateTriggerRequestDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ContainerProbeHTTPProbe: + path: str + """ + HTTP path to perform the check on. + """ + + +@dataclass +class ContainerProbeTCPProbe: + pass + + +@dataclass +class ContainerProbe: + failure_threshold: int + """ + Unhealthy containers do not receive traffic from incoming requests. + """ + + interval: Optional[str] = None + """ + Time interval between checks. + """ + + timeout: Optional[str] = None + """ + Duration before the check times out. + """ + + tcp: Optional[ContainerProbeTCPProbe] = None + + http: Optional[ContainerProbeHTTPProbe] = None + + +@dataclass +class ContainerScalingOption: + concurrent_requests_threshold: Optional[int] = 0 + + cpu_usage_threshold: Optional[int] = 0 + + memory_usage_threshold: Optional[int] = 0 + + +@dataclass +class TriggerCronConfig: + schedule: str + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: str + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: str + """ + Body to send to the container when the trigger is invoked. + """ + + headers: dict[str, str] + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class TriggerDestinationConfig: + http_path: str + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: TriggerDestinationConfigHttpMethod + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class TriggerNATSConfig: + server_urls: list[str] + """ + The URLs of the NATS servers (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: str + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + +@dataclass +class TriggerSQSConfig: + region: ScwRegion + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: str + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: str + """ + The access key for accessing the SQS queue. + """ + + queue_url: str + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class UpdateContainerRequestProbeHTTPProbe: + path: Optional[str] = None + + +@dataclass +class UpdateContainerRequestProbeTCPProbe: + pass + + +@dataclass +class CreateTriggerRequestCronConfig: + schedule: str + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: str + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: str + """ + Body to send to the container when the trigger is invoked. + """ + + headers: dict[str, str] + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class CreateTriggerRequestDestinationConfig: + http_path: str + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: CreateTriggerRequestDestinationConfigHttpMethod + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class CreateTriggerRequestNATSConfig: + server_urls: list[str] + """ + The URLs of the NATS server (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: str + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + credentials_file_content: str + """ + The credentials from this file will be used to authenticate with the NATS server and subscribe to the specified subject. + """ + + +@dataclass +class CreateTriggerRequestSQSConfig: + region: ScwRegion + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: str + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: str + """ + The access key for accessing the SQS queue. + """ + + secret_access_key: str + """ + The secret key for accessing the SQS queue. + """ + + queue_url: str + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class Container: + id: str + """ + Container unique ID. + """ + + name: str + """ + Container name. + """ + + namespace_id: str + """ + Unique ID of the namespace the container belongs to. + """ + + description: str + """ + Container description. + """ + + status: ContainerStatus + """ + Container status. + """ + + environment_variables: dict[str, str] + """ + Environment variables of the container. + """ + + secret_environment_variables: dict[str, str] + """ + Secret environment variables of the container. + """ + + min_scale: int + """ + Minimum number of instances to scale the container to. + """ + + max_scale: int + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: int + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: int + """ + CPU limit of the container in mvCPU. + """ + + local_storage_limit_bytes: int + """ + Local storage limit of the container (in bytes). + """ + + privacy: ContainerPrivacy + """ + Privacy policy of the container. + """ + + image: str + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + protocol: ContainerProtocol + """ + Protocol the container uses. + """ + + port: int + """ + Port the container listens on. + """ + + https_connections_only: bool + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: ContainerSandbox + """ + Execution environment of the container. + """ + + tags: list[str] + """ + Tags of the Serverless Container. + """ + + command: list[str] + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: list[str] + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + public_endpoint: str + """ + This is the default endpoint generated by Scaleway to access the container from the Internet. + """ + + region: ScwRegion + """ + Region in which the container exists. + """ + + error_message: Optional[str] = None + """ + Container last error message. + """ + + created_at: Optional[datetime] = None + """ + Container creation date. + """ + + updated_at: Optional[datetime] = None + """ + Container last update date. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[ContainerProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + +@dataclass +class Domain: + id: str + """ + Domain unique ID. + """ + + container_id: str + """ + Unique ID of the container the domain is assigned to. + """ + + hostname: str + """ + Domain assigned to the container. + """ + + status: DomainStatus + """ + Domain status. + """ + + tags: list[str] + """ + A list of arbitrary tags associated with the domain. + """ + + error_message: Optional[str] = None + """ + Domain last error message. + """ + + created_at: Optional[datetime] = None + """ + Domain creation date. + """ + + updated_at: Optional[datetime] = None + """ + Domain last update date. + """ + + +@dataclass +class Namespace: + id: str + """ + Namespace unique ID. + """ + + name: str + """ + Namespace name. + """ + + organization_id: str + """ + Unique ID of the Organization the namespace belongs to. + """ + + project_id: str + """ + Unique ID of the Project the namespace belongs to. + """ + + description: str + """ + Namespace description. + """ + + status: NamespaceStatus + """ + Namespace status. + """ + + environment_variables: dict[str, str] + """ + Namespace environment variables. + """ + + secret_environment_variables: dict[str, str] + """ + Namespace secret environment variables. + """ + + tags: list[str] + """ + A list of arbitrary tags associated with the namespace. + """ + + region: ScwRegion + """ + Region in which the namespace will be created. + """ + + error_message: Optional[str] = None + """ + Namespace last error message. + """ + + created_at: Optional[datetime] = None + """ + Namespace creation date. + """ + + updated_at: Optional[datetime] = None + """ + Namespace last update date. + """ + + +@dataclass +class Trigger: + id: str + """ + Trigger unique ID. + """ + + name: str + """ + Name of the trigger. + """ + + description: str + """ + Description of the trigger. + """ + + tags: list[str] + """ + Tags of the trigger. + """ + + status: TriggerStatus + """ + Trigger status. + """ + + container_id: str + """ + ID of the container to trigger. + """ + + source_type: TriggerSourceType + """ + Type of source that will trigger the container. + """ + + error_message: Optional[str] = None + """ + Trigger last error message. + """ + + destination_config: Optional[TriggerDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + created_at: Optional[datetime] = None + """ + Trigger creation date. + """ + + updated_at: Optional[datetime] = None + """ + Trigger last update date. + """ + + cron_config: Optional[TriggerCronConfig] = None + + sqs_config: Optional[TriggerSQSConfig] = None + + nats_config: Optional[TriggerNATSConfig] = None + + +@dataclass +class UpdateContainerRequestProbe: + failure_threshold: Optional[int] = None + interval: Optional[str] = None + timeout: Optional[str] = None + http: Optional[UpdateContainerRequestProbeHTTPProbe] = None + + tcp: Optional[UpdateContainerRequestProbeTCPProbe] = None + + +@dataclass +class UpdateTriggerRequestCronConfig: + schedule: Optional[str] = None + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: Optional[str] = None + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: Optional[str] = None + """ + Body to send to the container when the trigger is invoked. + """ + + headers: Optional[dict[str, str]] = field(default_factory=dict) + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class UpdateTriggerRequestDestinationConfig: + http_path: Optional[str] = None + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: Optional[UpdateTriggerRequestDestinationConfigHttpMethod] = ( + UpdateTriggerRequestDestinationConfigHttpMethod.UNKNOWN_HTTP_METHOD + ) + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class UpdateTriggerRequestNATSConfig: + server_urls: Optional[list[str]] = field(default_factory=list) + """ + The URLs of the NATS server (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: Optional[str] = None + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + credentials_file_content: Optional[str] = None + """ + The credentials from this file will be used to authenticate with the NATS server and subscribe to the specified subject. + """ + + +@dataclass +class UpdateTriggerRequestSQSConfig: + region: Optional[ScwRegion] = None + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: Optional[str] = None + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: Optional[str] = None + """ + The access key for accessing the SQS queue. + """ + + secret_access_key: Optional[str] = None + """ + The secret key for accessing the SQS queue. + """ + + queue_url: Optional[str] = None + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class CreateContainerRequest: + namespace_id: str + """ + Unique ID of the namespace the container belongs to. + """ + + name: str + """ + Container name. + """ + + image: str + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Environment variables of the container. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Secret environment variables of the container. + """ + + min_scale: Optional[int] = 0 + """ + Minimum number of instances to scale the container to. + """ + + max_scale: Optional[int] = 0 + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: Optional[int] = 0 + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: Optional[int] = 0 + """ + CPU limit of the container in mvCPU. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + privacy: Optional[ContainerPrivacy] = ContainerPrivacy.UNKNOWN_PRIVACY + """ + Privacy policy of the container. + """ + + description: Optional[str] = None + """ + Container description. + """ + + protocol: Optional[ContainerProtocol] = ContainerProtocol.UNKNOWN_PROTOCOL + """ + Protocol the container uses. + """ + + port: Optional[int] = 0 + """ + Port the container listens on. + """ + + https_connections_only: Optional[bool] = False + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: Optional[ContainerSandbox] = ContainerSandbox.UNKNOWN_SANDBOX + """ + Execution environment of the container. + """ + + local_storage_limit_bytes: Optional[int] = 0 + """ + Local storage limit of the container (in bytes). + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[ContainerProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the Serverless Container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + command: Optional[list[str]] = field(default_factory=list) + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: Optional[list[str]] = field(default_factory=list) + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + +@dataclass +class CreateDomainRequest: + container_id: str + """ + Unique ID of the container the domain will be assigned to. + """ + + hostname: str + """ + Domain assigned to the container. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the domain. + """ + + +@dataclass +class CreateNamespaceRequest: + name: str + """ + Namespace name. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + Unique ID of the Project the namespace belongs to. + """ + + description: Optional[str] = None + """ + Namespace description. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace environment variables. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace secret environment variables. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the namespace. + """ + + +@dataclass +class CreateTriggerRequest: + container_id: str + """ + ID of the container to trigger. + """ + + name: str + """ + Name of the trigger. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + description: Optional[str] = None + """ + Description of the trigger. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the trigger. + """ + + destination_config: Optional[CreateTriggerRequestDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + cron_config: Optional[CreateTriggerRequestCronConfig] = None + + sqs_config: Optional[CreateTriggerRequestSQSConfig] = None + + nats_config: Optional[CreateTriggerRequestNATSConfig] = None + + +@dataclass +class DeleteContainerRequest: + container_id: str + """ + UUID of the container to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteDomainRequest: + domain_id: str + """ + UUID of the domain to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteNamespaceRequest: + namespace_id: str + """ + UUID of the namespace to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteTriggerRequest: + trigger_id: str + """ + ID of the trigger to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetContainerRequest: + container_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDomainRequest: + domain_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetNamespaceRequest: + namespace_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetServiceInfoRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetTriggerRequest: + trigger_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListContainersRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListContainersRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + name: Optional[str] = None + + +@dataclass +class ListContainersResponse: + containers: list[Container] + total_count: int + + +@dataclass +class ListDomainsRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListDomainsRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + container_id: Optional[str] = None + + +@dataclass +class ListDomainsResponse: + domains: list[Domain] + total_count: int + + +@dataclass +class ListNamespacesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListNamespacesRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + name: Optional[str] = None + + +@dataclass +class ListNamespacesResponse: + namespaces: list[Namespace] + total_count: int + + +@dataclass +class ListTriggersRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListTriggersRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + container_id: Optional[str] = None + + +@dataclass +class ListTriggersResponse: + triggers: list[Trigger] + total_count: int + + +@dataclass +class RedeployContainerRequest: + container_id: str + """ + ID of the container to redeploy. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class UpdateContainerRequest: + container_id: str + """ + UUID of the container to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Environment variables of the container. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Secret environment variables of the container. + """ + + min_scale: Optional[int] = 0 + """ + Minimum number of instances to scale the container to. + """ + + max_scale: Optional[int] = 0 + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: Optional[int] = 0 + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: Optional[int] = 0 + """ + CPU limit of the container in mvCPU. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + privacy: Optional[ContainerPrivacy] = ContainerPrivacy.UNKNOWN_PRIVACY + """ + Privacy policy of the container. + """ + + description: Optional[str] = None + """ + Container description. + """ + + image: Optional[str] = None + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + protocol: Optional[ContainerProtocol] = ContainerProtocol.UNKNOWN_PROTOCOL + """ + Protocol the container uses. + """ + + port: Optional[int] = 0 + """ + Port the container listens on. + """ + + https_connection_only: Optional[bool] = False + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: Optional[ContainerSandbox] = ContainerSandbox.UNKNOWN_SANDBOX + """ + Execution environment of the container. + """ + + local_storage_limit_bytes: Optional[int] = 0 + """ + Local storage limit of the container (in bytes). + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[UpdateContainerRequestProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the Serverless Container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + command: Optional[list[str]] = field(default_factory=list) + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: Optional[list[str]] = field(default_factory=list) + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + +@dataclass +class UpdateDomainRequest: + domain_id: str + """ + UUID of the domain to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the domain. + """ + + +@dataclass +class UpdateNamespaceRequest: + namespace_id: str + """ + UUID of the namespace to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + description: Optional[str] = None + """ + Namespace description. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace environment variables. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace secret environment variables. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the namespace. + """ + + +@dataclass +class UpdateTriggerRequest: + trigger_id: str + """ + ID of the trigger to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the trigger. + """ + + description: Optional[str] = None + """ + Description of the trigger. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the trigger. + """ + + destination_config: Optional[UpdateTriggerRequestDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + cron_config: Optional[UpdateTriggerRequestCronConfig] = None + + sqs_config: Optional[UpdateTriggerRequestSQSConfig] = None + + nats_config: Optional[UpdateTriggerRequestNATSConfig] = None diff --git a/scaleway-async/scaleway_async/container/v1beta1/api.py b/scaleway-async/scaleway_async/container/v1beta1/api.py index 3f75db9f2..4aec43e70 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/api.py +++ b/scaleway-async/scaleway_async/container/v1beta1/api.py @@ -616,6 +616,9 @@ async def create_container( """ Create a new container. Create a new container in the specified region. + + When creating a container, the `created` status is no longer used. The deployment process is started + and the status is set to `pending` accordingly. :param namespace_id: UUID of the namespace the container belongs to. :param name: Name of the container. :param region: Region to target. If none is passed will use default region from the config. @@ -733,7 +736,8 @@ async def update_container( Update the container associated with the specified ID. When updating a container, the container is automatically redeployed to apply the changes. - This behavior can be changed by setting the `redeploy` field to `false` in the request. + + Warning: The `redeploy` field has been deprecated. An update now always redeploys the container. :param container_id: UUID of the container to update. :param region: Region to target. If none is passed will use default region from the config. :param environment_variables: Environment variables of the container. @@ -874,6 +878,10 @@ async def deploy_container( """ Deploy a container. Deploy a container associated with the specified ID. + + Since updating a container now always deploys it (and passes its status to `pending`), this call becomes superfluous. + + Moreover, calling `DeployContainer` immediately after `UpdateContainer` can cause `409 - resource is in a transient state` errors, so it is better to not use it when updating a container. :param container_id: UUID of the container to deploy. :param region: Region to target. If none is passed will use default region from the config. :return: :class:`Container ` diff --git a/scaleway-async/scaleway_async/container/v1beta1/types.py b/scaleway-async/scaleway_async/container/v1beta1/types.py index 6f645841b..0c20744c7 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/types.py +++ b/scaleway-async/scaleway_async/container/v1beta1/types.py @@ -428,7 +428,7 @@ class Container: domain_name: str """ - Domain name attributed to the contaioner. + Domain name attributed to the container. """ protocol: ContainerProtocol @@ -657,7 +657,7 @@ class Namespace: error_message: Optional[str] = None """ - Last error message of the namesace. + Last error message of the namespace. """ description: Optional[str] = None diff --git a/scaleway/scaleway/container/v1/__init__.py b/scaleway/scaleway/container/v1/__init__.py new file mode 100644 index 000000000..0aa584254 --- /dev/null +++ b/scaleway/scaleway/container/v1/__init__.py @@ -0,0 +1,143 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from .types import ContainerPrivacy +from .types import ContainerProtocol +from .types import ContainerSandbox +from .types import ContainerStatus +from .content import CONTAINER_TRANSIENT_STATUSES +from .types import CreateTriggerRequestDestinationConfigHttpMethod +from .types import DomainStatus +from .content import DOMAIN_TRANSIENT_STATUSES +from .types import ListContainersRequestOrderBy +from .types import ListDomainsRequestOrderBy +from .types import ListNamespacesRequestOrderBy +from .types import ListTriggersRequestOrderBy +from .types import NamespaceStatus +from .content import NAMESPACE_TRANSIENT_STATUSES +from .types import TriggerDestinationConfigHttpMethod +from .types import TriggerSourceType +from .types import TriggerStatus +from .content import TRIGGER_TRANSIENT_STATUSES +from .types import UpdateTriggerRequestDestinationConfigHttpMethod +from .types import ContainerProbeHTTPProbe +from .types import ContainerProbeTCPProbe +from .types import ContainerProbe +from .types import ContainerScalingOption +from .types import TriggerCronConfig +from .types import TriggerDestinationConfig +from .types import TriggerNATSConfig +from .types import TriggerSQSConfig +from .types import UpdateContainerRequestProbeHTTPProbe +from .types import UpdateContainerRequestProbeTCPProbe +from .types import CreateTriggerRequestCronConfig +from .types import CreateTriggerRequestDestinationConfig +from .types import CreateTriggerRequestNATSConfig +from .types import CreateTriggerRequestSQSConfig +from .types import Container +from .types import Domain +from .types import Namespace +from .types import Trigger +from .types import UpdateContainerRequestProbe +from .types import UpdateTriggerRequestCronConfig +from .types import UpdateTriggerRequestDestinationConfig +from .types import UpdateTriggerRequestNATSConfig +from .types import UpdateTriggerRequestSQSConfig +from .types import CreateContainerRequest +from .types import CreateDomainRequest +from .types import CreateNamespaceRequest +from .types import CreateTriggerRequest +from .types import DeleteContainerRequest +from .types import DeleteDomainRequest +from .types import DeleteNamespaceRequest +from .types import DeleteTriggerRequest +from .types import GetContainerRequest +from .types import GetDomainRequest +from .types import GetNamespaceRequest +from .types import GetServiceInfoRequest +from .types import GetTriggerRequest +from .types import ListContainersRequest +from .types import ListContainersResponse +from .types import ListDomainsRequest +from .types import ListDomainsResponse +from .types import ListNamespacesRequest +from .types import ListNamespacesResponse +from .types import ListTriggersRequest +from .types import ListTriggersResponse +from .types import RedeployContainerRequest +from .types import UpdateContainerRequest +from .types import UpdateDomainRequest +from .types import UpdateNamespaceRequest +from .types import UpdateTriggerRequest +from .api import ContainerV1API + +__all__ = [ + "ContainerPrivacy", + "ContainerProtocol", + "ContainerSandbox", + "ContainerStatus", + "CONTAINER_TRANSIENT_STATUSES", + "CreateTriggerRequestDestinationConfigHttpMethod", + "DomainStatus", + "DOMAIN_TRANSIENT_STATUSES", + "ListContainersRequestOrderBy", + "ListDomainsRequestOrderBy", + "ListNamespacesRequestOrderBy", + "ListTriggersRequestOrderBy", + "NamespaceStatus", + "NAMESPACE_TRANSIENT_STATUSES", + "TriggerDestinationConfigHttpMethod", + "TriggerSourceType", + "TriggerStatus", + "TRIGGER_TRANSIENT_STATUSES", + "UpdateTriggerRequestDestinationConfigHttpMethod", + "ContainerProbeHTTPProbe", + "ContainerProbeTCPProbe", + "ContainerProbe", + "ContainerScalingOption", + "TriggerCronConfig", + "TriggerDestinationConfig", + "TriggerNATSConfig", + "TriggerSQSConfig", + "UpdateContainerRequestProbeHTTPProbe", + "UpdateContainerRequestProbeTCPProbe", + "CreateTriggerRequestCronConfig", + "CreateTriggerRequestDestinationConfig", + "CreateTriggerRequestNATSConfig", + "CreateTriggerRequestSQSConfig", + "Container", + "Domain", + "Namespace", + "Trigger", + "UpdateContainerRequestProbe", + "UpdateTriggerRequestCronConfig", + "UpdateTriggerRequestDestinationConfig", + "UpdateTriggerRequestNATSConfig", + "UpdateTriggerRequestSQSConfig", + "CreateContainerRequest", + "CreateDomainRequest", + "CreateNamespaceRequest", + "CreateTriggerRequest", + "DeleteContainerRequest", + "DeleteDomainRequest", + "DeleteNamespaceRequest", + "DeleteTriggerRequest", + "GetContainerRequest", + "GetDomainRequest", + "GetNamespaceRequest", + "GetServiceInfoRequest", + "GetTriggerRequest", + "ListContainersRequest", + "ListContainersResponse", + "ListDomainsRequest", + "ListDomainsResponse", + "ListNamespacesRequest", + "ListNamespacesResponse", + "ListTriggersRequest", + "ListTriggersResponse", + "RedeployContainerRequest", + "UpdateContainerRequest", + "UpdateDomainRequest", + "UpdateNamespaceRequest", + "UpdateTriggerRequest", + "ContainerV1API", +] diff --git a/scaleway/scaleway/container/v1/api.py b/scaleway/scaleway/container/v1/api.py new file mode 100644 index 000000000..2ca7fa52f --- /dev/null +++ b/scaleway/scaleway/container/v1/api.py @@ -0,0 +1,1538 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + ServiceInfo, + unmarshal_ServiceInfo, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + ContainerPrivacy, + ContainerProtocol, + ContainerSandbox, + ListContainersRequestOrderBy, + ListDomainsRequestOrderBy, + ListNamespacesRequestOrderBy, + ListTriggersRequestOrderBy, + Container, + ContainerProbe, + ContainerScalingOption, + CreateContainerRequest, + CreateDomainRequest, + CreateNamespaceRequest, + CreateTriggerRequest, + CreateTriggerRequestCronConfig, + CreateTriggerRequestDestinationConfig, + CreateTriggerRequestNATSConfig, + CreateTriggerRequestSQSConfig, + Domain, + ListContainersResponse, + ListDomainsResponse, + ListNamespacesResponse, + ListTriggersResponse, + Namespace, + Trigger, + UpdateContainerRequest, + UpdateContainerRequestProbe, + UpdateDomainRequest, + UpdateNamespaceRequest, + UpdateTriggerRequest, + UpdateTriggerRequestCronConfig, + UpdateTriggerRequestDestinationConfig, + UpdateTriggerRequestNATSConfig, + UpdateTriggerRequestSQSConfig, +) +from .content import ( + CONTAINER_TRANSIENT_STATUSES, + DOMAIN_TRANSIENT_STATUSES, + NAMESPACE_TRANSIENT_STATUSES, + TRIGGER_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Container, + unmarshal_Domain, + unmarshal_Namespace, + unmarshal_Trigger, + unmarshal_ListContainersResponse, + unmarshal_ListDomainsResponse, + unmarshal_ListNamespacesResponse, + unmarshal_ListTriggersResponse, + marshal_CreateContainerRequest, + marshal_CreateDomainRequest, + marshal_CreateNamespaceRequest, + marshal_CreateTriggerRequest, + marshal_UpdateContainerRequest, + marshal_UpdateDomainRequest, + marshal_UpdateNamespaceRequest, + marshal_UpdateTriggerRequest, +) + + +class ContainerV1API(API): + """ + Easily run containers on the cloud with a single command. + """ + + def get_service_info( + self, + *, + region: Optional[ScwRegion] = None, + ) -> ServiceInfo: + """ + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`ServiceInfo ` + + Usage: + :: + + result = api.get_service_info() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}", + ) + + self._throw_on_error(res) + return unmarshal_ServiceInfo(res.json()) + + def create_namespace( + self, + *, + name: str, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + description: Optional[str] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + tags: Optional[list[str]] = None, + ) -> Namespace: + """ + Create a new namespace. + Namespace name must be unique inside a project. + :param name: Namespace name. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: Unique ID of the Project the namespace belongs to. + :param description: Namespace description. + :param environment_variables: Namespace environment variables. + :param secret_environment_variables: Namespace secret environment variables. + :param tags: A list of arbitrary tags associated with the namespace. + :return: :class:`Namespace ` + + Usage: + :: + + result = api.create_namespace( + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/namespaces", + body=marshal_CreateNamespaceRequest( + CreateNamespaceRequest( + name=name, + region=region, + project_id=project_id, + description=description, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + def get_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + ) -> Namespace: + """ + Get the namespace associated with the specified ID. + :param namespace_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = api.get_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + def wait_for_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Namespace, bool]] = None, + ) -> Namespace: + """ + Get the namespace associated with the specified ID. + :param namespace_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = api.get_namespace( + namespace_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in NAMESPACE_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_namespace, + options=options, + args={ + "namespace_id": namespace_id, + "region": region, + }, + ) + + def list_namespaces( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListNamespacesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListNamespacesResponse: + """ + List all namespaces the caller can access (read permission). + By default, the namespaces listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param name: + :return: :class:`ListNamespacesResponse ` + + Usage: + :: + + result = api.list_namespaces() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/namespaces", + params={ + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListNamespacesResponse(res.json()) + + def list_namespaces_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListNamespacesRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + ) -> list[Namespace]: + """ + List all namespaces the caller can access (read permission). + By default, the namespaces listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param name: + :return: :class:`list[Namespace] ` + + Usage: + :: + + result = api.list_namespaces_all() + """ + + return fetch_all_pages( + type=ListNamespacesResponse, + key="namespaces", + fetcher=self.list_namespaces, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "name": name, + }, + ) + + def update_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + description: Optional[str] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + tags: Optional[list[str]] = None, + ) -> Namespace: + """ + Update the namespace associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param namespace_id: UUID of the namespace to update. + :param region: Region to target. If none is passed will use default region from the config. + :param description: Namespace description. + :param environment_variables: Namespace environment variables. + :param secret_environment_variables: Namespace secret environment variables. + :param tags: A list of arbitrary tags associated with the namespace. + :return: :class:`Namespace ` + + Usage: + :: + + result = api.update_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + body=marshal_UpdateNamespaceRequest( + UpdateNamespaceRequest( + namespace_id=namespace_id, + region=region, + description=description, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + def delete_namespace( + self, + *, + namespace_id: str, + region: Optional[ScwRegion] = None, + ) -> Namespace: + """ + Delete the namespace associated with the specified ID. + It also deletes in cascade any resource inside the namespace. + + This action **cannot** be undone. + :param namespace_id: UUID of the namespace to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Namespace ` + + Usage: + :: + + result = api.delete_namespace( + namespace_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_namespace_id = validate_path_param("namespace_id", namespace_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/namespaces/{param_namespace_id}", + ) + + self._throw_on_error(res) + return unmarshal_Namespace(res.json()) + + def create_container( + self, + *, + namespace_id: str, + name: str, + region: Optional[ScwRegion] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + min_scale: Optional[int] = None, + max_scale: Optional[int] = None, + memory_limit_bytes: Optional[int] = None, + mvcpu_limit: Optional[int] = None, + timeout: Optional[str] = None, + privacy: Optional[ContainerPrivacy] = None, + description: Optional[str] = None, + image: str, + protocol: Optional[ContainerProtocol] = None, + port: Optional[int] = None, + https_connections_only: Optional[bool] = None, + sandbox: Optional[ContainerSandbox] = None, + local_storage_limit_bytes: Optional[int] = None, + scaling_option: Optional[ContainerScalingOption] = None, + liveness_probe: Optional[ContainerProbe] = None, + startup_probe: Optional[ContainerProbe] = None, + tags: Optional[list[str]] = None, + private_network_id: Optional[str] = None, + command: Optional[list[str]] = None, + args: Optional[list[str]] = None, + ) -> Container: + """ + Create a new container in a namespace. + Name must be unique inside the given namespace. + :param namespace_id: Unique ID of the namespace the container belongs to. + :param name: Container name. + :param region: Region to target. If none is passed will use default region from the config. + :param environment_variables: Environment variables of the container. + :param secret_environment_variables: Secret environment variables of the container. + :param min_scale: Minimum number of instances to scale the container to. + :param max_scale: Maximum number of instances to scale the container to. + :param memory_limit_bytes: Memory limit of the container in bytes. + :param mvcpu_limit: CPU limit of the container in mvCPU. + :param timeout: Processing time limit for the container. + :param privacy: Privacy policy of the container. + :param description: Container description. + :param image: Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + :param protocol: Protocol the container uses. + :param port: Port the container listens on. + :param https_connections_only: If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + :param sandbox: Execution environment of the container. + :param local_storage_limit_bytes: Local storage limit of the container (in bytes). + :param scaling_option: Parameter used to decide when to scale up or down. + :param liveness_probe: If the liveness probe fails, the container will be restarted. + It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param startup_probe: If the startup probe fails, the container will be restarted. + This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param tags: Tags of the Serverless Container. + :param private_network_id: When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + :param command: Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + :param args: Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + :return: :class:`Container ` + + Usage: + :: + + result = api.create_container( + namespace_id="example", + name="example", + image="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/containers", + body=marshal_CreateContainerRequest( + CreateContainerRequest( + namespace_id=namespace_id, + name=name, + region=region, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + min_scale=min_scale, + max_scale=max_scale, + memory_limit_bytes=memory_limit_bytes, + mvcpu_limit=mvcpu_limit, + timeout=timeout, + privacy=privacy, + description=description, + image=image, + protocol=protocol, + port=port, + https_connections_only=https_connections_only, + sandbox=sandbox, + local_storage_limit_bytes=local_storage_limit_bytes, + scaling_option=scaling_option, + liveness_probe=liveness_probe, + startup_probe=startup_probe, + tags=tags, + private_network_id=private_network_id, + command=command, + args=args, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + def get_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Get the container associated with the specified ID. + :param container_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = api.get_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + def wait_for_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Container, bool]] = None, + ) -> Container: + """ + Get the container associated with the specified ID. + :param container_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = api.get_container( + container_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in CONTAINER_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_container, + options=options, + args={ + "container_id": container_id, + "region": region, + }, + ) + + def list_containers( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListContainersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + name: Optional[str] = None, + ) -> ListContainersResponse: + """ + List all containers the caller can access (read permission). + By default, the containers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param name: + :return: :class:`ListContainersResponse ` + + Usage: + :: + + result = api.list_containers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/containers", + params={ + "name": name, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListContainersResponse(res.json()) + + def list_containers_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListContainersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + name: Optional[str] = None, + ) -> list[Container]: + """ + List all containers the caller can access (read permission). + By default, the containers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, and `name`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param name: + :return: :class:`list[Container] ` + + Usage: + :: + + result = api.list_containers_all() + """ + + return fetch_all_pages( + type=ListContainersResponse, + key="containers", + fetcher=self.list_containers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "name": name, + }, + ) + + def update_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + environment_variables: Optional[dict[str, str]] = None, + secret_environment_variables: Optional[dict[str, str]] = None, + min_scale: Optional[int] = None, + max_scale: Optional[int] = None, + memory_limit_bytes: Optional[int] = None, + mvcpu_limit: Optional[int] = None, + timeout: Optional[str] = None, + privacy: Optional[ContainerPrivacy] = None, + description: Optional[str] = None, + image: Optional[str] = None, + protocol: Optional[ContainerProtocol] = None, + port: Optional[int] = None, + https_connection_only: Optional[bool] = None, + sandbox: Optional[ContainerSandbox] = None, + local_storage_limit_bytes: Optional[int] = None, + scaling_option: Optional[ContainerScalingOption] = None, + liveness_probe: Optional[ContainerProbe] = None, + startup_probe: Optional[UpdateContainerRequestProbe] = None, + tags: Optional[list[str]] = None, + private_network_id: Optional[str] = None, + command: Optional[list[str]] = None, + args: Optional[list[str]] = None, + ) -> Container: + """ + Update the container associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param container_id: UUID of the container to update. + :param region: Region to target. If none is passed will use default region from the config. + :param environment_variables: Environment variables of the container. + :param secret_environment_variables: Secret environment variables of the container. + :param min_scale: Minimum number of instances to scale the container to. + :param max_scale: Maximum number of instances to scale the container to. + :param memory_limit_bytes: Memory limit of the container in bytes. + :param mvcpu_limit: CPU limit of the container in mvCPU. + :param timeout: Processing time limit for the container. + :param privacy: Privacy policy of the container. + :param description: Container description. + :param image: Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + :param protocol: Protocol the container uses. + :param port: Port the container listens on. + :param https_connection_only: If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + :param sandbox: Execution environment of the container. + :param local_storage_limit_bytes: Local storage limit of the container (in bytes). + :param scaling_option: Parameter used to decide when to scale up or down. + :param liveness_probe: If the liveness probe fails, the container will be restarted. + It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param startup_probe: If the startup probe fails, the container will be restarted. + This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + + Possible check types: + - http: Perform HTTP check on the container with the specified path. + - tcp: Perform TCP check on the container. + :param tags: Tags of the Serverless Container. + :param private_network_id: When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + :param command: Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + :param args: Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + :return: :class:`Container ` + + Usage: + :: + + result = api.update_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + body=marshal_UpdateContainerRequest( + UpdateContainerRequest( + container_id=container_id, + region=region, + environment_variables=environment_variables, + secret_environment_variables=secret_environment_variables, + min_scale=min_scale, + max_scale=max_scale, + memory_limit_bytes=memory_limit_bytes, + mvcpu_limit=mvcpu_limit, + timeout=timeout, + privacy=privacy, + description=description, + image=image, + protocol=protocol, + port=port, + https_connection_only=https_connection_only, + sandbox=sandbox, + local_storage_limit_bytes=local_storage_limit_bytes, + scaling_option=scaling_option, + liveness_probe=liveness_probe, + startup_probe=startup_probe, + tags=tags, + private_network_id=private_network_id, + command=command, + args=args, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + def delete_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Delete the container associated with the specified ID. + It also deletes in cascade any resource linked to the container (crons, tokens, etc.). + + This action **cannot** be undone. + :param container_id: UUID of the container to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = api.delete_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}", + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + def create_domain( + self, + *, + container_id: str, + hostname: str, + region: Optional[ScwRegion] = None, + tags: Optional[list[str]] = None, + ) -> Domain: + """ + Create a new custom domain for the container with the specified ID. + :param container_id: Unique ID of the container the domain will be assigned to. + :param hostname: Domain assigned to the container. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: A list of arbitrary tags associated with the domain. + :return: :class:`Domain ` + + Usage: + :: + + result = api.create_domain( + container_id="example", + hostname="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/domains", + body=marshal_CreateDomainRequest( + CreateDomainRequest( + container_id=container_id, + hostname=hostname, + region=region, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + def get_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + ) -> Domain: + """ + Get the custom domain associated with the specified ID. + :param domain_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = api.get_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + def wait_for_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Domain, bool]] = None, + ) -> Domain: + """ + Get the custom domain associated with the specified ID. + :param domain_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = api.get_domain( + domain_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in DOMAIN_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_domain, + options=options, + args={ + "domain_id": domain_id, + "region": region, + }, + ) + + def list_domains( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDomainsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> ListDomainsResponse: + """ + List all custom domains the caller can access (read permission). + By default, the custom domains listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter the output, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`ListDomainsResponse ` + + Usage: + :: + + result = api.list_domains() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/domains", + params={ + "container_id": container_id, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDomainsResponse(res.json()) + + def list_domains_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListDomainsRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> list[Domain]: + """ + List all custom domains the caller can access (read permission). + By default, the custom domains listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter the output, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`list[Domain] ` + + Usage: + :: + + result = api.list_domains_all() + """ + + return fetch_all_pages( + type=ListDomainsResponse, + key="domains", + fetcher=self.list_domains, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "container_id": container_id, + }, + ) + + def update_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + tags: Optional[list[str]] = None, + ) -> Domain: + """ + Update the domain associated with the specified ID. + Only fields present in the request are updated; others are left untouched. + :param domain_id: UUID of the domain to update. + :param region: Region to target. If none is passed will use default region from the config. + :param tags: A list of arbitrary tags associated with the domain. + :return: :class:`Domain ` + + Usage: + :: + + result = api.update_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + body=marshal_UpdateDomainRequest( + UpdateDomainRequest( + domain_id=domain_id, + region=region, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + def delete_domain( + self, + *, + domain_id: str, + region: Optional[ScwRegion] = None, + ) -> Domain: + """ + Delete the custom domain associated with the specified ID. + :param domain_id: UUID of the domain to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Domain ` + + Usage: + :: + + result = api.delete_domain( + domain_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_domain_id = validate_path_param("domain_id", domain_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/domains/{param_domain_id}", + ) + + self._throw_on_error(res) + return unmarshal_Domain(res.json()) + + def redeploy_container( + self, + *, + container_id: str, + region: Optional[ScwRegion] = None, + ) -> Container: + """ + Redeploy a container. + Performs a rollout of the container by creating new instances with the latest image version and terminating the old instances. + When using mutable registry image references (e.g. `my-registry-namespace/image:tag`), this endpoint can be used to force the container to use + the most recent image version available in the registry. + :param container_id: ID of the container to redeploy. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Container ` + + Usage: + :: + + result = api.redeploy_container( + container_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_container_id = validate_path_param("container_id", container_id) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/containers/{param_container_id}/redeploy", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Container(res.json()) + + def create_trigger( + self, + *, + container_id: str, + name: str, + region: Optional[ScwRegion] = None, + description: Optional[str] = None, + tags: Optional[list[str]] = None, + destination_config: Optional[CreateTriggerRequestDestinationConfig] = None, + cron_config: Optional[CreateTriggerRequestCronConfig] = None, + sqs_config: Optional[CreateTriggerRequestSQSConfig] = None, + nats_config: Optional[CreateTriggerRequestNATSConfig] = None, + ) -> Trigger: + """ + Create a new trigger for the container with the specified ID. + :param container_id: ID of the container to trigger. + :param name: Name of the trigger. + :param region: Region to target. If none is passed will use default region from the config. + :param description: Description of the trigger. + :param tags: Tags of the trigger. + :param destination_config: Configuration of the destination to trigger. + :param cron_config: Configuration for a cron source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param sqs_config: Configuration for an SQS queue source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param nats_config: Configuration for a NATS source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :return: :class:`Trigger ` + + Usage: + :: + + result = api.create_trigger( + container_id="example", + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/containers/v1/regions/{param_region}/triggers", + body=marshal_CreateTriggerRequest( + CreateTriggerRequest( + container_id=container_id, + name=name, + region=region, + description=description, + tags=tags, + destination_config=destination_config, + cron_config=cron_config, + sqs_config=sqs_config, + nats_config=nats_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + def get_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + ) -> Trigger: + """ + Get the trigger associated with the specified ID. + :param trigger_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = api.get_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + def wait_for_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Trigger, bool]] = None, + ) -> Trigger: + """ + Get the trigger associated with the specified ID. + :param trigger_id: + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = api.get_trigger( + trigger_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in TRIGGER_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_trigger, + options=options, + args={ + "trigger_id": trigger_id, + "region": region, + }, + ) + + def list_triggers( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListTriggersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> ListTriggersResponse: + """ + List all triggers the caller can access (read permission). + By default, the triggers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`ListTriggersResponse ` + + Usage: + :: + + result = api.list_triggers() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/containers/v1/regions/{param_region}/triggers", + params={ + "container_id": container_id, + "namespace_id": namespace_id, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListTriggersResponse(res.json()) + + def list_triggers_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListTriggersRequestOrderBy] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + namespace_id: Optional[str] = None, + container_id: Optional[str] = None, + ) -> list[Trigger]: + """ + List all triggers the caller can access (read permission). + By default, the triggers listed are ordered by creation date in ascending order. This can be modified via the `order_by` field. + + Additional parameters can be set in the query to filter, such as `organization_id`, `project_id`, `namespace_id`, or `container_id`. + :param region: Region to target. If none is passed will use default region from the config. + :param page: + :param page_size: + :param order_by: + :param organization_id: + :param project_id: + :param namespace_id: + :param container_id: + :return: :class:`list[Trigger] ` + + Usage: + :: + + result = api.list_triggers_all() + """ + + return fetch_all_pages( + type=ListTriggersResponse, + key="triggers", + fetcher=self.list_triggers, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "organization_id": organization_id, + "project_id": project_id, + "namespace_id": namespace_id, + "container_id": container_id, + }, + ) + + def update_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + description: Optional[str] = None, + tags: Optional[list[str]] = None, + destination_config: Optional[UpdateTriggerRequestDestinationConfig] = None, + cron_config: Optional[UpdateTriggerRequestCronConfig] = None, + sqs_config: Optional[UpdateTriggerRequestSQSConfig] = None, + nats_config: Optional[UpdateTriggerRequestNATSConfig] = None, + ) -> Trigger: + """ + Update the trigger associated with the specified ID. + When updating a trigger, you cannot specify a different source type than the one already set. + Only fields present in the request are updated; others are left untouched. + :param trigger_id: ID of the trigger to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the trigger. + :param description: Description of the trigger. + :param tags: Tags of the trigger. + :param destination_config: Configuration of the destination to trigger. + :param cron_config: Configuration for a cron source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param sqs_config: Configuration for an SQS queue source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :param nats_config: Configuration for a NATS source. + One-Of ('source_config'): at most one of 'cron_config', 'sqs_config', 'nats_config' could be set. + :return: :class:`Trigger ` + + Usage: + :: + + result = api.update_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "PATCH", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + body=marshal_UpdateTriggerRequest( + UpdateTriggerRequest( + trigger_id=trigger_id, + region=region, + name=name, + description=description, + tags=tags, + destination_config=destination_config, + cron_config=cron_config, + sqs_config=sqs_config, + nats_config=nats_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) + + def delete_trigger( + self, + *, + trigger_id: str, + region: Optional[ScwRegion] = None, + ) -> Trigger: + """ + Delete the trigger associated with the specified ID. + This action **cannot** be undone. + :param trigger_id: ID of the trigger to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Trigger ` + + Usage: + :: + + result = api.delete_trigger( + trigger_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_trigger_id = validate_path_param("trigger_id", trigger_id) + + res = self._request( + "DELETE", + f"/containers/v1/regions/{param_region}/triggers/{param_trigger_id}", + ) + + self._throw_on_error(res) + return unmarshal_Trigger(res.json()) diff --git a/scaleway/scaleway/container/v1/content.py b/scaleway/scaleway/container/v1/content.py new file mode 100644 index 000000000..f2c1dff3c --- /dev/null +++ b/scaleway/scaleway/container/v1/content.py @@ -0,0 +1,50 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from .types import ( + ContainerStatus, + DomainStatus, + NamespaceStatus, + TriggerStatus, +) + +CONTAINER_TRANSIENT_STATUSES: list[ContainerStatus] = [ + ContainerStatus.UPDATING, + ContainerStatus.DELETING, + ContainerStatus.LOCKING, + ContainerStatus.CREATING, + ContainerStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`ContainerStatus `. +""" +DOMAIN_TRANSIENT_STATUSES: list[DomainStatus] = [ + DomainStatus.CREATING, + DomainStatus.UPDATING, + DomainStatus.DELETING, + DomainStatus.LOCKING, + DomainStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`DomainStatus `. +""" +NAMESPACE_TRANSIENT_STATUSES: list[NamespaceStatus] = [ + NamespaceStatus.UPDATING, + NamespaceStatus.DELETING, + NamespaceStatus.LOCKING, + NamespaceStatus.CREATING, + NamespaceStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`NamespaceStatus `. +""" +TRIGGER_TRANSIENT_STATUSES: list[TriggerStatus] = [ + TriggerStatus.DELETING, + TriggerStatus.UPDATING, + TriggerStatus.CREATING, + TriggerStatus.LOCKING, + TriggerStatus.UPGRADING, +] +""" +Lists transient statutes of the enum :class:`TriggerStatus `. +""" diff --git a/scaleway/scaleway/container/v1/marshalling.py b/scaleway/scaleway/container/v1/marshalling.py new file mode 100644 index 000000000..cd73fbcca --- /dev/null +++ b/scaleway/scaleway/container/v1/marshalling.py @@ -0,0 +1,1456 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + ContainerPrivacy, + ContainerProtocol, + ContainerSandbox, + ContainerStatus, + DomainStatus, + NamespaceStatus, + TriggerDestinationConfigHttpMethod, + TriggerSourceType, + TriggerStatus, + ContainerProbeHTTPProbe, + ContainerProbeTCPProbe, + ContainerProbe, + ContainerScalingOption, + Container, + Domain, + Namespace, + TriggerCronConfig, + TriggerDestinationConfig, + TriggerNATSConfig, + TriggerSQSConfig, + Trigger, + ListContainersResponse, + ListDomainsResponse, + ListNamespacesResponse, + ListTriggersResponse, + CreateContainerRequest, + CreateDomainRequest, + CreateNamespaceRequest, + CreateTriggerRequestCronConfig, + CreateTriggerRequestDestinationConfig, + CreateTriggerRequestNATSConfig, + CreateTriggerRequestSQSConfig, + CreateTriggerRequest, + UpdateContainerRequestProbeHTTPProbe, + UpdateContainerRequestProbeTCPProbe, + UpdateContainerRequestProbe, + UpdateContainerRequest, + UpdateDomainRequest, + UpdateNamespaceRequest, + UpdateTriggerRequestCronConfig, + UpdateTriggerRequestDestinationConfig, + UpdateTriggerRequestNATSConfig, + UpdateTriggerRequestSQSConfig, + UpdateTriggerRequest, +) + + +def unmarshal_ContainerProbeHTTPProbe(data: Any) -> ContainerProbeHTTPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbeHTTPProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + else: + args["path"] = None + + return ContainerProbeHTTPProbe(**args) + + +def unmarshal_ContainerProbeTCPProbe(data: Any) -> ContainerProbeTCPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbeTCPProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + return ContainerProbeTCPProbe(**args) + + +def unmarshal_ContainerProbe(data: Any) -> ContainerProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerProbe' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("failure_threshold", None) + if field is not None: + args["failure_threshold"] = field + else: + args["failure_threshold"] = 0 + + field = data.get("interval", None) + if field is not None: + args["interval"] = field + else: + args["interval"] = None + + field = data.get("timeout", None) + if field is not None: + args["timeout"] = field + else: + args["timeout"] = None + + field = data.get("tcp", None) + if field is not None: + args["tcp"] = unmarshal_ContainerProbeTCPProbe(field) + else: + args["tcp"] = None + + field = data.get("http", None) + if field is not None: + args["http"] = unmarshal_ContainerProbeHTTPProbe(field) + else: + args["http"] = None + + return ContainerProbe(**args) + + +def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerScalingOption' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("concurrent_requests_threshold", None) + if field is not None: + args["concurrent_requests_threshold"] = field + else: + args["concurrent_requests_threshold"] = 0 + + field = data.get("cpu_usage_threshold", None) + if field is not None: + args["cpu_usage_threshold"] = field + else: + args["cpu_usage_threshold"] = 0 + + field = data.get("memory_usage_threshold", None) + if field is not None: + args["memory_usage_threshold"] = field + else: + args["memory_usage_threshold"] = 0 + + return ContainerScalingOption(**args) + + +def unmarshal_Container(data: Any) -> Container: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Container' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("namespace_id", None) + if field is not None: + args["namespace_id"] = field + else: + args["namespace_id"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = ContainerStatus.UNKNOWN_STATUS + + field = data.get("environment_variables", None) + if field is not None: + args["environment_variables"] = field + else: + args["environment_variables"] = {} + + field = data.get("secret_environment_variables", None) + if field is not None: + args["secret_environment_variables"] = field + else: + args["secret_environment_variables"] = {} + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("min_scale", None) + if field is not None: + args["min_scale"] = field + else: + args["min_scale"] = 0 + + field = data.get("max_scale", None) + if field is not None: + args["max_scale"] = field + else: + args["max_scale"] = 0 + + field = data.get("memory_limit_bytes", None) + if field is not None: + args["memory_limit_bytes"] = field + else: + args["memory_limit_bytes"] = 0 + + field = data.get("mvcpu_limit", None) + if field is not None: + args["mvcpu_limit"] = field + else: + args["mvcpu_limit"] = 0 + + field = data.get("local_storage_limit_bytes", None) + if field is not None: + args["local_storage_limit_bytes"] = field + else: + args["local_storage_limit_bytes"] = 0 + + field = data.get("privacy", None) + if field is not None: + args["privacy"] = field + else: + args["privacy"] = ContainerPrivacy.UNKNOWN_PRIVACY + + field = data.get("image", None) + if field is not None: + args["image"] = field + else: + args["image"] = None + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + else: + args["protocol"] = ContainerProtocol.UNKNOWN_PROTOCOL + + field = data.get("port", None) + if field is not None: + args["port"] = field + else: + args["port"] = 0 + + field = data.get("https_connections_only", None) + if field is not None: + args["https_connections_only"] = field + else: + args["https_connections_only"] = False + + field = data.get("timeout", None) + if field is not None: + args["timeout"] = field + else: + args["timeout"] = None + + field = data.get("sandbox", None) + if field is not None: + args["sandbox"] = field + else: + args["sandbox"] = ContainerSandbox.UNKNOWN_SANDBOX + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("command", None) + if field is not None: + args["command"] = field + else: + args["command"] = [] + + field = data.get("args", None) + if field is not None: + args["args"] = field + else: + args["args"] = [] + + field = data.get("public_endpoint", None) + if field is not None: + args["public_endpoint"] = field + else: + args["public_endpoint"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("scaling_option", None) + if field is not None: + args["scaling_option"] = unmarshal_ContainerScalingOption(field) + else: + args["scaling_option"] = None + + field = data.get("liveness_probe", None) + if field is not None: + args["liveness_probe"] = unmarshal_ContainerProbe(field) + else: + args["liveness_probe"] = None + + field = data.get("startup_probe", None) + if field is not None: + args["startup_probe"] = unmarshal_ContainerProbe(field) + else: + args["startup_probe"] = None + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + + return Container(**args) + + +def unmarshal_Domain(data: Any) -> Domain: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Domain' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("container_id", None) + if field is not None: + args["container_id"] = field + else: + args["container_id"] = None + + field = data.get("hostname", None) + if field is not None: + args["hostname"] = field + else: + args["hostname"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = DomainStatus.UNKNOWN_STATUS + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Domain(**args) + + +def unmarshal_Namespace(data: Any) -> Namespace: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Namespace' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = NamespaceStatus.UNKNOWN_STATUS + + field = data.get("environment_variables", None) + if field is not None: + args["environment_variables"] = field + else: + args["environment_variables"] = {} + + field = data.get("secret_environment_variables", None) + if field is not None: + args["secret_environment_variables"] = field + else: + args["secret_environment_variables"] = {} + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Namespace(**args) + + +def unmarshal_TriggerCronConfig(data: Any) -> TriggerCronConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerCronConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("schedule", None) + if field is not None: + args["schedule"] = field + else: + args["schedule"] = None + + field = data.get("timezone", None) + if field is not None: + args["timezone"] = field + else: + args["timezone"] = None + + field = data.get("body", None) + if field is not None: + args["body"] = field + else: + args["body"] = None + + field = data.get("headers", None) + if field is not None: + args["headers"] = field + else: + args["headers"] = {} + + return TriggerCronConfig(**args) + + +def unmarshal_TriggerDestinationConfig(data: Any) -> TriggerDestinationConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerDestinationConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("http_path", None) + if field is not None: + args["http_path"] = field + else: + args["http_path"] = None + + field = data.get("http_method", None) + if field is not None: + args["http_method"] = field + else: + args["http_method"] = TriggerDestinationConfigHttpMethod.UNKNOWN_HTTP_METHOD + + return TriggerDestinationConfig(**args) + + +def unmarshal_TriggerNATSConfig(data: Any) -> TriggerNATSConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerNATSConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("server_urls", None) + if field is not None: + args["server_urls"] = field + else: + args["server_urls"] = [] + + field = data.get("subject", None) + if field is not None: + args["subject"] = field + else: + args["subject"] = None + + return TriggerNATSConfig(**args) + + +def unmarshal_TriggerSQSConfig(data: Any) -> TriggerSQSConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'TriggerSQSConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("endpoint", None) + if field is not None: + args["endpoint"] = field + else: + args["endpoint"] = None + + field = data.get("access_key_id", None) + if field is not None: + args["access_key_id"] = field + else: + args["access_key_id"] = None + + field = data.get("queue_url", None) + if field is not None: + args["queue_url"] = field + else: + args["queue_url"] = None + + return TriggerSQSConfig(**args) + + +def unmarshal_Trigger(data: Any) -> Trigger: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Trigger' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("description", None) + if field is not None: + args["description"] = field + else: + args["description"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = TriggerStatus.UNKNOWN_STATUS + + field = data.get("error_message", None) + if field is not None: + args["error_message"] = field + else: + args["error_message"] = None + + field = data.get("container_id", None) + if field is not None: + args["container_id"] = field + else: + args["container_id"] = None + + field = data.get("source_type", None) + if field is not None: + args["source_type"] = field + else: + args["source_type"] = TriggerSourceType.UNKNOWN_SOURCE_TYPE + + field = data.get("destination_config", None) + if field is not None: + args["destination_config"] = unmarshal_TriggerDestinationConfig(field) + else: + args["destination_config"] = None + + field = data.get("cron_config", None) + if field is not None: + args["cron_config"] = unmarshal_TriggerCronConfig(field) + else: + args["cron_config"] = None + + field = data.get("sqs_config", None) + if field is not None: + args["sqs_config"] = unmarshal_TriggerSQSConfig(field) + else: + args["sqs_config"] = None + + field = data.get("nats_config", None) + if field is not None: + args["nats_config"] = unmarshal_TriggerNATSConfig(field) + else: + args["nats_config"] = None + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return Trigger(**args) + + +def unmarshal_ListContainersResponse(data: Any) -> ListContainersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListContainersResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("containers", None) + if field is not None: + args["containers"] = ( + [unmarshal_Container(v) for v in field] if field is not None else None + ) + else: + args["containers"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListContainersResponse(**args) + + +def unmarshal_ListDomainsResponse(data: Any) -> ListDomainsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDomainsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("domains", None) + if field is not None: + args["domains"] = ( + [unmarshal_Domain(v) for v in field] if field is not None else None + ) + else: + args["domains"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListDomainsResponse(**args) + + +def unmarshal_ListNamespacesResponse(data: Any) -> ListNamespacesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListNamespacesResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("namespaces", None) + if field is not None: + args["namespaces"] = ( + [unmarshal_Namespace(v) for v in field] if field is not None else None + ) + else: + args["namespaces"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListNamespacesResponse(**args) + + +def unmarshal_ListTriggersResponse(data: Any) -> ListTriggersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListTriggersResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("triggers", None) + if field is not None: + args["triggers"] = ( + [unmarshal_Trigger(v) for v in field] if field is not None else None + ) + else: + args["triggers"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListTriggersResponse(**args) + + +def marshal_ContainerProbeHTTPProbe( + request: ContainerProbeHTTPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_ContainerProbeTCPProbe( + request: ContainerProbeTCPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + return output + + +def marshal_ContainerProbe( + request: ContainerProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="tcp", + value=request.tcp, + marshal_func=marshal_ContainerProbeTCPProbe, + ), + OneOfPossibility( + param="http", + value=request.http, + marshal_func=marshal_ContainerProbeHTTPProbe, + ), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + if request.timeout is not None: + output["timeout"] = request.timeout + + return output + + +def marshal_ContainerScalingOption( + request: ContainerScalingOption, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="concurrent_requests_threshold", + value=request.concurrent_requests_threshold, + marshal_func=None, + ), + OneOfPossibility( + param="cpu_usage_threshold", + value=request.cpu_usage_threshold, + marshal_func=None, + ), + OneOfPossibility( + param="memory_usage_threshold", + value=request.memory_usage_threshold, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_CreateContainerRequest( + request: CreateContainerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.namespace_id is not None: + output["namespace_id"] = request.namespace_id + + if request.name is not None: + output["name"] = request.name + + if request.environment_variables is not None: + output["environment_variables"] = { + key: value for key, value in request.environment_variables.items() + } + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = { + key: value for key, value in request.secret_environment_variables.items() + } + + if request.min_scale is not None: + output["min_scale"] = request.min_scale + + if request.max_scale is not None: + output["max_scale"] = request.max_scale + + if request.memory_limit_bytes is not None: + output["memory_limit_bytes"] = request.memory_limit_bytes + + if request.mvcpu_limit is not None: + output["mvcpu_limit"] = request.mvcpu_limit + + if request.timeout is not None: + output["timeout"] = request.timeout + + if request.privacy is not None: + output["privacy"] = request.privacy + + if request.description is not None: + output["description"] = request.description + + if request.image is not None: + output["image"] = request.image + + if request.protocol is not None: + output["protocol"] = request.protocol + + if request.port is not None: + output["port"] = request.port + + if request.https_connections_only is not None: + output["https_connections_only"] = request.https_connections_only + + if request.sandbox is not None: + output["sandbox"] = request.sandbox + + if request.local_storage_limit_bytes is not None: + output["local_storage_limit_bytes"] = request.local_storage_limit_bytes + + if request.scaling_option is not None: + output["scaling_option"] = marshal_ContainerScalingOption( + request.scaling_option, defaults + ) + + if request.liveness_probe is not None: + output["liveness_probe"] = marshal_ContainerProbe( + request.liveness_probe, defaults + ) + + if request.startup_probe is not None: + output["startup_probe"] = marshal_ContainerProbe( + request.startup_probe, defaults + ) + + if request.tags is not None: + output["tags"] = request.tags + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.command is not None: + output["command"] = request.command + + if request.args is not None: + output["args"] = request.args + + return output + + +def marshal_CreateDomainRequest( + request: CreateDomainRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.container_id is not None: + output["container_id"] = request.container_id + + if request.hostname is not None: + output["hostname"] = request.hostname + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateNamespaceRequest( + request: CreateNamespaceRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.description is not None: + output["description"] = request.description + + if request.environment_variables is not None: + output["environment_variables"] = { + key: value for key, value in request.environment_variables.items() + } + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = { + key: value for key, value in request.secret_environment_variables.items() + } + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateTriggerRequestCronConfig( + request: CreateTriggerRequestCronConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.schedule is not None: + output["schedule"] = request.schedule + + if request.timezone is not None: + output["timezone"] = request.timezone + + if request.body is not None: + output["body"] = request.body + + if request.headers is not None: + output["headers"] = {key: value for key, value in request.headers.items()} + + return output + + +def marshal_CreateTriggerRequestDestinationConfig( + request: CreateTriggerRequestDestinationConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.http_path is not None: + output["http_path"] = request.http_path + + if request.http_method is not None: + output["http_method"] = request.http_method + + return output + + +def marshal_CreateTriggerRequestNATSConfig( + request: CreateTriggerRequestNATSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.server_urls is not None: + output["server_urls"] = request.server_urls + + if request.subject is not None: + output["subject"] = request.subject + + if request.credentials_file_content is not None: + output["credentials_file_content"] = request.credentials_file_content + + return output + + +def marshal_CreateTriggerRequestSQSConfig( + request: CreateTriggerRequestSQSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.region is not None: + output["region"] = request.region + else: + output["region"] = defaults.default_region + + if request.endpoint is not None: + output["endpoint"] = request.endpoint + + if request.access_key_id is not None: + output["access_key_id"] = request.access_key_id + + if request.secret_access_key is not None: + output["secret_access_key"] = request.secret_access_key + + if request.queue_url is not None: + output["queue_url"] = request.queue_url + + return output + + +def marshal_CreateTriggerRequest( + request: CreateTriggerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="cron_config", + value=request.cron_config, + marshal_func=marshal_CreateTriggerRequestCronConfig, + ), + OneOfPossibility( + param="sqs_config", + value=request.sqs_config, + marshal_func=marshal_CreateTriggerRequestSQSConfig, + ), + OneOfPossibility( + param="nats_config", + value=request.nats_config, + marshal_func=marshal_CreateTriggerRequestNATSConfig, + ), + ] + ), + ) + + if request.container_id is not None: + output["container_id"] = request.container_id + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.tags is not None: + output["tags"] = request.tags + + if request.destination_config is not None: + output["destination_config"] = marshal_CreateTriggerRequestDestinationConfig( + request.destination_config, defaults + ) + + return output + + +def marshal_UpdateContainerRequestProbeHTTPProbe( + request: UpdateContainerRequestProbeHTTPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_UpdateContainerRequestProbeTCPProbe( + request: UpdateContainerRequestProbeTCPProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + return output + + +def marshal_UpdateContainerRequestProbe( + request: UpdateContainerRequestProbe, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="http", + value=request.http, + marshal_func=marshal_UpdateContainerRequestProbeHTTPProbe, + ), + OneOfPossibility( + param="tcp", + value=request.tcp, + marshal_func=marshal_UpdateContainerRequestProbeTCPProbe, + ), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + if request.timeout is not None: + output["timeout"] = request.timeout + + return output + + +def marshal_UpdateContainerRequest( + request: UpdateContainerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.environment_variables is not None: + output["environment_variables"] = request.environment_variables + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = request.secret_environment_variables + + if request.min_scale is not None: + output["min_scale"] = request.min_scale + + if request.max_scale is not None: + output["max_scale"] = request.max_scale + + if request.memory_limit_bytes is not None: + output["memory_limit_bytes"] = request.memory_limit_bytes + + if request.mvcpu_limit is not None: + output["mvcpu_limit"] = request.mvcpu_limit + + if request.timeout is not None: + output["timeout"] = request.timeout + + if request.privacy is not None: + output["privacy"] = request.privacy + + if request.description is not None: + output["description"] = request.description + + if request.image is not None: + output["image"] = request.image + + if request.protocol is not None: + output["protocol"] = request.protocol + + if request.port is not None: + output["port"] = request.port + + if request.https_connection_only is not None: + output["https_connection_only"] = request.https_connection_only + + if request.sandbox is not None: + output["sandbox"] = request.sandbox + + if request.local_storage_limit_bytes is not None: + output["local_storage_limit_bytes"] = request.local_storage_limit_bytes + + if request.scaling_option is not None: + output["scaling_option"] = marshal_ContainerScalingOption( + request.scaling_option, defaults + ) + + if request.liveness_probe is not None: + output["liveness_probe"] = marshal_ContainerProbe( + request.liveness_probe, defaults + ) + + if request.startup_probe is not None: + output["startup_probe"] = marshal_UpdateContainerRequestProbe( + request.startup_probe, defaults + ) + + if request.tags is not None: + output["tags"] = request.tags + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.command is not None: + output["command"] = request.command + + if request.args is not None: + output["args"] = request.args + + return output + + +def marshal_UpdateDomainRequest( + request: UpdateDomainRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateNamespaceRequest( + request: UpdateNamespaceRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.description is not None: + output["description"] = request.description + + if request.environment_variables is not None: + output["environment_variables"] = request.environment_variables + + if request.secret_environment_variables is not None: + output["secret_environment_variables"] = request.secret_environment_variables + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateTriggerRequestCronConfig( + request: UpdateTriggerRequestCronConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.schedule is not None: + output["schedule"] = request.schedule + + if request.timezone is not None: + output["timezone"] = request.timezone + + if request.body is not None: + output["body"] = request.body + + if request.headers is not None: + output["headers"] = request.headers + + return output + + +def marshal_UpdateTriggerRequestDestinationConfig( + request: UpdateTriggerRequestDestinationConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.http_path is not None: + output["http_path"] = request.http_path + + if request.http_method is not None: + output["http_method"] = request.http_method + + return output + + +def marshal_UpdateTriggerRequestNATSConfig( + request: UpdateTriggerRequestNATSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.server_urls is not None: + output["server_urls"] = request.server_urls + + if request.subject is not None: + output["subject"] = request.subject + + if request.credentials_file_content is not None: + output["credentials_file_content"] = request.credentials_file_content + + return output + + +def marshal_UpdateTriggerRequestSQSConfig( + request: UpdateTriggerRequestSQSConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.region is not None: + output["region"] = request.region + + if request.endpoint is not None: + output["endpoint"] = request.endpoint + + if request.access_key_id is not None: + output["access_key_id"] = request.access_key_id + + if request.secret_access_key is not None: + output["secret_access_key"] = request.secret_access_key + + if request.queue_url is not None: + output["queue_url"] = request.queue_url + + return output + + +def marshal_UpdateTriggerRequest( + request: UpdateTriggerRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="cron_config", + value=request.cron_config, + marshal_func=marshal_UpdateTriggerRequestCronConfig, + ), + OneOfPossibility( + param="sqs_config", + value=request.sqs_config, + marshal_func=marshal_UpdateTriggerRequestSQSConfig, + ), + OneOfPossibility( + param="nats_config", + value=request.nats_config, + marshal_func=marshal_UpdateTriggerRequestNATSConfig, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.description is not None: + output["description"] = request.description + + if request.tags is not None: + output["tags"] = request.tags + + if request.destination_config is not None: + output["destination_config"] = marshal_UpdateTriggerRequestDestinationConfig( + request.destination_config, defaults + ) + + return output diff --git a/scaleway/scaleway/container/v1/types.py b/scaleway/scaleway/container/v1/types.py new file mode 100644 index 000000000..f931ca056 --- /dev/null +++ b/scaleway/scaleway/container/v1/types.py @@ -0,0 +1,1490 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass, field +from datetime import datetime +from enum import Enum +from typing import Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class ContainerPrivacy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PRIVACY = "unknown_privacy" + PUBLIC = "public" + PRIVATE = "private" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerProtocol(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PROTOCOL = "unknown_protocol" + HTTP1 = "http1" + H2C = "h2c" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerSandbox(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SANDBOX = "unknown_sandbox" + V1 = "v1" + V2 = "v2" + + def __str__(self) -> str: + return str(self.value) + + +class ContainerStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UPDATING = "updating" + DELETING = "deleting" + LOCKING = "locking" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + CREATING = "creating" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class CreateTriggerRequestDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +class DomainStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATING = "creating" + UPDATING = "updating" + DELETING = "deleting" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + LOCKING = "locking" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class ListContainersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListDomainsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + HOSTNAME_ASC = "hostname_asc" + HOSTNAME_DESC = "hostname_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListNamespacesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListTriggersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class NamespaceStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UPDATING = "updating" + DELETING = "deleting" + LOCKING = "locking" + READY = "ready" + ERROR = "error" + LOCKED = "locked" + CREATING = "creating" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerSourceType(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_SOURCE_TYPE = "unknown_source_type" + CRON = "cron" + SQS = "sqs" + NATS = "nats" + + def __str__(self) -> str: + return str(self.value) + + +class TriggerStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + READY = "ready" + DELETING = "deleting" + ERROR = "error" + UPDATING = "updating" + CREATING = "creating" + LOCKING = "locking" + LOCKED = "locked" + UPGRADING = "upgrading" + + def __str__(self) -> str: + return str(self.value) + + +class UpdateTriggerRequestDestinationConfigHttpMethod(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_HTTP_METHOD = "unknown_http_method" + GET = "get" + POST = "post" + PUT = "put" + PATCH = "patch" + DELETE = "delete" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class ContainerProbeHTTPProbe: + path: str + """ + HTTP path to perform the check on. + """ + + +@dataclass +class ContainerProbeTCPProbe: + pass + + +@dataclass +class ContainerProbe: + failure_threshold: int + """ + Unhealthy containers do not receive traffic from incoming requests. + """ + + interval: Optional[str] = None + """ + Time interval between checks. + """ + + timeout: Optional[str] = None + """ + Duration before the check times out. + """ + + tcp: Optional[ContainerProbeTCPProbe] = None + + http: Optional[ContainerProbeHTTPProbe] = None + + +@dataclass +class ContainerScalingOption: + concurrent_requests_threshold: Optional[int] = 0 + + cpu_usage_threshold: Optional[int] = 0 + + memory_usage_threshold: Optional[int] = 0 + + +@dataclass +class TriggerCronConfig: + schedule: str + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: str + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: str + """ + Body to send to the container when the trigger is invoked. + """ + + headers: dict[str, str] + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class TriggerDestinationConfig: + http_path: str + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: TriggerDestinationConfigHttpMethod + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class TriggerNATSConfig: + server_urls: list[str] + """ + The URLs of the NATS servers (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: str + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + +@dataclass +class TriggerSQSConfig: + region: ScwRegion + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: str + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: str + """ + The access key for accessing the SQS queue. + """ + + queue_url: str + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class UpdateContainerRequestProbeHTTPProbe: + path: Optional[str] = None + + +@dataclass +class UpdateContainerRequestProbeTCPProbe: + pass + + +@dataclass +class CreateTriggerRequestCronConfig: + schedule: str + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: str + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: str + """ + Body to send to the container when the trigger is invoked. + """ + + headers: dict[str, str] + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class CreateTriggerRequestDestinationConfig: + http_path: str + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: CreateTriggerRequestDestinationConfigHttpMethod + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class CreateTriggerRequestNATSConfig: + server_urls: list[str] + """ + The URLs of the NATS server (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: str + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + credentials_file_content: str + """ + The credentials from this file will be used to authenticate with the NATS server and subscribe to the specified subject. + """ + + +@dataclass +class CreateTriggerRequestSQSConfig: + region: ScwRegion + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: str + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: str + """ + The access key for accessing the SQS queue. + """ + + secret_access_key: str + """ + The secret key for accessing the SQS queue. + """ + + queue_url: str + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class Container: + id: str + """ + Container unique ID. + """ + + name: str + """ + Container name. + """ + + namespace_id: str + """ + Unique ID of the namespace the container belongs to. + """ + + description: str + """ + Container description. + """ + + status: ContainerStatus + """ + Container status. + """ + + environment_variables: dict[str, str] + """ + Environment variables of the container. + """ + + secret_environment_variables: dict[str, str] + """ + Secret environment variables of the container. + """ + + min_scale: int + """ + Minimum number of instances to scale the container to. + """ + + max_scale: int + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: int + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: int + """ + CPU limit of the container in mvCPU. + """ + + local_storage_limit_bytes: int + """ + Local storage limit of the container (in bytes). + """ + + privacy: ContainerPrivacy + """ + Privacy policy of the container. + """ + + image: str + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + protocol: ContainerProtocol + """ + Protocol the container uses. + """ + + port: int + """ + Port the container listens on. + """ + + https_connections_only: bool + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: ContainerSandbox + """ + Execution environment of the container. + """ + + tags: list[str] + """ + Tags of the Serverless Container. + """ + + command: list[str] + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: list[str] + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + public_endpoint: str + """ + This is the default endpoint generated by Scaleway to access the container from the Internet. + """ + + region: ScwRegion + """ + Region in which the container exists. + """ + + error_message: Optional[str] = None + """ + Container last error message. + """ + + created_at: Optional[datetime] = None + """ + Container creation date. + """ + + updated_at: Optional[datetime] = None + """ + Container last update date. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[ContainerProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + +@dataclass +class Domain: + id: str + """ + Domain unique ID. + """ + + container_id: str + """ + Unique ID of the container the domain is assigned to. + """ + + hostname: str + """ + Domain assigned to the container. + """ + + status: DomainStatus + """ + Domain status. + """ + + tags: list[str] + """ + A list of arbitrary tags associated with the domain. + """ + + error_message: Optional[str] = None + """ + Domain last error message. + """ + + created_at: Optional[datetime] = None + """ + Domain creation date. + """ + + updated_at: Optional[datetime] = None + """ + Domain last update date. + """ + + +@dataclass +class Namespace: + id: str + """ + Namespace unique ID. + """ + + name: str + """ + Namespace name. + """ + + organization_id: str + """ + Unique ID of the Organization the namespace belongs to. + """ + + project_id: str + """ + Unique ID of the Project the namespace belongs to. + """ + + description: str + """ + Namespace description. + """ + + status: NamespaceStatus + """ + Namespace status. + """ + + environment_variables: dict[str, str] + """ + Namespace environment variables. + """ + + secret_environment_variables: dict[str, str] + """ + Namespace secret environment variables. + """ + + tags: list[str] + """ + A list of arbitrary tags associated with the namespace. + """ + + region: ScwRegion + """ + Region in which the namespace will be created. + """ + + error_message: Optional[str] = None + """ + Namespace last error message. + """ + + created_at: Optional[datetime] = None + """ + Namespace creation date. + """ + + updated_at: Optional[datetime] = None + """ + Namespace last update date. + """ + + +@dataclass +class Trigger: + id: str + """ + Trigger unique ID. + """ + + name: str + """ + Name of the trigger. + """ + + description: str + """ + Description of the trigger. + """ + + tags: list[str] + """ + Tags of the trigger. + """ + + status: TriggerStatus + """ + Trigger status. + """ + + container_id: str + """ + ID of the container to trigger. + """ + + source_type: TriggerSourceType + """ + Type of source that will trigger the container. + """ + + error_message: Optional[str] = None + """ + Trigger last error message. + """ + + destination_config: Optional[TriggerDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + created_at: Optional[datetime] = None + """ + Trigger creation date. + """ + + updated_at: Optional[datetime] = None + """ + Trigger last update date. + """ + + cron_config: Optional[TriggerCronConfig] = None + + sqs_config: Optional[TriggerSQSConfig] = None + + nats_config: Optional[TriggerNATSConfig] = None + + +@dataclass +class UpdateContainerRequestProbe: + failure_threshold: Optional[int] = None + interval: Optional[str] = None + timeout: Optional[str] = None + http: Optional[UpdateContainerRequestProbeHTTPProbe] = None + + tcp: Optional[UpdateContainerRequestProbeTCPProbe] = None + + +@dataclass +class UpdateTriggerRequestCronConfig: + schedule: Optional[str] = None + """ + UNIX cron schedule to run job (e.g., "* * * * *"). + """ + + timezone: Optional[str] = None + """ + Timezone for the cron schedule, in tz database format (e.g., "Europe/Paris"). + """ + + body: Optional[str] = None + """ + Body to send to the container when the trigger is invoked. + """ + + headers: Optional[dict[str, str]] = field(default_factory=dict) + """ + Additional headers to send to the container when the trigger is invoked. + """ + + +@dataclass +class UpdateTriggerRequestDestinationConfig: + http_path: Optional[str] = None + """ + The HTTP path to send the request to (e.g., "/my-webhook-endpoint"). + """ + + http_method: Optional[UpdateTriggerRequestDestinationConfigHttpMethod] = ( + UpdateTriggerRequestDestinationConfigHttpMethod.UNKNOWN_HTTP_METHOD + ) + """ + The HTTP method to use when sending the request (e.g., get, post, put, patch, delete). Must be specified as lowercase. + """ + + +@dataclass +class UpdateTriggerRequestNATSConfig: + server_urls: Optional[list[str]] = field(default_factory=list) + """ + The URLs of the NATS server (e.g., "nats://nats.mnq.fr-par.scaleway.com:4222"). + """ + + subject: Optional[str] = None + """ + NATS subject to subscribe to (e.g., "my-subject"). + """ + + credentials_file_content: Optional[str] = None + """ + The credentials from this file will be used to authenticate with the NATS server and subscribe to the specified subject. + """ + + +@dataclass +class UpdateTriggerRequestSQSConfig: + region: Optional[ScwRegion] = None + """ + The region where the SQS queue is hosted (e.g., "fr-par", "nl-ams"). + """ + + endpoint: Optional[str] = None + """ + Endpoint URL to use to access SQS (e.g., "https://sqs.mnq.fr-par.scaleway.com"). + """ + + access_key_id: Optional[str] = None + """ + The access key for accessing the SQS queue. + """ + + secret_access_key: Optional[str] = None + """ + The secret key for accessing the SQS queue. + """ + + queue_url: Optional[str] = None + """ + The URL of the SQS queue to monitor for messages. + """ + + +@dataclass +class CreateContainerRequest: + namespace_id: str + """ + Unique ID of the namespace the container belongs to. + """ + + name: str + """ + Container name. + """ + + image: str + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Environment variables of the container. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Secret environment variables of the container. + """ + + min_scale: Optional[int] = 0 + """ + Minimum number of instances to scale the container to. + """ + + max_scale: Optional[int] = 0 + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: Optional[int] = 0 + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: Optional[int] = 0 + """ + CPU limit of the container in mvCPU. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + privacy: Optional[ContainerPrivacy] = ContainerPrivacy.UNKNOWN_PRIVACY + """ + Privacy policy of the container. + """ + + description: Optional[str] = None + """ + Container description. + """ + + protocol: Optional[ContainerProtocol] = ContainerProtocol.UNKNOWN_PROTOCOL + """ + Protocol the container uses. + """ + + port: Optional[int] = 0 + """ + Port the container listens on. + """ + + https_connections_only: Optional[bool] = False + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: Optional[ContainerSandbox] = ContainerSandbox.UNKNOWN_SANDBOX + """ + Execution environment of the container. + """ + + local_storage_limit_bytes: Optional[int] = 0 + """ + Local storage limit of the container (in bytes). + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[ContainerProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the Serverless Container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + command: Optional[list[str]] = field(default_factory=list) + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: Optional[list[str]] = field(default_factory=list) + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + +@dataclass +class CreateDomainRequest: + container_id: str + """ + Unique ID of the container the domain will be assigned to. + """ + + hostname: str + """ + Domain assigned to the container. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the domain. + """ + + +@dataclass +class CreateNamespaceRequest: + name: str + """ + Namespace name. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + Unique ID of the Project the namespace belongs to. + """ + + description: Optional[str] = None + """ + Namespace description. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace environment variables. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace secret environment variables. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the namespace. + """ + + +@dataclass +class CreateTriggerRequest: + container_id: str + """ + ID of the container to trigger. + """ + + name: str + """ + Name of the trigger. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + description: Optional[str] = None + """ + Description of the trigger. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the trigger. + """ + + destination_config: Optional[CreateTriggerRequestDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + cron_config: Optional[CreateTriggerRequestCronConfig] = None + + sqs_config: Optional[CreateTriggerRequestSQSConfig] = None + + nats_config: Optional[CreateTriggerRequestNATSConfig] = None + + +@dataclass +class DeleteContainerRequest: + container_id: str + """ + UUID of the container to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteDomainRequest: + domain_id: str + """ + UUID of the domain to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteNamespaceRequest: + namespace_id: str + """ + UUID of the namespace to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteTriggerRequest: + trigger_id: str + """ + ID of the trigger to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetContainerRequest: + container_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetDomainRequest: + domain_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetNamespaceRequest: + namespace_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetServiceInfoRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetTriggerRequest: + trigger_id: str + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListContainersRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListContainersRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + name: Optional[str] = None + + +@dataclass +class ListContainersResponse: + containers: list[Container] + total_count: int + + +@dataclass +class ListDomainsRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListDomainsRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + container_id: Optional[str] = None + + +@dataclass +class ListDomainsResponse: + domains: list[Domain] + total_count: int + + +@dataclass +class ListNamespacesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListNamespacesRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + name: Optional[str] = None + + +@dataclass +class ListNamespacesResponse: + namespaces: list[Namespace] + total_count: int + + +@dataclass +class ListTriggersRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = None + page_size: Optional[int] = None + order_by: Optional[ListTriggersRequestOrderBy] = None + organization_id: Optional[str] = None + project_id: Optional[str] = None + namespace_id: Optional[str] = None + container_id: Optional[str] = None + + +@dataclass +class ListTriggersResponse: + triggers: list[Trigger] + total_count: int + + +@dataclass +class RedeployContainerRequest: + container_id: str + """ + ID of the container to redeploy. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class UpdateContainerRequest: + container_id: str + """ + UUID of the container to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Environment variables of the container. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Secret environment variables of the container. + """ + + min_scale: Optional[int] = 0 + """ + Minimum number of instances to scale the container to. + """ + + max_scale: Optional[int] = 0 + """ + Maximum number of instances to scale the container to. + """ + + memory_limit_bytes: Optional[int] = 0 + """ + Memory limit of the container in bytes. + """ + + mvcpu_limit: Optional[int] = 0 + """ + CPU limit of the container in mvCPU. + """ + + timeout: Optional[str] = None + """ + Processing time limit for the container. + """ + + privacy: Optional[ContainerPrivacy] = ContainerPrivacy.UNKNOWN_PRIVACY + """ + Privacy policy of the container. + """ + + description: Optional[str] = None + """ + Container description. + """ + + image: Optional[str] = None + """ + Image reference (e.g. "rg.fr-par.scw.cloud/my-registry-namespace/image:tag"). + """ + + protocol: Optional[ContainerProtocol] = ContainerProtocol.UNKNOWN_PROTOCOL + """ + Protocol the container uses. + """ + + port: Optional[int] = 0 + """ + Port the container listens on. + """ + + https_connection_only: Optional[bool] = False + """ + If true, it will allow only HTTPS connections to access your container to prevent it from being triggered by insecure connections (HTTP). + """ + + sandbox: Optional[ContainerSandbox] = ContainerSandbox.UNKNOWN_SANDBOX + """ + Execution environment of the container. + """ + + local_storage_limit_bytes: Optional[int] = 0 + """ + Local storage limit of the container (in bytes). + """ + + scaling_option: Optional[ContainerScalingOption] = None + """ + Parameter used to decide when to scale up or down. + """ + + liveness_probe: Optional[ContainerProbe] = None + """ + If the liveness probe fails, the container will be restarted. +It is performed periodically during the container's lifetime. The liveness probe is not executed until the startup probe (if defined) is successful. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + startup_probe: Optional[UpdateContainerRequestProbe] = None + """ + If the startup probe fails, the container will be restarted. +This check is useful for applications that might take a long time to start. It is only performed when the container is starting. + +Possible check types: +- http: Perform HTTP check on the container with the specified path. +- tcp: Perform TCP check on the container. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the Serverless Container. + """ + + private_network_id: Optional[str] = None + """ + When connected to a Private Network, the container can access other Scaleway resources in this Private Network. + """ + + command: Optional[list[str]] = field(default_factory=list) + """ + Command executed when the container starts. This overrides the default command defined in the container image. This is usually the main executable, or ENTRYPOINT script to run. + """ + + args: Optional[list[str]] = field(default_factory=list) + """ + Arguments passed to the command specified in the "command" field. These override the default arguments from the container image, and behave like command-line parameters. + """ + + +@dataclass +class UpdateDomainRequest: + domain_id: str + """ + UUID of the domain to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the domain. + """ + + +@dataclass +class UpdateNamespaceRequest: + namespace_id: str + """ + UUID of the namespace to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + description: Optional[str] = None + """ + Namespace description. + """ + + environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace environment variables. + """ + + secret_environment_variables: Optional[dict[str, str]] = field(default_factory=dict) + """ + Namespace secret environment variables. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + A list of arbitrary tags associated with the namespace. + """ + + +@dataclass +class UpdateTriggerRequest: + trigger_id: str + """ + ID of the trigger to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the trigger. + """ + + description: Optional[str] = None + """ + Description of the trigger. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags of the trigger. + """ + + destination_config: Optional[UpdateTriggerRequestDestinationConfig] = None + """ + Configuration of the destination to trigger. + """ + + cron_config: Optional[UpdateTriggerRequestCronConfig] = None + + sqs_config: Optional[UpdateTriggerRequestSQSConfig] = None + + nats_config: Optional[UpdateTriggerRequestNATSConfig] = None diff --git a/scaleway/scaleway/container/v1beta1/api.py b/scaleway/scaleway/container/v1beta1/api.py index 2107b60d3..aaa321d43 100644 --- a/scaleway/scaleway/container/v1beta1/api.py +++ b/scaleway/scaleway/container/v1beta1/api.py @@ -612,6 +612,9 @@ def create_container( """ Create a new container. Create a new container in the specified region. + + When creating a container, the `created` status is no longer used. The deployment process is started + and the status is set to `pending` accordingly. :param namespace_id: UUID of the namespace the container belongs to. :param name: Name of the container. :param region: Region to target. If none is passed will use default region from the config. @@ -729,7 +732,8 @@ def update_container( Update the container associated with the specified ID. When updating a container, the container is automatically redeployed to apply the changes. - This behavior can be changed by setting the `redeploy` field to `false` in the request. + + Warning: The `redeploy` field has been deprecated. An update now always redeploys the container. :param container_id: UUID of the container to update. :param region: Region to target. If none is passed will use default region from the config. :param environment_variables: Environment variables of the container. @@ -870,6 +874,10 @@ def deploy_container( """ Deploy a container. Deploy a container associated with the specified ID. + + Since updating a container now always deploys it (and passes its status to `pending`), this call becomes superfluous. + + Moreover, calling `DeployContainer` immediately after `UpdateContainer` can cause `409 - resource is in a transient state` errors, so it is better to not use it when updating a container. :param container_id: UUID of the container to deploy. :param region: Region to target. If none is passed will use default region from the config. :return: :class:`Container ` diff --git a/scaleway/scaleway/container/v1beta1/types.py b/scaleway/scaleway/container/v1beta1/types.py index 6f645841b..0c20744c7 100644 --- a/scaleway/scaleway/container/v1beta1/types.py +++ b/scaleway/scaleway/container/v1beta1/types.py @@ -428,7 +428,7 @@ class Container: domain_name: str """ - Domain name attributed to the contaioner. + Domain name attributed to the container. """ protocol: ContainerProtocol @@ -657,7 +657,7 @@ class Namespace: error_message: Optional[str] = None """ - Last error message of the namesace. + Last error message of the namespace. """ description: Optional[str] = None