From eeff26004131dc9be4e994853b4f3ac6d2edeb71 Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Thu, 31 Oct 2024 09:11:34 +0000 Subject: [PATCH 1/7] feat: update generated APIs --- .../container/v1beta1/__init__.py | 6 + .../scaleway_async/container/v1beta1/api.py | 9 + .../container/v1beta1/marshalling.py | 165 ++++++++++++++++-- .../scaleway_async/container/v1beta1/types.py | 79 +++++++-- .../scaleway/container/v1beta1/__init__.py | 6 + scaleway/scaleway/container/v1beta1/api.py | 9 + .../scaleway/container/v1beta1/marshalling.py | 165 ++++++++++++++++-- scaleway/scaleway/container/v1beta1/types.py | 79 +++++++-- 8 files changed, 458 insertions(+), 60 deletions(-) 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 e7b36fdb0..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. @@ -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 ` Usage: @@ -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, ), @@ -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. @@ -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 ` Usage: @@ -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, ), diff --git a/scaleway-async/scaleway_async/container/v1beta1/marshalling.py b/scaleway-async/scaleway_async/container/v1beta1/marshalling.py index 77998357f..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( @@ -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) @@ -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 @@ -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"] = ( @@ -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 @@ -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, @@ -702,6 +824,7 @@ def marshal_ContainerScalingOption( "concurrent_requests_threshold", request.concurrent_requests_threshold, ), + OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold), ] ), ) @@ -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 @@ -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 diff --git a/scaleway-async/scaleway_async/container/v1beta1/types.py b/scaleway-async/scaleway_async/container/v1beta1/types.py index c96afa2b3..93f35f15f 100644 --- a/scaleway-async/scaleway_async/container/v1beta1/types.py +++ b/scaleway-async/scaleway_async/container/v1beta1/types.py @@ -191,10 +191,43 @@ 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] + cpu_usage_threshold: Optional[int] + @dataclass class SecretHashedValue: @@ -381,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] @@ -447,6 +480,12 @@ class Container: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ created_at: Optional[datetime] @@ -790,6 +829,12 @@ class CreateContainerRequest: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ @@ -1462,6 +1507,12 @@ class UpdateContainerRequest: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ 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 06a6201cb..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. @@ -626,6 +628,8 @@ 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 ` Usage: @@ -666,6 +670,7 @@ def create_container( sandbox=sandbox, local_storage_limit=local_storage_limit, scaling_option=scaling_option, + health_check=health_check, ), self.client, ), @@ -697,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. @@ -724,6 +730,8 @@ 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 ` Usage: @@ -764,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 77998357f..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( @@ -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) @@ -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 @@ -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"] = ( @@ -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 @@ -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, @@ -702,6 +824,7 @@ def marshal_ContainerScalingOption( "concurrent_requests_threshold", request.concurrent_requests_threshold, ), + OneOfPossibility("cpu_usage_threshold", request.cpu_usage_threshold), ] ), ) @@ -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 @@ -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 diff --git a/scaleway/scaleway/container/v1beta1/types.py b/scaleway/scaleway/container/v1beta1/types.py index c96afa2b3..93f35f15f 100644 --- a/scaleway/scaleway/container/v1beta1/types.py +++ b/scaleway/scaleway/container/v1beta1/types.py @@ -191,10 +191,43 @@ 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] + cpu_usage_threshold: Optional[int] + @dataclass class SecretHashedValue: @@ -381,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] @@ -447,6 +480,12 @@ class Container: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ created_at: Optional[datetime] @@ -790,6 +829,12 @@ class CreateContainerRequest: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ @@ -1462,6 +1507,12 @@ class UpdateContainerRequest: """ 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. + """ + + health_check: Optional[ContainerHealthCheckSpec] + """ + Health check configuration of the container. """ From 14eb248f01eb1d2bead590f02b6b38acef5d10d8 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Thu, 31 Oct 2024 18:07:55 +0100 Subject: [PATCH 2/7] feat(mongodb): make CreateUser.password none optional (#724) --- scaleway-async/scaleway_async/mongodb/v1alpha1/api.py | 7 ++++--- scaleway-async/scaleway_async/mongodb/v1alpha1/types.py | 8 ++++---- scaleway/scaleway/mongodb/v1alpha1/api.py | 7 ++++--- scaleway/scaleway/mongodb/v1alpha1/types.py | 8 ++++---- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py index 78883abbf..6f9df35d7 100644 --- a/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py @@ -1077,16 +1077,16 @@ async def create_user( *, instance_id: str, name: str, + password: str, region: Optional[Region] = None, - password: Optional[str] = None, ) -> User: """ Create an user on a Database Instance. Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request. :param instance_id: UUID of the Database Instance the user belongs to. :param name: Name of the database user. - :param region: Region to target. If none is passed will use default region from the config. :param password: Password of the database user. + :param region: Region to target. If none is passed will use default region from the config. :return: :class:`User ` Usage: @@ -1095,6 +1095,7 @@ async def create_user( result = await api.create_user( instance_id="example", name="example", + password="example", ) """ @@ -1111,8 +1112,8 @@ async def create_user( CreateUserRequest( instance_id=instance_id, name=name, - region=region, password=password, + region=region, ), self.client, ), diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py index fec93e393..9fd17e352 100644 --- a/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/types.py @@ -604,14 +604,14 @@ class CreateUserRequest: Name of the database user. """ - region: Optional[Region] + password: str """ - Region to target. If none is passed will use default region from the config. + Password of the database user. """ - password: Optional[str] + region: Optional[Region] """ - Password of the database user. + Region to target. If none is passed will use default region from the config. """ diff --git a/scaleway/scaleway/mongodb/v1alpha1/api.py b/scaleway/scaleway/mongodb/v1alpha1/api.py index 15577d853..f1388166c 100644 --- a/scaleway/scaleway/mongodb/v1alpha1/api.py +++ b/scaleway/scaleway/mongodb/v1alpha1/api.py @@ -1073,16 +1073,16 @@ def create_user( *, instance_id: str, name: str, + password: str, region: Optional[Region] = None, - password: Optional[str] = None, ) -> User: """ Create an user on a Database Instance. Create an user on a Database Instance. You must define the `name`, `password` of the user and `instance_id` parameters in the request. :param instance_id: UUID of the Database Instance the user belongs to. :param name: Name of the database user. - :param region: Region to target. If none is passed will use default region from the config. :param password: Password of the database user. + :param region: Region to target. If none is passed will use default region from the config. :return: :class:`User ` Usage: @@ -1091,6 +1091,7 @@ def create_user( result = api.create_user( instance_id="example", name="example", + password="example", ) """ @@ -1107,8 +1108,8 @@ def create_user( CreateUserRequest( instance_id=instance_id, name=name, - region=region, password=password, + region=region, ), self.client, ), diff --git a/scaleway/scaleway/mongodb/v1alpha1/types.py b/scaleway/scaleway/mongodb/v1alpha1/types.py index fec93e393..9fd17e352 100644 --- a/scaleway/scaleway/mongodb/v1alpha1/types.py +++ b/scaleway/scaleway/mongodb/v1alpha1/types.py @@ -604,14 +604,14 @@ class CreateUserRequest: Name of the database user. """ - region: Optional[Region] + password: str """ - Region to target. If none is passed will use default region from the config. + Password of the database user. """ - password: Optional[str] + region: Optional[Region] """ - Password of the database user. + Region to target. If none is passed will use default region from the config. """ From d476e19783e83724501b9820bd7ad75c2494e99e Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 08:22:14 +0100 Subject: [PATCH 3/7] feat(apple-silicon): add VNC port suppport (#723) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- .../scaleway_async/applesilicon/v1alpha1/marshalling.py | 4 ++++ scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py | 5 +++++ scaleway/scaleway/applesilicon/v1alpha1/marshalling.py | 4 ++++ scaleway/scaleway/applesilicon/v1alpha1/types.py | 5 +++++ 4 files changed, 18 insertions(+) diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py index 57ba88031..b057db698 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/marshalling.py @@ -266,6 +266,10 @@ def unmarshal_Server(data: Any) -> Server: if field is not None: args["sudo_password"] = field + field = data.get("vnc_port", None) + if field is not None: + args["vnc_port"] = field + field = data.get("status", None) if field is not None: args["status"] = field diff --git a/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py b/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py index 779b71cf3..1e13e4a5f 100644 --- a/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/applesilicon/v1alpha1/types.py @@ -225,6 +225,11 @@ class Server: Admin password required to execute commands. """ + vnc_port: int + """ + VNC port to use for remote desktop connection. + """ + status: ServerStatus """ Current status of the server. diff --git a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py index 57ba88031..b057db698 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/marshalling.py @@ -266,6 +266,10 @@ def unmarshal_Server(data: Any) -> Server: if field is not None: args["sudo_password"] = field + field = data.get("vnc_port", None) + if field is not None: + args["vnc_port"] = field + field = data.get("status", None) if field is not None: args["status"] = field diff --git a/scaleway/scaleway/applesilicon/v1alpha1/types.py b/scaleway/scaleway/applesilicon/v1alpha1/types.py index 779b71cf3..1e13e4a5f 100644 --- a/scaleway/scaleway/applesilicon/v1alpha1/types.py +++ b/scaleway/scaleway/applesilicon/v1alpha1/types.py @@ -225,6 +225,11 @@ class Server: Admin password required to execute commands. """ + vnc_port: int + """ + VNC port to use for remote desktop connection. + """ + status: ServerStatus """ Current status of the server. From 8b28c0e21864efe743ee5202d10942a2daaf4c10 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 08:28:42 +0100 Subject: [PATCH 4/7] feat(k8s): expose ACL routes in SDK (#726) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- .../scaleway_async/k8s/v1/__init__.py | 18 ++ scaleway-async/scaleway_async/k8s/v1/api.py | 210 ++++++++++++++++++ .../scaleway_async/k8s/v1/marshalling.py | 141 ++++++++++++ scaleway-async/scaleway_async/k8s/v1/types.py | 130 +++++++++++ scaleway/scaleway/k8s/v1/__init__.py | 18 ++ scaleway/scaleway/k8s/v1/api.py | 210 ++++++++++++++++++ scaleway/scaleway/k8s/v1/marshalling.py | 141 ++++++++++++ scaleway/scaleway/k8s/v1/types.py | 130 +++++++++++ 8 files changed, 998 insertions(+) diff --git a/scaleway-async/scaleway_async/k8s/v1/__init__.py b/scaleway-async/scaleway_async/k8s/v1/__init__.py index f27274871..6a088ca7f 100644 --- a/scaleway-async/scaleway_async/k8s/v1/__init__.py +++ b/scaleway-async/scaleway_async/k8s/v1/__init__.py @@ -24,6 +24,8 @@ from .types import ClusterAutoscalerConfig from .types import ClusterOpenIDConnectConfig from .types import Pool +from .types import ACLRuleRequest +from .types import ACLRule from .types import CreateClusterRequestAutoUpgrade from .types import CreateClusterRequestAutoscalerConfig from .types import CreateClusterRequestOpenIDConnectConfig @@ -39,10 +41,13 @@ from .types import UpdateClusterRequestAutoscalerConfig from .types import UpdateClusterRequestOpenIDConnectConfig from .types import UpdatePoolRequestUpgradePolicy +from .types import AddClusterACLRulesRequest +from .types import AddClusterACLRulesResponse from .types import AuthExternalNodeRequest from .types import CreateClusterRequest from .types import CreateExternalNodeRequest from .types import CreatePoolRequest +from .types import DeleteACLRuleRequest from .types import DeleteClusterRequest from .types import DeleteNodeRequest from .types import DeletePoolRequest @@ -54,6 +59,8 @@ from .types import GetNodeRequest from .types import GetPoolRequest from .types import GetVersionRequest +from .types import ListClusterACLRulesRequest +from .types import ListClusterACLRulesResponse from .types import ListClusterAvailableTypesRequest from .types import ListClusterAvailableTypesResponse from .types import ListClusterAvailableVersionsRequest @@ -73,6 +80,8 @@ from .types import RebootNodeRequest from .types import ReplaceNodeRequest from .types import ResetClusterAdminTokenRequest +from .types import SetClusterACLRulesRequest +from .types import SetClusterACLRulesResponse from .types import SetClusterTypeRequest from .types import UpdateClusterRequest from .types import UpdatePoolRequest @@ -105,6 +114,8 @@ "ClusterAutoscalerConfig", "ClusterOpenIDConnectConfig", "Pool", + "ACLRuleRequest", + "ACLRule", "CreateClusterRequestAutoUpgrade", "CreateClusterRequestAutoscalerConfig", "CreateClusterRequestOpenIDConnectConfig", @@ -120,10 +131,13 @@ "UpdateClusterRequestAutoscalerConfig", "UpdateClusterRequestOpenIDConnectConfig", "UpdatePoolRequestUpgradePolicy", + "AddClusterACLRulesRequest", + "AddClusterACLRulesResponse", "AuthExternalNodeRequest", "CreateClusterRequest", "CreateExternalNodeRequest", "CreatePoolRequest", + "DeleteACLRuleRequest", "DeleteClusterRequest", "DeleteNodeRequest", "DeletePoolRequest", @@ -135,6 +149,8 @@ "GetNodeRequest", "GetPoolRequest", "GetVersionRequest", + "ListClusterACLRulesRequest", + "ListClusterACLRulesResponse", "ListClusterAvailableTypesRequest", "ListClusterAvailableTypesResponse", "ListClusterAvailableVersionsRequest", @@ -154,6 +170,8 @@ "RebootNodeRequest", "ReplaceNodeRequest", "ResetClusterAdminTokenRequest", + "SetClusterACLRulesRequest", + "SetClusterACLRulesResponse", "SetClusterTypeRequest", "UpdateClusterRequest", "UpdatePoolRequest", diff --git a/scaleway-async/scaleway_async/k8s/v1/api.py b/scaleway-async/scaleway_async/k8s/v1/api.py index 9ab8ae39b..50edcdb4f 100644 --- a/scaleway-async/scaleway_async/k8s/v1/api.py +++ b/scaleway-async/scaleway_async/k8s/v1/api.py @@ -27,6 +27,10 @@ PoolStatus, PoolVolumeType, Runtime, + ACLRule, + ACLRuleRequest, + AddClusterACLRulesRequest, + AddClusterACLRulesResponse, Cluster, ClusterType, CreateClusterRequest, @@ -38,6 +42,7 @@ CreatePoolRequestUpgradePolicy, ExternalNode, ExternalNodeAuth, + ListClusterACLRulesResponse, ListClusterAvailableTypesResponse, ListClusterAvailableVersionsResponse, ListClusterTypesResponse, @@ -48,6 +53,8 @@ Node, NodeMetadata, Pool, + SetClusterACLRulesRequest, + SetClusterACLRulesResponse, SetClusterTypeRequest, UpdateClusterRequest, UpdateClusterRequestAutoUpgrade, @@ -69,8 +76,10 @@ unmarshal_Version, unmarshal_Cluster, unmarshal_Node, + unmarshal_AddClusterACLRulesResponse, unmarshal_ExternalNode, unmarshal_ExternalNodeAuth, + unmarshal_ListClusterACLRulesResponse, unmarshal_ListClusterAvailableTypesResponse, unmarshal_ListClusterAvailableVersionsResponse, unmarshal_ListClusterTypesResponse, @@ -79,8 +88,11 @@ unmarshal_ListPoolsResponse, unmarshal_ListVersionsResponse, unmarshal_NodeMetadata, + unmarshal_SetClusterACLRulesResponse, + marshal_AddClusterACLRulesRequest, marshal_CreateClusterRequest, marshal_CreatePoolRequest, + marshal_SetClusterACLRulesRequest, marshal_SetClusterTypeRequest, marshal_UpdateClusterRequest, marshal_UpdatePoolRequest, @@ -749,6 +761,204 @@ async def migrate_cluster_to_sbscsi( self._throw_on_error(res) return unmarshal_Cluster(res.json()) + async def list_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListClusterACLRulesResponse: + """ + List ACLs. + List ACLs for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be listed. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number for the returned ACLs. + :param page_size: Maximum number of ACLs per page. + :return: :class:`ListClusterACLRulesResponse ` + + Usage: + :: + + result = await api.list_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "GET", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListClusterACLRulesResponse(res.json()) + + async def list_cluster_acl_rules_all( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ACLRule]: + """ + List ACLs. + List ACLs for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be listed. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number for the returned ACLs. + :param page_size: Maximum number of ACLs per page. + :return: :class:`List[ACLRule] ` + + Usage: + :: + + result = await api.list_cluster_acl_rules_all( + cluster_id="example", + ) + """ + + return await fetch_all_pages_async( + type=ListClusterACLRulesResponse, + key="rules", + fetcher=self.list_cluster_acl_rules, + args={ + "cluster_id": cluster_id, + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + async def add_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + acls: Optional[List[ACLRuleRequest]] = None, + ) -> AddClusterACLRulesResponse: + """ + Add new ACLs. + Add new ACL rules for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be added. + :param region: Region to target. If none is passed will use default region from the config. + :param acls: ACLs to add. + :return: :class:`AddClusterACLRulesResponse ` + + Usage: + :: + + result = await api.add_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "POST", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + body=marshal_AddClusterACLRulesRequest( + AddClusterACLRulesRequest( + cluster_id=cluster_id, + region=region, + acls=acls, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddClusterACLRulesResponse(res.json()) + + async def set_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + acls: Optional[List[ACLRuleRequest]] = None, + ) -> SetClusterACLRulesResponse: + """ + Set new ACLs. + Set new ACL rules for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be set. + :param region: Region to target. If none is passed will use default region from the config. + :param acls: ACLs to set. + :return: :class:`SetClusterACLRulesResponse ` + + Usage: + :: + + result = await api.set_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "PUT", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + body=marshal_SetClusterACLRulesRequest( + SetClusterACLRulesRequest( + cluster_id=cluster_id, + region=region, + acls=acls, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetClusterACLRulesResponse(res.json()) + + async def delete_acl_rule( + self, + *, + acl_id: str, + region: Optional[Region] = None, + ) -> None: + """ + Delete an existing ACL. + :param acl_id: ID of the ACL rule to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_acl_rule( + acl_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_acl_id = validate_path_param("acl_id", acl_id) + + res = self._request( + "DELETE", + f"/k8s/v1/regions/{param_region}/acls/{param_acl_id}", + ) + + self._throw_on_error(res) + async def list_pools( self, *, diff --git a/scaleway-async/scaleway_async/k8s/v1/marshalling.py b/scaleway-async/scaleway_async/k8s/v1/marshalling.py index 26991b89c..1095ed9ca 100644 --- a/scaleway-async/scaleway_async/k8s/v1/marshalling.py +++ b/scaleway-async/scaleway_async/k8s/v1/marshalling.py @@ -21,9 +21,12 @@ ClusterOpenIDConnectConfig, Cluster, Node, + ACLRule, + AddClusterACLRulesResponse, ExternalNodeCoreV1Taint, ExternalNode, ExternalNodeAuth, + ListClusterACLRulesResponse, ClusterType, ListClusterAvailableTypesResponse, ListClusterAvailableVersionsResponse, @@ -34,6 +37,9 @@ ListVersionsResponse, NodeMetadataCoreV1Taint, NodeMetadata, + SetClusterACLRulesResponse, + ACLRuleRequest, + AddClusterACLRulesRequest, CreateClusterRequestPoolConfigUpgradePolicy, CreateClusterRequestAutoUpgrade, CreateClusterRequestAutoscalerConfig, @@ -42,6 +48,7 @@ CreateClusterRequest, CreatePoolRequestUpgradePolicy, CreatePoolRequest, + SetClusterACLRulesRequest, SetClusterTypeRequest, UpdateClusterRequestAutoUpgrade, UpdateClusterRequestAutoscalerConfig, @@ -577,6 +584,54 @@ def unmarshal_Node(data: Any) -> Node: return Node(**args) +def unmarshal_ACLRule(data: Any) -> ACLRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ACLRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("ip", None) + if field is not None: + args["ip"] = field + else: + args["ip"] = None + + field = data.get("scaleway_ranges", None) + if field is not None: + args["scaleway_ranges"] = field + else: + args["scaleway_ranges"] = None + + return ACLRule(**args) + + +def unmarshal_AddClusterACLRulesResponse(data: Any) -> AddClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return AddClusterACLRulesResponse(**args) + + def unmarshal_ExternalNodeCoreV1Taint(data: Any) -> ExternalNodeCoreV1Taint: if not isinstance(data, dict): raise TypeError( @@ -686,6 +741,27 @@ def unmarshal_ExternalNodeAuth(data: Any) -> ExternalNodeAuth: return ExternalNodeAuth(**args) +def unmarshal_ListClusterACLRulesResponse(data: Any) -> ListClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return ListClusterACLRulesResponse(**args) + + def unmarshal_ClusterType(data: Any) -> ClusterType: if not isinstance(data, dict): raise TypeError( @@ -976,6 +1052,57 @@ def unmarshal_NodeMetadata(data: Any) -> NodeMetadata: return NodeMetadata(**args) +def unmarshal_SetClusterACLRulesResponse(data: Any) -> SetClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return SetClusterACLRulesResponse(**args) + + +def marshal_ACLRuleRequest( + request: ACLRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("ip", request.ip), + OneOfPossibility("scaleway_ranges", request.scaleway_ranges), + ] + ), + ) + + if request.description is not None: + output["description"] = request.description + + return output + + +def marshal_AddClusterACLRulesRequest( + request: AddClusterACLRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.acls is not None: + output["acls"] = [ + marshal_ACLRuleRequest(item, defaults) for item in request.acls + ] + + return output + + def marshal_MaintenanceWindow( request: MaintenanceWindow, defaults: ProfileDefaults, @@ -1309,6 +1436,20 @@ def marshal_CreatePoolRequest( return output +def marshal_SetClusterACLRulesRequest( + request: SetClusterACLRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.acls is not None: + output["acls"] = [ + marshal_ACLRuleRequest(item, defaults) for item in request.acls + ] + + return output + + def marshal_SetClusterTypeRequest( request: SetClusterTypeRequest, defaults: ProfileDefaults, diff --git a/scaleway-async/scaleway_async/k8s/v1/types.py b/scaleway-async/scaleway_async/k8s/v1/types.py index 6d1944b53..2df9f07b3 100644 --- a/scaleway-async/scaleway_async/k8s/v1/types.py +++ b/scaleway-async/scaleway_async/k8s/v1/types.py @@ -441,6 +441,35 @@ class Pool: """ +@dataclass +class ACLRuleRequest: + description: str + """ + Description of the ACL. + """ + + ip: Optional[str] + + scaleway_ranges: Optional[bool] + + +@dataclass +class ACLRule: + id: str + """ + ID of the ACL rule. + """ + + description: str + """ + Description of the ACL. + """ + + ip: Optional[str] + + scaleway_ranges: Optional[bool] + + @dataclass class CreateClusterRequestAutoUpgrade: enable: bool @@ -1066,6 +1095,32 @@ class UpdatePoolRequestUpgradePolicy: max_surge: Optional[int] +@dataclass +class AddClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be added. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + acls: Optional[List[ACLRuleRequest]] + """ + ACLs to add. + """ + + +@dataclass +class AddClusterACLRulesResponse: + rules: List[ACLRule] + """ + ACLs that were added. + """ + + @dataclass class AuthExternalNodeRequest: pool_id: str @@ -1264,6 +1319,19 @@ class CreatePoolRequest: """ +@dataclass +class DeleteACLRuleRequest: + acl_id: str + """ + ID of the ACL rule to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class DeleteClusterRequest: cluster_id: str @@ -1432,6 +1500,42 @@ class GetVersionRequest: """ +@dataclass +class ListClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be listed. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number for the returned ACLs. + """ + + page_size: Optional[int] + """ + Maximum number of ACLs per page. + """ + + +@dataclass +class ListClusterACLRulesResponse: + total_count: int + """ + Total number of ACLs that exist for the cluster. + """ + + rules: List[ACLRule] + """ + Paginated returned ACLs. + """ + + @dataclass class ListClusterAvailableTypesRequest: cluster_id: str @@ -1782,6 +1886,32 @@ class ResetClusterAdminTokenRequest: """ +@dataclass +class SetClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be set. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + acls: Optional[List[ACLRuleRequest]] + """ + ACLs to set. + """ + + +@dataclass +class SetClusterACLRulesResponse: + rules: List[ACLRule] + """ + ACLs that were set. + """ + + @dataclass class SetClusterTypeRequest: cluster_id: str diff --git a/scaleway/scaleway/k8s/v1/__init__.py b/scaleway/scaleway/k8s/v1/__init__.py index f27274871..6a088ca7f 100644 --- a/scaleway/scaleway/k8s/v1/__init__.py +++ b/scaleway/scaleway/k8s/v1/__init__.py @@ -24,6 +24,8 @@ from .types import ClusterAutoscalerConfig from .types import ClusterOpenIDConnectConfig from .types import Pool +from .types import ACLRuleRequest +from .types import ACLRule from .types import CreateClusterRequestAutoUpgrade from .types import CreateClusterRequestAutoscalerConfig from .types import CreateClusterRequestOpenIDConnectConfig @@ -39,10 +41,13 @@ from .types import UpdateClusterRequestAutoscalerConfig from .types import UpdateClusterRequestOpenIDConnectConfig from .types import UpdatePoolRequestUpgradePolicy +from .types import AddClusterACLRulesRequest +from .types import AddClusterACLRulesResponse from .types import AuthExternalNodeRequest from .types import CreateClusterRequest from .types import CreateExternalNodeRequest from .types import CreatePoolRequest +from .types import DeleteACLRuleRequest from .types import DeleteClusterRequest from .types import DeleteNodeRequest from .types import DeletePoolRequest @@ -54,6 +59,8 @@ from .types import GetNodeRequest from .types import GetPoolRequest from .types import GetVersionRequest +from .types import ListClusterACLRulesRequest +from .types import ListClusterACLRulesResponse from .types import ListClusterAvailableTypesRequest from .types import ListClusterAvailableTypesResponse from .types import ListClusterAvailableVersionsRequest @@ -73,6 +80,8 @@ from .types import RebootNodeRequest from .types import ReplaceNodeRequest from .types import ResetClusterAdminTokenRequest +from .types import SetClusterACLRulesRequest +from .types import SetClusterACLRulesResponse from .types import SetClusterTypeRequest from .types import UpdateClusterRequest from .types import UpdatePoolRequest @@ -105,6 +114,8 @@ "ClusterAutoscalerConfig", "ClusterOpenIDConnectConfig", "Pool", + "ACLRuleRequest", + "ACLRule", "CreateClusterRequestAutoUpgrade", "CreateClusterRequestAutoscalerConfig", "CreateClusterRequestOpenIDConnectConfig", @@ -120,10 +131,13 @@ "UpdateClusterRequestAutoscalerConfig", "UpdateClusterRequestOpenIDConnectConfig", "UpdatePoolRequestUpgradePolicy", + "AddClusterACLRulesRequest", + "AddClusterACLRulesResponse", "AuthExternalNodeRequest", "CreateClusterRequest", "CreateExternalNodeRequest", "CreatePoolRequest", + "DeleteACLRuleRequest", "DeleteClusterRequest", "DeleteNodeRequest", "DeletePoolRequest", @@ -135,6 +149,8 @@ "GetNodeRequest", "GetPoolRequest", "GetVersionRequest", + "ListClusterACLRulesRequest", + "ListClusterACLRulesResponse", "ListClusterAvailableTypesRequest", "ListClusterAvailableTypesResponse", "ListClusterAvailableVersionsRequest", @@ -154,6 +170,8 @@ "RebootNodeRequest", "ReplaceNodeRequest", "ResetClusterAdminTokenRequest", + "SetClusterACLRulesRequest", + "SetClusterACLRulesResponse", "SetClusterTypeRequest", "UpdateClusterRequest", "UpdatePoolRequest", diff --git a/scaleway/scaleway/k8s/v1/api.py b/scaleway/scaleway/k8s/v1/api.py index 7ed4433ed..e0270bac6 100644 --- a/scaleway/scaleway/k8s/v1/api.py +++ b/scaleway/scaleway/k8s/v1/api.py @@ -27,6 +27,10 @@ PoolStatus, PoolVolumeType, Runtime, + ACLRule, + ACLRuleRequest, + AddClusterACLRulesRequest, + AddClusterACLRulesResponse, Cluster, ClusterType, CreateClusterRequest, @@ -38,6 +42,7 @@ CreatePoolRequestUpgradePolicy, ExternalNode, ExternalNodeAuth, + ListClusterACLRulesResponse, ListClusterAvailableTypesResponse, ListClusterAvailableVersionsResponse, ListClusterTypesResponse, @@ -48,6 +53,8 @@ Node, NodeMetadata, Pool, + SetClusterACLRulesRequest, + SetClusterACLRulesResponse, SetClusterTypeRequest, UpdateClusterRequest, UpdateClusterRequestAutoUpgrade, @@ -69,8 +76,10 @@ unmarshal_Version, unmarshal_Cluster, unmarshal_Node, + unmarshal_AddClusterACLRulesResponse, unmarshal_ExternalNode, unmarshal_ExternalNodeAuth, + unmarshal_ListClusterACLRulesResponse, unmarshal_ListClusterAvailableTypesResponse, unmarshal_ListClusterAvailableVersionsResponse, unmarshal_ListClusterTypesResponse, @@ -79,8 +88,11 @@ unmarshal_ListPoolsResponse, unmarshal_ListVersionsResponse, unmarshal_NodeMetadata, + unmarshal_SetClusterACLRulesResponse, + marshal_AddClusterACLRulesRequest, marshal_CreateClusterRequest, marshal_CreatePoolRequest, + marshal_SetClusterACLRulesRequest, marshal_SetClusterTypeRequest, marshal_UpdateClusterRequest, marshal_UpdatePoolRequest, @@ -749,6 +761,204 @@ def migrate_cluster_to_sbscsi( self._throw_on_error(res) return unmarshal_Cluster(res.json()) + def list_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListClusterACLRulesResponse: + """ + List ACLs. + List ACLs for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be listed. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number for the returned ACLs. + :param page_size: Maximum number of ACLs per page. + :return: :class:`ListClusterACLRulesResponse ` + + Usage: + :: + + result = api.list_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "GET", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListClusterACLRulesResponse(res.json()) + + def list_cluster_acl_rules_all( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> List[ACLRule]: + """ + List ACLs. + List ACLs for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be listed. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number for the returned ACLs. + :param page_size: Maximum number of ACLs per page. + :return: :class:`List[ACLRule] ` + + Usage: + :: + + result = api.list_cluster_acl_rules_all( + cluster_id="example", + ) + """ + + return fetch_all_pages( + type=ListClusterACLRulesResponse, + key="rules", + fetcher=self.list_cluster_acl_rules, + args={ + "cluster_id": cluster_id, + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + def add_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + acls: Optional[List[ACLRuleRequest]] = None, + ) -> AddClusterACLRulesResponse: + """ + Add new ACLs. + Add new ACL rules for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be added. + :param region: Region to target. If none is passed will use default region from the config. + :param acls: ACLs to add. + :return: :class:`AddClusterACLRulesResponse ` + + Usage: + :: + + result = api.add_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "POST", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + body=marshal_AddClusterACLRulesRequest( + AddClusterACLRulesRequest( + cluster_id=cluster_id, + region=region, + acls=acls, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_AddClusterACLRulesResponse(res.json()) + + def set_cluster_acl_rules( + self, + *, + cluster_id: str, + region: Optional[Region] = None, + acls: Optional[List[ACLRuleRequest]] = None, + ) -> SetClusterACLRulesResponse: + """ + Set new ACLs. + Set new ACL rules for a specific cluster. + :param cluster_id: ID of the cluster whose ACLs will be set. + :param region: Region to target. If none is passed will use default region from the config. + :param acls: ACLs to set. + :return: :class:`SetClusterACLRulesResponse ` + + Usage: + :: + + result = api.set_cluster_acl_rules( + cluster_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_cluster_id = validate_path_param("cluster_id", cluster_id) + + res = self._request( + "PUT", + f"/k8s/v1/regions/{param_region}/clusters/{param_cluster_id}/acls", + body=marshal_SetClusterACLRulesRequest( + SetClusterACLRulesRequest( + cluster_id=cluster_id, + region=region, + acls=acls, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetClusterACLRulesResponse(res.json()) + + def delete_acl_rule( + self, + *, + acl_id: str, + region: Optional[Region] = None, + ) -> None: + """ + Delete an existing ACL. + :param acl_id: ID of the ACL rule to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_acl_rule( + acl_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_acl_id = validate_path_param("acl_id", acl_id) + + res = self._request( + "DELETE", + f"/k8s/v1/regions/{param_region}/acls/{param_acl_id}", + ) + + self._throw_on_error(res) + def list_pools( self, *, diff --git a/scaleway/scaleway/k8s/v1/marshalling.py b/scaleway/scaleway/k8s/v1/marshalling.py index 26991b89c..1095ed9ca 100644 --- a/scaleway/scaleway/k8s/v1/marshalling.py +++ b/scaleway/scaleway/k8s/v1/marshalling.py @@ -21,9 +21,12 @@ ClusterOpenIDConnectConfig, Cluster, Node, + ACLRule, + AddClusterACLRulesResponse, ExternalNodeCoreV1Taint, ExternalNode, ExternalNodeAuth, + ListClusterACLRulesResponse, ClusterType, ListClusterAvailableTypesResponse, ListClusterAvailableVersionsResponse, @@ -34,6 +37,9 @@ ListVersionsResponse, NodeMetadataCoreV1Taint, NodeMetadata, + SetClusterACLRulesResponse, + ACLRuleRequest, + AddClusterACLRulesRequest, CreateClusterRequestPoolConfigUpgradePolicy, CreateClusterRequestAutoUpgrade, CreateClusterRequestAutoscalerConfig, @@ -42,6 +48,7 @@ CreateClusterRequest, CreatePoolRequestUpgradePolicy, CreatePoolRequest, + SetClusterACLRulesRequest, SetClusterTypeRequest, UpdateClusterRequestAutoUpgrade, UpdateClusterRequestAutoscalerConfig, @@ -577,6 +584,54 @@ def unmarshal_Node(data: Any) -> Node: return Node(**args) +def unmarshal_ACLRule(data: Any) -> ACLRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ACLRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("description", None) + if field is not None: + args["description"] = field + + field = data.get("ip", None) + if field is not None: + args["ip"] = field + else: + args["ip"] = None + + field = data.get("scaleway_ranges", None) + if field is not None: + args["scaleway_ranges"] = field + else: + args["scaleway_ranges"] = None + + return ACLRule(**args) + + +def unmarshal_AddClusterACLRulesResponse(data: Any) -> AddClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'AddClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return AddClusterACLRulesResponse(**args) + + def unmarshal_ExternalNodeCoreV1Taint(data: Any) -> ExternalNodeCoreV1Taint: if not isinstance(data, dict): raise TypeError( @@ -686,6 +741,27 @@ def unmarshal_ExternalNodeAuth(data: Any) -> ExternalNodeAuth: return ExternalNodeAuth(**args) +def unmarshal_ListClusterACLRulesResponse(data: Any) -> ListClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return ListClusterACLRulesResponse(**args) + + def unmarshal_ClusterType(data: Any) -> ClusterType: if not isinstance(data, dict): raise TypeError( @@ -976,6 +1052,57 @@ def unmarshal_NodeMetadata(data: Any) -> NodeMetadata: return NodeMetadata(**args) +def unmarshal_SetClusterACLRulesResponse(data: Any) -> SetClusterACLRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetClusterACLRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("rules", None) + if field is not None: + args["rules"] = ( + [unmarshal_ACLRule(v) for v in field] if field is not None else None + ) + + return SetClusterACLRulesResponse(**args) + + +def marshal_ACLRuleRequest( + request: ACLRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("ip", request.ip), + OneOfPossibility("scaleway_ranges", request.scaleway_ranges), + ] + ), + ) + + if request.description is not None: + output["description"] = request.description + + return output + + +def marshal_AddClusterACLRulesRequest( + request: AddClusterACLRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.acls is not None: + output["acls"] = [ + marshal_ACLRuleRequest(item, defaults) for item in request.acls + ] + + return output + + def marshal_MaintenanceWindow( request: MaintenanceWindow, defaults: ProfileDefaults, @@ -1309,6 +1436,20 @@ def marshal_CreatePoolRequest( return output +def marshal_SetClusterACLRulesRequest( + request: SetClusterACLRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.acls is not None: + output["acls"] = [ + marshal_ACLRuleRequest(item, defaults) for item in request.acls + ] + + return output + + def marshal_SetClusterTypeRequest( request: SetClusterTypeRequest, defaults: ProfileDefaults, diff --git a/scaleway/scaleway/k8s/v1/types.py b/scaleway/scaleway/k8s/v1/types.py index 6d1944b53..2df9f07b3 100644 --- a/scaleway/scaleway/k8s/v1/types.py +++ b/scaleway/scaleway/k8s/v1/types.py @@ -441,6 +441,35 @@ class Pool: """ +@dataclass +class ACLRuleRequest: + description: str + """ + Description of the ACL. + """ + + ip: Optional[str] + + scaleway_ranges: Optional[bool] + + +@dataclass +class ACLRule: + id: str + """ + ID of the ACL rule. + """ + + description: str + """ + Description of the ACL. + """ + + ip: Optional[str] + + scaleway_ranges: Optional[bool] + + @dataclass class CreateClusterRequestAutoUpgrade: enable: bool @@ -1066,6 +1095,32 @@ class UpdatePoolRequestUpgradePolicy: max_surge: Optional[int] +@dataclass +class AddClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be added. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + acls: Optional[List[ACLRuleRequest]] + """ + ACLs to add. + """ + + +@dataclass +class AddClusterACLRulesResponse: + rules: List[ACLRule] + """ + ACLs that were added. + """ + + @dataclass class AuthExternalNodeRequest: pool_id: str @@ -1264,6 +1319,19 @@ class CreatePoolRequest: """ +@dataclass +class DeleteACLRuleRequest: + acl_id: str + """ + ID of the ACL rule to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class DeleteClusterRequest: cluster_id: str @@ -1432,6 +1500,42 @@ class GetVersionRequest: """ +@dataclass +class ListClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be listed. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] + """ + Page number for the returned ACLs. + """ + + page_size: Optional[int] + """ + Maximum number of ACLs per page. + """ + + +@dataclass +class ListClusterACLRulesResponse: + total_count: int + """ + Total number of ACLs that exist for the cluster. + """ + + rules: List[ACLRule] + """ + Paginated returned ACLs. + """ + + @dataclass class ListClusterAvailableTypesRequest: cluster_id: str @@ -1782,6 +1886,32 @@ class ResetClusterAdminTokenRequest: """ +@dataclass +class SetClusterACLRulesRequest: + cluster_id: str + """ + ID of the cluster whose ACLs will be set. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + acls: Optional[List[ACLRuleRequest]] + """ + ACLs to set. + """ + + +@dataclass +class SetClusterACLRulesResponse: + rules: List[ACLRule] + """ + ACLs that were set. + """ + + @dataclass class SetClusterTypeRequest: cluster_id: str From f3055502fde74b634c34279ac35406f25d214ec4 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 08:32:52 +0100 Subject: [PATCH 5/7] feat(mongodb): fix typo the CreateUser url (#727) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- scaleway-async/scaleway_async/mongodb/v1alpha1/api.py | 3 +-- scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py | 3 +++ scaleway/scaleway/mongodb/v1alpha1/api.py | 3 +-- scaleway/scaleway/mongodb/v1alpha1/marshalling.py | 3 +++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py index 6f9df35d7..980843a92 100644 --- a/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/api.py @@ -1103,11 +1103,10 @@ async def create_user( "region", region or self.client.default_region ) param_instance_id = validate_path_param("instance_id", instance_id) - param_name = validate_path_param("name", name) res = self._request( "POST", - f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users", body=marshal_CreateUserRequest( CreateUserRequest( instance_id=instance_id, diff --git a/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py index a59cdf460..01055557c 100644 --- a/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py +++ b/scaleway-async/scaleway_async/mongodb/v1alpha1/marshalling.py @@ -715,6 +715,9 @@ def marshal_CreateUserRequest( ) -> Dict[str, Any]: output: Dict[str, Any] = {} + if request.name is not None: + output["name"] = request.name + if request.password is not None: output["password"] = request.password diff --git a/scaleway/scaleway/mongodb/v1alpha1/api.py b/scaleway/scaleway/mongodb/v1alpha1/api.py index f1388166c..dfb7c6236 100644 --- a/scaleway/scaleway/mongodb/v1alpha1/api.py +++ b/scaleway/scaleway/mongodb/v1alpha1/api.py @@ -1099,11 +1099,10 @@ def create_user( "region", region or self.client.default_region ) param_instance_id = validate_path_param("instance_id", instance_id) - param_name = validate_path_param("name", name) res = self._request( "POST", - f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users/{param_name}", + f"/mongodb/v1alpha1/regions/{param_region}/instances/{param_instance_id}/users", body=marshal_CreateUserRequest( CreateUserRequest( instance_id=instance_id, diff --git a/scaleway/scaleway/mongodb/v1alpha1/marshalling.py b/scaleway/scaleway/mongodb/v1alpha1/marshalling.py index a59cdf460..01055557c 100644 --- a/scaleway/scaleway/mongodb/v1alpha1/marshalling.py +++ b/scaleway/scaleway/mongodb/v1alpha1/marshalling.py @@ -715,6 +715,9 @@ def marshal_CreateUserRequest( ) -> Dict[str, Any]: output: Dict[str, Any] = {} + if request.name is not None: + output["name"] = request.name + if request.password is not None: output["password"] = request.password From f2985d44a549bb5db7d945582301c2947cf687dc Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 08:38:22 +0100 Subject: [PATCH 6/7] feat(iam): add LockUser and UnlockUser method (#728) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- .../scaleway_async/iam/v1alpha1/__init__.py | 4 ++ .../scaleway_async/iam/v1alpha1/api.py | 59 +++++++++++++++++++ .../scaleway_async/iam/v1alpha1/types.py | 10 ++++ scaleway/scaleway/iam/v1alpha1/__init__.py | 4 ++ scaleway/scaleway/iam/v1alpha1/api.py | 59 +++++++++++++++++++ scaleway/scaleway/iam/v1alpha1/types.py | 10 ++++ 6 files changed, 146 insertions(+) diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py index a59f33617..bb4d8d674 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/__init__.py @@ -78,10 +78,12 @@ from .types import ListSSHKeysResponse from .types import ListUsersRequest from .types import ListUsersResponse +from .types import LockUserRequest from .types import RemoveGroupMemberRequest from .types import SetGroupMembersRequest from .types import SetRulesRequest from .types import SetRulesResponse +from .types import UnlockUserRequest from .types import UpdateAPIKeyRequest from .types import UpdateApplicationRequest from .types import UpdateGroupRequest @@ -170,10 +172,12 @@ "ListSSHKeysResponse", "ListUsersRequest", "ListUsersResponse", + "LockUserRequest", "RemoveGroupMemberRequest", "SetGroupMembersRequest", "SetRulesRequest", "SetRulesResponse", + "UnlockUserRequest", "UpdateAPIKeyRequest", "UpdateApplicationRequest", "UpdateGroupRequest", diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index d01f497fc..fa99e8af5 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -617,6 +617,65 @@ async def update_user_password( self._throw_on_error(res) return unmarshal_User(res.json()) + async def lock_user( + self, + *, + user_id: str, + ) -> User: + """ + Lock a user. + Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed. + :param user_id: + :return: :class:`User ` + + Usage: + :: + + result = await api.lock_user( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/lock", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + + async def unlock_user( + self, + *, + user_id: str, + ) -> User: + """ + Unlock a user. + :param user_id: + :return: :class:`User ` + + Usage: + :: + + result = await api.unlock_user( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/unlock", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + async def list_applications( self, *, diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 5c1d9df71..1342fa8a3 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -1691,6 +1691,11 @@ class ListUsersResponse: """ +@dataclass +class LockUserRequest: + user_id: str + + @dataclass class RemoveGroupMemberRequest: group_id: str @@ -1733,6 +1738,11 @@ class SetRulesResponse: """ +@dataclass +class UnlockUserRequest: + user_id: str + + @dataclass class UpdateAPIKeyRequest: access_key: str diff --git a/scaleway/scaleway/iam/v1alpha1/__init__.py b/scaleway/scaleway/iam/v1alpha1/__init__.py index a59f33617..bb4d8d674 100644 --- a/scaleway/scaleway/iam/v1alpha1/__init__.py +++ b/scaleway/scaleway/iam/v1alpha1/__init__.py @@ -78,10 +78,12 @@ from .types import ListSSHKeysResponse from .types import ListUsersRequest from .types import ListUsersResponse +from .types import LockUserRequest from .types import RemoveGroupMemberRequest from .types import SetGroupMembersRequest from .types import SetRulesRequest from .types import SetRulesResponse +from .types import UnlockUserRequest from .types import UpdateAPIKeyRequest from .types import UpdateApplicationRequest from .types import UpdateGroupRequest @@ -170,10 +172,12 @@ "ListSSHKeysResponse", "ListUsersRequest", "ListUsersResponse", + "LockUserRequest", "RemoveGroupMemberRequest", "SetGroupMembersRequest", "SetRulesRequest", "SetRulesResponse", + "UnlockUserRequest", "UpdateAPIKeyRequest", "UpdateApplicationRequest", "UpdateGroupRequest", diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 602db99d8..67238fc42 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -617,6 +617,65 @@ def update_user_password( self._throw_on_error(res) return unmarshal_User(res.json()) + def lock_user( + self, + *, + user_id: str, + ) -> User: + """ + Lock a user. + Lock a user. Note that a locked user cannot log in or use API keys until the locked status is removed. + :param user_id: + :return: :class:`User ` + + Usage: + :: + + result = api.lock_user( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/lock", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + + def unlock_user( + self, + *, + user_id: str, + ) -> User: + """ + Unlock a user. + :param user_id: + :return: :class:`User ` + + Usage: + :: + + result = api.unlock_user( + user_id="example", + ) + """ + + param_user_id = validate_path_param("user_id", user_id) + + res = self._request( + "POST", + f"/iam/v1alpha1/users/{param_user_id}/unlock", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_User(res.json()) + def list_applications( self, *, diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 5c1d9df71..1342fa8a3 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -1691,6 +1691,11 @@ class ListUsersResponse: """ +@dataclass +class LockUserRequest: + user_id: str + + @dataclass class RemoveGroupMemberRequest: group_id: str @@ -1733,6 +1738,11 @@ class SetRulesResponse: """ +@dataclass +class UnlockUserRequest: + user_id: str + + @dataclass class UpdateAPIKeyRequest: access_key: str From b27ce4ba28dd54ff989614c747911809dda02bd9 Mon Sep 17 00:00:00 2001 From: Scaleway Bot Date: Mon, 4 Nov 2024 10:03:12 +0100 Subject: [PATCH 7/7] feat(iam): add doc for UpdateUserPassword (#729) Co-authored-by: Laure-di <62625835+Laure-di@users.noreply.github.com> --- scaleway-async/scaleway_async/iam/v1alpha1/api.py | 7 ++++--- scaleway-async/scaleway_async/iam/v1alpha1/types.py | 9 +++++++++ scaleway/scaleway/iam/v1alpha1/api.py | 7 ++++--- scaleway/scaleway/iam/v1alpha1/types.py | 9 +++++++++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/api.py b/scaleway-async/scaleway_async/iam/v1alpha1/api.py index fa99e8af5..5141b99b5 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/api.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/api.py @@ -584,9 +584,10 @@ async def update_user_password( send_email: bool, ) -> User: """ - :param user_id: - :param password: - :param send_email: + Update an user's password. + :param user_id: ID of the user to update. + :param password: The new password. + :param send_email: Whether or not to send an email alerting the user their password has changed. :return: :class:`User ` Usage: diff --git a/scaleway-async/scaleway_async/iam/v1alpha1/types.py b/scaleway-async/scaleway_async/iam/v1alpha1/types.py index 1342fa8a3..63d8753df 100644 --- a/scaleway-async/scaleway_async/iam/v1alpha1/types.py +++ b/scaleway-async/scaleway_async/iam/v1alpha1/types.py @@ -1856,10 +1856,19 @@ class UpdateSSHKeyRequest: @dataclass class UpdateUserPasswordRequest: user_id: str + """ + ID of the user to update. + """ password: str + """ + The new password. + """ send_email: bool + """ + Whether or not to send an email alerting the user their password has changed. + """ @dataclass diff --git a/scaleway/scaleway/iam/v1alpha1/api.py b/scaleway/scaleway/iam/v1alpha1/api.py index 67238fc42..5b5758822 100644 --- a/scaleway/scaleway/iam/v1alpha1/api.py +++ b/scaleway/scaleway/iam/v1alpha1/api.py @@ -584,9 +584,10 @@ def update_user_password( send_email: bool, ) -> User: """ - :param user_id: - :param password: - :param send_email: + Update an user's password. + :param user_id: ID of the user to update. + :param password: The new password. + :param send_email: Whether or not to send an email alerting the user their password has changed. :return: :class:`User ` Usage: diff --git a/scaleway/scaleway/iam/v1alpha1/types.py b/scaleway/scaleway/iam/v1alpha1/types.py index 1342fa8a3..63d8753df 100644 --- a/scaleway/scaleway/iam/v1alpha1/types.py +++ b/scaleway/scaleway/iam/v1alpha1/types.py @@ -1856,10 +1856,19 @@ class UpdateSSHKeyRequest: @dataclass class UpdateUserPasswordRequest: user_id: str + """ + ID of the user to update. + """ password: str + """ + The new password. + """ send_email: bool + """ + Whether or not to send an email alerting the user their password has changed. + """ @dataclass