Skip to content

Commit a6fa174

Browse files
authored
feat(containers): add VPC integration feature flag (#991)
1 parent 191aadc commit a6fa174

File tree

6 files changed

+108
-24
lines changed

6 files changed

+108
-24
lines changed

scaleway-async/scaleway_async/container/v1beta1/api.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ async def wait_for_namespace(
267267
async def create_namespace(
268268
self,
269269
*,
270+
activate_vpc_integration: bool,
270271
region: Optional[ScwRegion] = None,
271272
name: Optional[str] = None,
272273
environment_variables: Optional[Dict[str, str]] = None,
@@ -278,6 +279,7 @@ async def create_namespace(
278279
"""
279280
Create a new namespace.
280281
Create a new namespace in a specified region.
282+
:param activate_vpc_integration:
281283
:param region: Region to target. If none is passed will use default region from the config.
282284
:param name: Name of the namespace to create.
283285
:param environment_variables: Environment variables of the namespace to create.
@@ -290,7 +292,9 @@ async def create_namespace(
290292
Usage:
291293
::
292294
293-
result = await api.create_namespace()
295+
result = await api.create_namespace(
296+
activate_vpc_integration=False,
297+
)
294298
"""
295299

296300
param_region = validate_path_param(
@@ -302,6 +306,7 @@ async def create_namespace(
302306
f"/containers/v1beta1/regions/{param_region}/namespaces",
303307
body=marshal_CreateNamespaceRequest(
304308
CreateNamespaceRequest(
309+
activate_vpc_integration=activate_vpc_integration,
305310
region=region,
306311
name=name or random_name(prefix="cns"),
307312
environment_variables=environment_variables,
@@ -606,6 +611,7 @@ async def create_container(
606611
scaling_option: Optional[ContainerScalingOption] = None,
607612
health_check: Optional[ContainerHealthCheckSpec] = None,
608613
tags: Optional[List[str]] = None,
614+
private_network_id: Optional[str] = None,
609615
) -> Container:
610616
"""
611617
Create a new container.
@@ -637,6 +643,7 @@ async def create_container(
637643
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
638644
:param health_check: Health check configuration of the container.
639645
:param tags: Tags of the Serverless Container.
646+
:param private_network_id:
640647
:return: :class:`Container <Container>`
641648
642649
Usage:
@@ -679,6 +686,7 @@ async def create_container(
679686
scaling_option=scaling_option,
680687
health_check=health_check,
681688
tags=tags,
689+
private_network_id=private_network_id,
682690
),
683691
self.client,
684692
),
@@ -712,6 +720,7 @@ async def update_container(
712720
scaling_option: Optional[ContainerScalingOption] = None,
713721
health_check: Optional[ContainerHealthCheckSpec] = None,
714722
tags: Optional[List[str]] = None,
723+
private_network_id: Optional[str] = None,
715724
) -> Container:
716725
"""
717726
Update an existing container.
@@ -743,6 +752,7 @@ async def update_container(
743752
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
744753
:param health_check: Health check configuration of the container.
745754
:param tags: Tags of the Serverless Container.
755+
:param private_network_id:
746756
:return: :class:`Container <Container>`
747757
748758
Usage:
@@ -785,6 +795,7 @@ async def update_container(
785795
scaling_option=scaling_option,
786796
health_check=health_check,
787797
tags=tags,
798+
private_network_id=private_network_id,
788799
),
789800
self.client,
790801
),

scaleway-async/scaleway_async/container/v1beta1/marshalling.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ def unmarshal_Container(data: Any) -> Container:
303303
else:
304304
args["ready_at"] = None
305305

306+
field = data.get("private_network_id", None)
307+
if field is not None:
308+
args["private_network_id"] = field
309+
else:
310+
args["private_network_id"] = None
311+
306312
return Container(**args)
307313

308314

@@ -416,6 +422,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
416422
if field is not None:
417423
args["registry_namespace_id"] = field
418424

425+
field = data.get("error_message", None)
426+
if field is not None:
427+
args["error_message"] = field
428+
else:
429+
args["error_message"] = None
430+
419431
field = data.get("registry_endpoint", None)
420432
if field is not None:
421433
args["registry_endpoint"] = field
@@ -436,12 +448,6 @@ def unmarshal_Namespace(data: Any) -> Namespace:
436448
if field is not None:
437449
args["tags"] = field
438450

439-
field = data.get("error_message", None)
440-
if field is not None:
441-
args["error_message"] = field
442-
else:
443-
args["error_message"] = None
444-
445451
field = data.get("description", None)
446452
if field is not None:
447453
args["description"] = field
@@ -460,6 +466,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
460466
else:
461467
args["updated_at"] = None
462468

469+
field = data.get("vpc_integration_activated", None)
470+
if field is not None:
471+
args["vpc_integration_activated"] = field
472+
else:
473+
args["vpc_integration_activated"] = None
474+
463475
return Namespace(**args)
464476

465477

@@ -948,6 +960,9 @@ def marshal_CreateContainerRequest(
948960
if request.tags is not None:
949961
output["tags"] = request.tags
950962

963+
if request.private_network_id is not None:
964+
output["private_network_id"] = request.private_network_id
965+
951966
return output
952967

953968

@@ -993,6 +1008,9 @@ def marshal_CreateNamespaceRequest(
9931008
) -> Dict[str, Any]:
9941009
output: Dict[str, Any] = {}
9951010

1011+
if request.activate_vpc_integration is not None:
1012+
output["activate_vpc_integration"] = request.activate_vpc_integration
1013+
9961014
if request.name is not None:
9971015
output["name"] = request.name
9981016

@@ -1200,6 +1218,9 @@ def marshal_UpdateContainerRequest(
12001218
if request.tags is not None:
12011219
output["tags"] = request.tags
12021220

1221+
if request.private_network_id is not None:
1222+
output["private_network_id"] = request.private_network_id
1223+
12031224
return output
12041225

12051226

scaleway-async/scaleway_async/container/v1beta1/types.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,8 @@ class Container:
511511
Last date when the container was successfully deployed and set to ready.
512512
"""
513513

514+
private_network_id: Optional[str]
515+
514516

515517
@dataclass
516518
class Cron:
@@ -615,6 +617,11 @@ class Namespace:
615617
UUID of the registry namespace.
616618
"""
617619

620+
error_message: Optional[str]
621+
"""
622+
Last error message of the namesace.
623+
"""
624+
618625
registry_endpoint: str
619626
"""
620627
Registry endpoint of the namespace.
@@ -635,11 +642,6 @@ class Namespace:
635642
List of tags applied to the Serverless Container Namespace.
636643
"""
637644

638-
error_message: Optional[str]
639-
"""
640-
Last error message of the namesace.
641-
"""
642-
643645
description: Optional[str]
644646
"""
645647
Description of the endpoint.
@@ -655,6 +657,8 @@ class Namespace:
655657
Last update date of the namespace.
656658
"""
657659

660+
vpc_integration_activated: Optional[bool]
661+
658662

659663
@dataclass
660664
class Token:
@@ -861,6 +865,8 @@ class CreateContainerRequest:
861865
Tags of the Serverless Container.
862866
"""
863867

868+
private_network_id: Optional[str]
869+
864870

865871
@dataclass
866872
class CreateCronRequest:
@@ -910,6 +916,8 @@ class CreateDomainRequest:
910916

911917
@dataclass
912918
class CreateNamespaceRequest:
919+
activate_vpc_integration: bool
920+
913921
region: Optional[ScwRegion]
914922
"""
915923
Region to target. If none is passed will use default region from the config.
@@ -1545,6 +1553,8 @@ class UpdateContainerRequest:
15451553
Tags of the Serverless Container.
15461554
"""
15471555

1556+
private_network_id: Optional[str]
1557+
15481558

15491559
@dataclass
15501560
class UpdateCronRequest:

scaleway/scaleway/container/v1beta1/api.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ def wait_for_namespace(
265265
def create_namespace(
266266
self,
267267
*,
268+
activate_vpc_integration: bool,
268269
region: Optional[ScwRegion] = None,
269270
name: Optional[str] = None,
270271
environment_variables: Optional[Dict[str, str]] = None,
@@ -276,6 +277,7 @@ def create_namespace(
276277
"""
277278
Create a new namespace.
278279
Create a new namespace in a specified region.
280+
:param activate_vpc_integration:
279281
:param region: Region to target. If none is passed will use default region from the config.
280282
:param name: Name of the namespace to create.
281283
:param environment_variables: Environment variables of the namespace to create.
@@ -288,7 +290,9 @@ def create_namespace(
288290
Usage:
289291
::
290292
291-
result = api.create_namespace()
293+
result = api.create_namespace(
294+
activate_vpc_integration=False,
295+
)
292296
"""
293297

294298
param_region = validate_path_param(
@@ -300,6 +304,7 @@ def create_namespace(
300304
f"/containers/v1beta1/regions/{param_region}/namespaces",
301305
body=marshal_CreateNamespaceRequest(
302306
CreateNamespaceRequest(
307+
activate_vpc_integration=activate_vpc_integration,
303308
region=region,
304309
name=name or random_name(prefix="cns"),
305310
environment_variables=environment_variables,
@@ -602,6 +607,7 @@ def create_container(
602607
scaling_option: Optional[ContainerScalingOption] = None,
603608
health_check: Optional[ContainerHealthCheckSpec] = None,
604609
tags: Optional[List[str]] = None,
610+
private_network_id: Optional[str] = None,
605611
) -> Container:
606612
"""
607613
Create a new container.
@@ -633,6 +639,7 @@ def create_container(
633639
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
634640
:param health_check: Health check configuration of the container.
635641
:param tags: Tags of the Serverless Container.
642+
:param private_network_id:
636643
:return: :class:`Container <Container>`
637644
638645
Usage:
@@ -675,6 +682,7 @@ def create_container(
675682
scaling_option=scaling_option,
676683
health_check=health_check,
677684
tags=tags,
685+
private_network_id=private_network_id,
678686
),
679687
self.client,
680688
),
@@ -708,6 +716,7 @@ def update_container(
708716
scaling_option: Optional[ContainerScalingOption] = None,
709717
health_check: Optional[ContainerHealthCheckSpec] = None,
710718
tags: Optional[List[str]] = None,
719+
private_network_id: Optional[str] = None,
711720
) -> Container:
712721
"""
713722
Update an existing container.
@@ -739,6 +748,7 @@ def update_container(
739748
- memory_usage_threshold: Scale depending on the memory usage of a container instance.
740749
:param health_check: Health check configuration of the container.
741750
:param tags: Tags of the Serverless Container.
751+
:param private_network_id:
742752
:return: :class:`Container <Container>`
743753
744754
Usage:
@@ -781,6 +791,7 @@ def update_container(
781791
scaling_option=scaling_option,
782792
health_check=health_check,
783793
tags=tags,
794+
private_network_id=private_network_id,
784795
),
785796
self.client,
786797
),

scaleway/scaleway/container/v1beta1/marshalling.py

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,12 @@ def unmarshal_Container(data: Any) -> Container:
303303
else:
304304
args["ready_at"] = None
305305

306+
field = data.get("private_network_id", None)
307+
if field is not None:
308+
args["private_network_id"] = field
309+
else:
310+
args["private_network_id"] = None
311+
306312
return Container(**args)
307313

308314

@@ -416,6 +422,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
416422
if field is not None:
417423
args["registry_namespace_id"] = field
418424

425+
field = data.get("error_message", None)
426+
if field is not None:
427+
args["error_message"] = field
428+
else:
429+
args["error_message"] = None
430+
419431
field = data.get("registry_endpoint", None)
420432
if field is not None:
421433
args["registry_endpoint"] = field
@@ -436,12 +448,6 @@ def unmarshal_Namespace(data: Any) -> Namespace:
436448
if field is not None:
437449
args["tags"] = field
438450

439-
field = data.get("error_message", None)
440-
if field is not None:
441-
args["error_message"] = field
442-
else:
443-
args["error_message"] = None
444-
445451
field = data.get("description", None)
446452
if field is not None:
447453
args["description"] = field
@@ -460,6 +466,12 @@ def unmarshal_Namespace(data: Any) -> Namespace:
460466
else:
461467
args["updated_at"] = None
462468

469+
field = data.get("vpc_integration_activated", None)
470+
if field is not None:
471+
args["vpc_integration_activated"] = field
472+
else:
473+
args["vpc_integration_activated"] = None
474+
463475
return Namespace(**args)
464476

465477

@@ -948,6 +960,9 @@ def marshal_CreateContainerRequest(
948960
if request.tags is not None:
949961
output["tags"] = request.tags
950962

963+
if request.private_network_id is not None:
964+
output["private_network_id"] = request.private_network_id
965+
951966
return output
952967

953968

@@ -993,6 +1008,9 @@ def marshal_CreateNamespaceRequest(
9931008
) -> Dict[str, Any]:
9941009
output: Dict[str, Any] = {}
9951010

1011+
if request.activate_vpc_integration is not None:
1012+
output["activate_vpc_integration"] = request.activate_vpc_integration
1013+
9961014
if request.name is not None:
9971015
output["name"] = request.name
9981016

@@ -1200,6 +1218,9 @@ def marshal_UpdateContainerRequest(
12001218
if request.tags is not None:
12011219
output["tags"] = request.tags
12021220

1221+
if request.private_network_id is not None:
1222+
output["private_network_id"] = request.private_network_id
1223+
12031224
return output
12041225

12051226

0 commit comments

Comments
 (0)