Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 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,7 @@
from .types import TriggerInputType
from .types import TriggerStatus
from .content import TRIGGER_TRANSIENT_STATUSES
from .types import ContainerScalingOption
from .types import SecretHashedValue
from .types import TriggerMnqNatsClientConfig
from .types import TriggerMnqSqsClientConfig
Expand Down Expand Up @@ -99,6 +100,7 @@
"TriggerInputType",
"TriggerStatus",
"TRIGGER_TRANSIENT_STATUSES",
"ContainerScalingOption",
"SecretHashedValue",
"TriggerMnqNatsClientConfig",
"TriggerMnqSqsClientConfig",
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,
ContainerScalingOption,
CreateContainerRequest,
CreateCronRequest,
CreateDomainRequest,
Expand Down Expand Up @@ -595,6 +596,7 @@ async def create_container(
http_option: Optional[ContainerHttpOption] = None,
sandbox: Optional[ContainerSandbox] = None,
local_storage_limit: Optional[int] = None,
scaling_option: Optional[ContainerScalingOption] = None,
) -> Container:
"""
Create a new container.
Expand All @@ -620,6 +622,8 @@ async def create_container(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the 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.
:return: :class:`Container <Container>`

Usage:
Expand Down Expand Up @@ -659,6 +663,7 @@ async def create_container(
http_option=http_option,
sandbox=sandbox,
local_storage_limit=local_storage_limit,
scaling_option=scaling_option,
),
self.client,
),
Expand Down Expand Up @@ -689,6 +694,7 @@ async def update_container(
http_option: Optional[ContainerHttpOption] = None,
sandbox: Optional[ContainerSandbox] = None,
local_storage_limit: Optional[int] = None,
scaling_option: Optional[ContainerScalingOption] = None,
) -> Container:
"""
Update an existing container.
Expand All @@ -714,6 +720,8 @@ async def update_container(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the 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.
:return: :class:`Container <Container>`

Usage:
Expand Down Expand Up @@ -753,6 +761,7 @@ async def update_container(
http_option=http_option,
sandbox=sandbox,
local_storage_limit=local_storage_limit,
scaling_option=scaling_option,
),
self.client,
),
Expand Down
77 changes: 65 additions & 12 deletions scaleway-async/scaleway_async/container/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
resolve_one_of,
)
from .types import (
ContainerScalingOption,
SecretHashedValue,
Container,
Cron,
Expand Down Expand Up @@ -44,6 +45,23 @@
)


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"] = None

return ContainerScalingOption(**args)


def unmarshal_SecretHashedValue(data: Any) -> SecretHashedValue:
if not isinstance(data, dict):
raise TypeError(
Expand Down Expand Up @@ -119,6 +137,18 @@ def unmarshal_Container(data: Any) -> Container:
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 @@ -137,18 +167,6 @@ def unmarshal_Container(data: Any) -> Container:
else:
args["description"] = None

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 All @@ -173,6 +191,12 @@ def unmarshal_Container(data: Any) -> Container:
if field is not None:
args["region"] = field

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

return Container(**args)


Expand Down Expand Up @@ -644,6 +668,25 @@ def unmarshal_ListTriggersResponse(data: Any) -> ListTriggersResponse:
return ListTriggersResponse(**args)


def marshal_ContainerScalingOption(
request: ContainerScalingOption,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}
output.update(
resolve_one_of(
[
OneOfPossibility(
"concurrent_requests_threshold",
request.concurrent_requests_threshold,
),
]
),
)

return output


def marshal_Secret(
request: Secret,
defaults: ProfileDefaults,
Expand Down Expand Up @@ -722,6 +765,11 @@ def marshal_CreateContainerRequest(
if request.local_storage_limit is not None:
output["local_storage_limit"] = request.local_storage_limit

if request.scaling_option is not None:
output["scaling_option"] = marshal_ContainerScalingOption(
request.scaling_option, defaults
)

return output


Expand Down Expand Up @@ -958,6 +1006,11 @@ def marshal_UpdateContainerRequest(
if request.local_storage_limit is not None:
output["local_storage_limit"] = request.local_storage_limit

if request.scaling_option is not None:
output["scaling_option"] = marshal_ContainerScalingOption(
request.scaling_option, defaults
)

return output


Expand Down
47 changes: 35 additions & 12 deletions scaleway-async/scaleway_async/container/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ def __str__(self) -> str:
return str(self.value)


@dataclass
class ContainerScalingOption:
concurrent_requests_threshold: Optional[int]


@dataclass
class SecretHashedValue:
key: str
Expand Down Expand Up @@ -381,34 +386,34 @@ class Container:
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.
"""

domain_name: str
timeout: Optional[str]
"""
Domain name attributed to the contaioner.
Processing time limit for the container.
"""

protocol: ContainerProtocol
error_message: Optional[str]
"""
Protocol the container uses.
Last error message of the container.
"""

port: int
description: Optional[str]
"""
Port the container listens on.
Description of the container.
"""

secret_environment_variables: List[SecretHashedValue]
Expand Down Expand Up @@ -438,6 +443,12 @@ class Container:
Region in which the container will be deployed.
"""

scaling_option: Optional[ContainerScalingOption]
"""
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
"""


@dataclass
class Cron:
Expand Down Expand Up @@ -755,6 +766,12 @@ class CreateContainerRequest:
Local storage limit of the container (in MB).
"""

scaling_option: Optional[ContainerScalingOption]
"""
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
"""


@dataclass
class CreateCronRequest:
Expand Down Expand Up @@ -1416,6 +1433,12 @@ class UpdateContainerRequest:
Local storage limit of the container (in MB).
"""

scaling_option: Optional[ContainerScalingOption]
"""
Possible values:
- concurrent_requests_threshold: Scale depending on the number of concurrent requests being processed per container instance.
"""


@dataclass
class UpdateCronRequest:
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/container/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from .types import TriggerInputType
from .types import TriggerStatus
from .content import TRIGGER_TRANSIENT_STATUSES
from .types import ContainerScalingOption
from .types import SecretHashedValue
from .types import TriggerMnqNatsClientConfig
from .types import TriggerMnqSqsClientConfig
Expand Down Expand Up @@ -99,6 +100,7 @@
"TriggerInputType",
"TriggerStatus",
"TRIGGER_TRANSIENT_STATUSES",
"ContainerScalingOption",
"SecretHashedValue",
"TriggerMnqNatsClientConfig",
"TriggerMnqSqsClientConfig",
Expand Down
9 changes: 9 additions & 0 deletions scaleway/scaleway/container/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
ListTokensRequestOrderBy,
ListTriggersRequestOrderBy,
Container,
ContainerScalingOption,
CreateContainerRequest,
CreateCronRequest,
CreateDomainRequest,
Expand Down Expand Up @@ -591,6 +592,7 @@ def create_container(
http_option: Optional[ContainerHttpOption] = None,
sandbox: Optional[ContainerSandbox] = None,
local_storage_limit: Optional[int] = None,
scaling_option: Optional[ContainerScalingOption] = None,
) -> Container:
"""
Create a new container.
Expand All @@ -616,6 +618,8 @@ def create_container(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the 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.
:return: :class:`Container <Container>`

Usage:
Expand Down Expand Up @@ -655,6 +659,7 @@ def create_container(
http_option=http_option,
sandbox=sandbox,
local_storage_limit=local_storage_limit,
scaling_option=scaling_option,
),
self.client,
),
Expand Down Expand Up @@ -685,6 +690,7 @@ def update_container(
http_option: Optional[ContainerHttpOption] = None,
sandbox: Optional[ContainerSandbox] = None,
local_storage_limit: Optional[int] = None,
scaling_option: Optional[ContainerScalingOption] = None,
) -> Container:
"""
Update an existing container.
Expand All @@ -710,6 +716,8 @@ def update_container(
- enabled: Serve both HTTP and HTTPS traffic.
:param sandbox: Execution environment of the 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.
:return: :class:`Container <Container>`

Usage:
Expand Down Expand Up @@ -749,6 +757,7 @@ def update_container(
http_option=http_option,
sandbox=sandbox,
local_storage_limit=local_storage_limit,
scaling_option=scaling_option,
),
self.client,
),
Expand Down
Loading