Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions scaleway-async/scaleway_async/container/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -100,6 +103,9 @@
"TriggerInputType",
"TriggerStatus",
"TRIGGER_TRANSIENT_STATUSES",
"ContainerHealthCheckSpecHTTPProbe",
"ContainerHealthCheckSpecTCPProbe",
"ContainerHealthCheckSpec",
"ContainerScalingOption",
"SecretHashedValue",
"TriggerMnqNatsClientConfig",
Expand Down
9 changes: 9 additions & 0 deletions scaleway-async/scaleway_async/container/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ListTokensRequestOrderBy,
ListTriggersRequestOrderBy,
Container,
ContainerHealthCheckSpec,
ContainerScalingOption,
CreateContainerRequest,
CreateCronRequest,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -630,6 +632,8 @@ async def create_container(
:param local_storage_limit: Local storage limit of the container (in MB).
: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 <Container>`

Usage:
Expand Down Expand Up @@ -670,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,
),
Expand Down Expand Up @@ -701,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.
Expand Down Expand Up @@ -728,6 +734,8 @@ async def update_container(
:param local_storage_limit: Local storage limit of the container (in MB).
: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 <Container>`

Usage:
Expand Down Expand Up @@ -768,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,
),
Expand Down
165 changes: 149 additions & 16 deletions scaleway-async/scaleway_async/container/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
resolve_one_of,
)
from .types import (
ContainerHealthCheckSpecHTTPProbe,
ContainerHealthCheckSpecTCPProbe,
ContainerHealthCheckSpec,
ContainerScalingOption,
SecretHashedValue,
Container,
Expand Down Expand Up @@ -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(
Expand All @@ -59,6 +125,12 @@ def unmarshal_ContainerScalingOption(data: Any) -> ContainerScalingOption:
else:
args["concurrent_requests_threshold"] = None

field = data.get("cpu_usage_threshold", None)
if field is not None:
args["cpu_usage_threshold"] = field
else:
args["cpu_usage_threshold"] = None

return ContainerScalingOption(**args)


Expand Down Expand Up @@ -133,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
Expand All @@ -167,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"] = (
Expand Down Expand Up @@ -197,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
Expand Down Expand Up @@ -690,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,
Expand All @@ -702,6 +824,7 @@ def marshal_ContainerScalingOption(
"concurrent_requests_threshold",
request.concurrent_requests_threshold,
),
OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold),
]
),
)
Expand Down Expand Up @@ -792,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


Expand Down Expand Up @@ -1036,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


Expand Down
Loading