diff --git a/scaleway-async/scaleway_async/container/v1beta1/__init__.py b/scaleway-async/scaleway_async/container/v1beta1/__init__.py index edca19aa0..a1de41c3c 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/__init__.py +++ b/scaleway-async/scaleway_async/container/v1beta1/__init__.py @@ -23,6 +23,9 @@ from .types import TriggerInputType from .types import TriggerStatus from .content import TRIGGER_TRANSIENT_STATUSES +from .types import ContainerHealthCheckSpecHTTPProbe +from .types import ContainerHealthCheckSpecTCPProbe +from .types import ContainerHealthCheckSpec from .types import ContainerScalingOption from .types import SecretHashedValue from .types import TriggerMnqNatsClientConfig @@ -100,6 +103,9 @@ "TriggerInputType", "TriggerStatus", "TRIGGER_TRANSIENT_STATUSES", + "ContainerHealthCheckSpecHTTPProbe", + "ContainerHealthCheckSpecTCPProbe", + "ContainerHealthCheckSpec", "ContainerScalingOption", "SecretHashedValue", "TriggerMnqNatsClientConfig", diff --git a/scaleway-async/scaleway_async/container/v1beta1/api.py b/scaleway-async/scaleway_async/container/v1beta1/api.py index 8b2d1663c..2dd4d5a43 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/api.py +++ b/scaleway-async/scaleway_async/container/v1beta1/api.py @@ -29,6 +29,7 @@ ListTokensRequestOrderBy, ListTriggersRequestOrderBy, Container, + ContainerHealthCheckSpec, ContainerScalingOption, CreateContainerRequest, CreateCronRequest, @@ -603,6 +604,7 @@ async def create_container( sandbox: Optional[ContainerSandbox] = None, local_storage_limit: Optional[int] = None, scaling_option: Optional[ContainerScalingOption] = None, + health_check: Optional[ContainerHealthCheckSpec] = None, ) -> Container: """ Create a new container. @@ -631,6 +633,7 @@ async def create_container( :param scaling_option: Possible values: - concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance. - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. + :param health_check: Health check configuration of the container. :return: :class:`Container ` Usage: @@ -671,6 +674,7 @@ async def create_container( sandbox=sandbox, local_storage_limit=local_storage_limit, scaling_option=scaling_option, + health_check=health_check, ), self.client, ), @@ -702,6 +706,7 @@ async def update_container( sandbox: Optional[ContainerSandbox] = None, local_storage_limit: Optional[int] = None, scaling_option: Optional[ContainerScalingOption] = None, + health_check: Optional[ContainerHealthCheckSpec] = None, ) -> Container: """ Update an existing container. @@ -730,6 +735,7 @@ async def update_container( :param scaling_option: Possible values: - concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance. - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. + :param health_check: Health check configuration of the container. :return: :class:`Container ` Usage: @@ -770,6 +776,7 @@ async def update_container( sandbox=sandbox, local_storage_limit=local_storage_limit, scaling_option=scaling_option, + health_check=health_check, ), self.client, ), diff --git a/scaleway-async/scaleway_async/container/v1beta1/marshalling.py b/scaleway-async/scaleway_async/container/v1beta1/marshalling.py index 7606d9b08..97d792352 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/marshalling.py +++ b/scaleway-async/scaleway_async/container/v1beta1/marshalling.py @@ -10,6 +10,9 @@ resolve_one_of, ) from .types import ( + ContainerHealthCheckSpecHTTPProbe, + ContainerHealthCheckSpecTCPProbe, + ContainerHealthCheckSpec, ContainerScalingOption, SecretHashedValue, Container, @@ -45,6 +48,69 @@ ) +def unmarshal_ContainerHealthCheckSpecHTTPProbe( + data: Any, +) -> ContainerHealthCheckSpecHTTPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpecHTTPProbe' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return ContainerHealthCheckSpecHTTPProbe(**args) + + +def unmarshal_ContainerHealthCheckSpecTCPProbe( + data: Any, +) -> ContainerHealthCheckSpecTCPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpecTCPProbe' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return ContainerHealthCheckSpecTCPProbe(**args) + + +def unmarshal_ContainerHealthCheckSpec(data: Any) -> ContainerHealthCheckSpec: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpec' 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 + + field = data.get("http", None) + if field is not None: + args["http"] = unmarshal_ContainerHealthCheckSpecHTTPProbe(field) + else: + args["http"] = None + + field = data.get("tcp", None) + if field is not None: + args["tcp"] = unmarshal_ContainerHealthCheckSpecTCPProbe(field) + else: + args["tcp"] = None + + field = data.get("interval", None) + if field is not None: + args["interval"] = field + else: + args["interval"] = None + + return ContainerHealthCheckSpec(**args) + + def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption: if not isinstance(data, dict): raise TypeError( @@ -139,22 +205,6 @@ def unmarshal_Container(data: Any) -> Container: if field is not None: args["registry_image"] = field - field = data.get("max_concurrency", None) - if field is not None: - args["max_concurrency"] = field - - field = data.get("domain_name", None) - if field is not None: - args["domain_name"] = field - - field = data.get("protocol", None) - if field is not None: - args["protocol"] = field - - field = data.get("port", None) - if field is not None: - args["port"] = field - field = data.get("timeout", None) if field is not None: args["timeout"] = field @@ -173,6 +223,22 @@ def unmarshal_Container(data: Any) -> Container: else: args["description"] = None + field = data.get("max_concurrency", None) + if field is not None: + args["max_concurrency"] = field + + field = data.get("domain_name", None) + if field is not None: + args["domain_name"] = field + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + + field = data.get("port", None) + if field is not None: + args["port"] = field + field = data.get("secret_environment_variables", None) if field is not None: args["secret_environment_variables"] = ( @@ -203,6 +269,12 @@ def unmarshal_Container(data: Any) -> Container: else: args["scaling_option"] = None + field = data.get("health_check", None) + if field is not None: + args["health_check"] = unmarshal_ContainerHealthCheckSpec(field) + else: + args["health_check"] = None + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -696,6 +768,50 @@ def unmarshal_ListTriggersResponse(data: Any) -> ListTriggersResponse: return ListTriggersResponse(**args) +def marshal_ContainerHealthCheckSpecHTTPProbe( + request: ContainerHealthCheckSpecHTTPProbe, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_ContainerHealthCheckSpecTCPProbe( + request: ContainerHealthCheckSpecTCPProbe, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_ContainerHealthCheckSpec( + request: ContainerHealthCheckSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("http", request.http), + OneOfPossibility("tcp", request.tcp), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + return output + + def marshal_ContainerScalingOption( request: ContainerScalingOption, defaults: ProfileDefaults, @@ -799,6 +915,11 @@ def marshal_CreateContainerRequest( request.scaling_option, defaults ) + if request.health_check is not None: + output["health_check"] = marshal_ContainerHealthCheckSpec( + request.health_check, defaults + ) + return output @@ -1043,6 +1164,11 @@ def marshal_UpdateContainerRequest( request.scaling_option, defaults ) + if request.health_check is not None: + output["health_check"] = marshal_ContainerHealthCheckSpec( + request.health_check, defaults + ) + return output diff --git a/scaleway-async/scaleway_async/container/v1beta1/types.py b/scaleway-async/scaleway_async/container/v1beta1/types.py index 43a090c07..93f35f15f 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/types.py +++ b/scaleway-async/scaleway_async/container/v1beta1/types.py @@ -191,6 +191,37 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class ContainerHealthCheckSpecHTTPProbe: + path: str + """ + Path to use for the HTTP health check. + """ + + +@dataclass +class ContainerHealthCheckSpecTCPProbe: + pass + + +@dataclass +class ContainerHealthCheckSpec: + failure_threshold: int + """ + During a deployment, if a newly created container fails to pass the health check, the deployment is aborted. +As a result, lowering this value can help to reduce the time it takes to detect a failed deployment. + """ + + interval: Optional[str] + """ + Period between health checks. + """ + + http: Optional[ContainerHealthCheckSpecHTTPProbe] + + tcp: Optional[ContainerHealthCheckSpecTCPProbe] + + @dataclass class ContainerScalingOption: concurrent_requests_threshold: Optional[int] @@ -383,39 +414,39 @@ class Container: Name of the registry image (e.g. "rg.fr-par.scw.cloud/something/image:tag"). """ - max_concurrency: int + timeout: Optional[str] """ - Number of maximum concurrent executions of the container. + Processing time limit for the container. """ - domain_name: str + error_message: Optional[str] """ - Domain name attributed to the contaioner. + Last error message of the container. """ - protocol: ContainerProtocol + description: Optional[str] """ - Protocol the container uses. + Description of the container. """ - port: int + max_concurrency: int """ - Port the container listens on. + Number of maximum concurrent executions of the container. """ - timeout: Optional[str] + domain_name: str """ - Processing time limit for the container. + Domain name attributed to the contaioner. """ - error_message: Optional[str] + protocol: ContainerProtocol """ - Last error message of the container. + Protocol the container uses. """ - description: Optional[str] + port: int """ - Description of the container. + Port the container listens on. """ secret_environment_variables: List[SecretHashedValue] @@ -452,6 +483,11 @@ class Container: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + created_at: Optional[datetime] """ Creation date of the container. @@ -796,6 +832,11 @@ class CreateContainerRequest: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + @dataclass class CreateCronRequest: @@ -1469,6 +1510,11 @@ class UpdateContainerRequest: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + @dataclass class UpdateCronRequest: diff --git a/scaleway/scaleway/container/v1beta1/__init__.py b/scaleway/scaleway/container/v1beta1/__init__.py index edca19aa0..a1de41c3c 100644 --- a/scaleway/scaleway/container/v1beta1/__init__.py +++ b/scaleway/scaleway/container/v1beta1/__init__.py @@ -23,6 +23,9 @@ from .types import TriggerInputType from .types import TriggerStatus from .content import TRIGGER_TRANSIENT_STATUSES +from .types import ContainerHealthCheckSpecHTTPProbe +from .types import ContainerHealthCheckSpecTCPProbe +from .types import ContainerHealthCheckSpec from .types import ContainerScalingOption from .types import SecretHashedValue from .types import TriggerMnqNatsClientConfig @@ -100,6 +103,9 @@ "TriggerInputType", "TriggerStatus", "TRIGGER_TRANSIENT_STATUSES", + "ContainerHealthCheckSpecHTTPProbe", + "ContainerHealthCheckSpecTCPProbe", + "ContainerHealthCheckSpec", "ContainerScalingOption", "SecretHashedValue", "TriggerMnqNatsClientConfig", diff --git a/scaleway/scaleway/container/v1beta1/api.py b/scaleway/scaleway/container/v1beta1/api.py index 648620a42..4dd8462b2 100644 --- a/scaleway/scaleway/container/v1beta1/api.py +++ b/scaleway/scaleway/container/v1beta1/api.py @@ -29,6 +29,7 @@ ListTokensRequestOrderBy, ListTriggersRequestOrderBy, Container, + ContainerHealthCheckSpec, ContainerScalingOption, CreateContainerRequest, CreateCronRequest, @@ -599,6 +600,7 @@ def create_container( sandbox: Optional[ContainerSandbox] = None, local_storage_limit: Optional[int] = None, scaling_option: Optional[ContainerScalingOption] = None, + health_check: Optional[ContainerHealthCheckSpec] = None, ) -> Container: """ Create a new container. @@ -627,6 +629,7 @@ def create_container( :param scaling_option: Possible values: - concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance. - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. + :param health_check: Health check configuration of the container. :return: :class:`Container ` Usage: @@ -667,6 +670,7 @@ def create_container( sandbox=sandbox, local_storage_limit=local_storage_limit, scaling_option=scaling_option, + health_check=health_check, ), self.client, ), @@ -698,6 +702,7 @@ def update_container( sandbox: Optional[ContainerSandbox] = None, local_storage_limit: Optional[int] = None, scaling_option: Optional[ContainerScalingOption] = None, + health_check: Optional[ContainerHealthCheckSpec] = None, ) -> Container: """ Update an existing container. @@ -726,6 +731,7 @@ def update_container( :param scaling_option: Possible values: - concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance. - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. + :param health_check: Health check configuration of the container. :return: :class:`Container ` Usage: @@ -766,6 +772,7 @@ def update_container( sandbox=sandbox, local_storage_limit=local_storage_limit, scaling_option=scaling_option, + health_check=health_check, ), self.client, ), diff --git a/scaleway/scaleway/container/v1beta1/marshalling.py b/scaleway/scaleway/container/v1beta1/marshalling.py index 7606d9b08..97d792352 100644 --- a/scaleway/scaleway/container/v1beta1/marshalling.py +++ b/scaleway/scaleway/container/v1beta1/marshalling.py @@ -10,6 +10,9 @@ resolve_one_of, ) from .types import ( + ContainerHealthCheckSpecHTTPProbe, + ContainerHealthCheckSpecTCPProbe, + ContainerHealthCheckSpec, ContainerScalingOption, SecretHashedValue, Container, @@ -45,6 +48,69 @@ ) +def unmarshal_ContainerHealthCheckSpecHTTPProbe( + data: Any, +) -> ContainerHealthCheckSpecHTTPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpecHTTPProbe' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("path", None) + if field is not None: + args["path"] = field + + return ContainerHealthCheckSpecHTTPProbe(**args) + + +def unmarshal_ContainerHealthCheckSpecTCPProbe( + data: Any, +) -> ContainerHealthCheckSpecTCPProbe: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpecTCPProbe' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + return ContainerHealthCheckSpecTCPProbe(**args) + + +def unmarshal_ContainerHealthCheckSpec(data: Any) -> ContainerHealthCheckSpec: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ContainerHealthCheckSpec' 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 + + field = data.get("http", None) + if field is not None: + args["http"] = unmarshal_ContainerHealthCheckSpecHTTPProbe(field) + else: + args["http"] = None + + field = data.get("tcp", None) + if field is not None: + args["tcp"] = unmarshal_ContainerHealthCheckSpecTCPProbe(field) + else: + args["tcp"] = None + + field = data.get("interval", None) + if field is not None: + args["interval"] = field + else: + args["interval"] = None + + return ContainerHealthCheckSpec(**args) + + def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption: if not isinstance(data, dict): raise TypeError( @@ -139,22 +205,6 @@ def unmarshal_Container(data: Any) -> Container: if field is not None: args["registry_image"] = field - field = data.get("max_concurrency", None) - if field is not None: - args["max_concurrency"] = field - - field = data.get("domain_name", None) - if field is not None: - args["domain_name"] = field - - field = data.get("protocol", None) - if field is not None: - args["protocol"] = field - - field = data.get("port", None) - if field is not None: - args["port"] = field - field = data.get("timeout", None) if field is not None: args["timeout"] = field @@ -173,6 +223,22 @@ def unmarshal_Container(data: Any) -> Container: else: args["description"] = None + field = data.get("max_concurrency", None) + if field is not None: + args["max_concurrency"] = field + + field = data.get("domain_name", None) + if field is not None: + args["domain_name"] = field + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + + field = data.get("port", None) + if field is not None: + args["port"] = field + field = data.get("secret_environment_variables", None) if field is not None: args["secret_environment_variables"] = ( @@ -203,6 +269,12 @@ def unmarshal_Container(data: Any) -> Container: else: args["scaling_option"] = None + field = data.get("health_check", None) + if field is not None: + args["health_check"] = unmarshal_ContainerHealthCheckSpec(field) + else: + args["health_check"] = None + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field @@ -696,6 +768,50 @@ def unmarshal_ListTriggersResponse(data: Any) -> ListTriggersResponse: return ListTriggersResponse(**args) +def marshal_ContainerHealthCheckSpecHTTPProbe( + request: ContainerHealthCheckSpecHTTPProbe, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.path is not None: + output["path"] = request.path + + return output + + +def marshal_ContainerHealthCheckSpecTCPProbe( + request: ContainerHealthCheckSpecTCPProbe, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + return output + + +def marshal_ContainerHealthCheckSpec( + request: ContainerHealthCheckSpec, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("http", request.http), + OneOfPossibility("tcp", request.tcp), + ] + ), + ) + + if request.failure_threshold is not None: + output["failure_threshold"] = request.failure_threshold + + if request.interval is not None: + output["interval"] = request.interval + + return output + + def marshal_ContainerScalingOption( request: ContainerScalingOption, defaults: ProfileDefaults, @@ -799,6 +915,11 @@ def marshal_CreateContainerRequest( request.scaling_option, defaults ) + if request.health_check is not None: + output["health_check"] = marshal_ContainerHealthCheckSpec( + request.health_check, defaults + ) + return output @@ -1043,6 +1164,11 @@ def marshal_UpdateContainerRequest( request.scaling_option, defaults ) + if request.health_check is not None: + output["health_check"] = marshal_ContainerHealthCheckSpec( + request.health_check, defaults + ) + return output diff --git a/scaleway/scaleway/container/v1beta1/types.py b/scaleway/scaleway/container/v1beta1/types.py index 43a090c07..93f35f15f 100644 --- a/scaleway/scaleway/container/v1beta1/types.py +++ b/scaleway/scaleway/container/v1beta1/types.py @@ -191,6 +191,37 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class ContainerHealthCheckSpecHTTPProbe: + path: str + """ + Path to use for the HTTP health check. + """ + + +@dataclass +class ContainerHealthCheckSpecTCPProbe: + pass + + +@dataclass +class ContainerHealthCheckSpec: + failure_threshold: int + """ + During a deployment, if a newly created container fails to pass the health check, the deployment is aborted. +As a result, lowering this value can help to reduce the time it takes to detect a failed deployment. + """ + + interval: Optional[str] + """ + Period between health checks. + """ + + http: Optional[ContainerHealthCheckSpecHTTPProbe] + + tcp: Optional[ContainerHealthCheckSpecTCPProbe] + + @dataclass class ContainerScalingOption: concurrent_requests_threshold: Optional[int] @@ -383,39 +414,39 @@ class Container: Name of the registry image (e.g. "rg.fr-par.scw.cloud/something/image:tag"). """ - max_concurrency: int + timeout: Optional[str] """ - Number of maximum concurrent executions of the container. + Processing time limit for the container. """ - domain_name: str + error_message: Optional[str] """ - Domain name attributed to the contaioner. + Last error message of the container. """ - protocol: ContainerProtocol + description: Optional[str] """ - Protocol the container uses. + Description of the container. """ - port: int + max_concurrency: int """ - Port the container listens on. + Number of maximum concurrent executions of the container. """ - timeout: Optional[str] + domain_name: str """ - Processing time limit for the container. + Domain name attributed to the contaioner. """ - error_message: Optional[str] + protocol: ContainerProtocol """ - Last error message of the container. + Protocol the container uses. """ - description: Optional[str] + port: int """ - Description of the container. + Port the container listens on. """ secret_environment_variables: List[SecretHashedValue] @@ -452,6 +483,11 @@ class Container: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + created_at: Optional[datetime] """ Creation date of the container. @@ -796,6 +832,11 @@ class CreateContainerRequest: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + @dataclass class CreateCronRequest: @@ -1469,6 +1510,11 @@ class UpdateContainerRequest: - cpu_usage_threshold: Scale depending on the CPU usage of a container instance. """ + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. + """ + @dataclass class UpdateCronRequest: