Skip to content

Commit 506ea6c

Browse files
authored
feat(vpc/v2): add property to enable or disable routing in a VPC (#448)
1 parent 9399ad6 commit 506ea6c

File tree

6 files changed

+82
-14
lines changed

6 files changed

+82
-14
lines changed

scaleway-async/scaleway_async/vpc/v2/api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ async def list_vp_cs(
6969
organization_id: Optional[str] = None,
7070
project_id: Optional[str] = None,
7171
is_default: Optional[bool] = None,
72+
routing_enabled: Optional[bool] = None,
7273
) -> ListVPCsResponse:
7374
"""
7475
List VPCs.
@@ -82,6 +83,7 @@ async def list_vp_cs(
8283
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
8384
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
8485
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
86+
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
8587
:return: :class:`ListVPCsResponse <ListVPCsResponse>`
8688
8789
Usage:
@@ -106,6 +108,7 @@ async def list_vp_cs(
106108
"page": page,
107109
"page_size": page_size or self.client.default_page_size,
108110
"project_id": project_id or self.client.default_project_id,
111+
"routing_enabled": routing_enabled,
109112
"tags": tags,
110113
},
111114
)
@@ -125,6 +128,7 @@ async def list_vp_cs_all(
125128
organization_id: Optional[str] = None,
126129
project_id: Optional[str] = None,
127130
is_default: Optional[bool] = None,
131+
routing_enabled: Optional[bool] = None,
128132
) -> List[VPC]:
129133
"""
130134
List VPCs.
@@ -138,6 +142,7 @@ async def list_vp_cs_all(
138142
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
139143
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
140144
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
145+
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
141146
:return: :class:`List[ListVPCsResponse] <List[ListVPCsResponse]>`
142147
143148
Usage:
@@ -160,12 +165,14 @@ async def list_vp_cs_all(
160165
"organization_id": organization_id,
161166
"project_id": project_id,
162167
"is_default": is_default,
168+
"routing_enabled": routing_enabled,
163169
},
164170
)
165171

166172
async def create_vpc(
167173
self,
168174
*,
175+
enable_routing: bool,
169176
region: Optional[Region] = None,
170177
name: Optional[str] = None,
171178
project_id: Optional[str] = None,
@@ -178,12 +185,13 @@ async def create_vpc(
178185
:param name: Name for the VPC.
179186
:param project_id: Scaleway Project in which to create the VPC.
180187
:param tags: Tags for the VPC.
188+
:param enable_routing: Enable routing between Private Networks in the VPC.
181189
:return: :class:`VPC <VPC>`
182190
183191
Usage:
184192
::
185193
186-
result = await api.create_vpc()
194+
result = await api.create_vpc(enable_routing=True)
187195
"""
188196

189197
param_region = validate_path_param(
@@ -195,6 +203,7 @@ async def create_vpc(
195203
f"/vpc/v2/regions/{param_region}/vpcs",
196204
body=marshal_CreateVPCRequest(
197205
CreateVPCRequest(
206+
enable_routing=enable_routing,
198207
region=region,
199208
name=name or random_name(prefix="vpc"),
200209
project_id=project_id,

scaleway-async/scaleway_async/vpc/v2/marshalling.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def unmarshal_VPC(data: Any) -> VPC:
130130
field = data.get("region", None)
131131
args["region"] = field
132132

133+
field = data.get("routing_enabled", None)
134+
args["routing_enabled"] = field
135+
133136
field = data.get("tags", None)
134137
args["tags"] = field
135138

@@ -259,6 +262,9 @@ def marshal_CreateVPCRequest(
259262
) -> Dict[str, Any]:
260263
output: Dict[str, Any] = {}
261264

265+
if request.enable_routing is not None:
266+
output["enable_routing"] = request.enable_routing
267+
262268
if request.name is not None:
263269
output["name"] = request.name
264270

@@ -293,16 +299,20 @@ def marshal_MigrateZonalPrivateNetworksRequest(
293299
[
294300
OneOfPossibility(
295301
"project_id",
296-
request.project_id or defaults.default_project_id
297-
if request.project_id is not None
298-
else None,
302+
(
303+
request.project_id or defaults.default_project_id
304+
if request.project_id is not None
305+
else None
306+
),
299307
defaults.default_project_id,
300308
),
301309
OneOfPossibility(
302310
"organization_id",
303-
request.organization_id or defaults.default_organization_id
304-
if request.organization_id is not None
305-
else None,
311+
(
312+
request.organization_id or defaults.default_organization_id
313+
if request.organization_id is not None
314+
else None
315+
),
306316
defaults.default_organization_id,
307317
),
308318
]

scaleway-async/scaleway_async/vpc/v2/types.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ class VPC:
209209
Number of Private Networks within this VPC.
210210
"""
211211

212+
routing_enabled: bool
213+
"""
214+
Defines whether the VPC routes traffic between its Private Networks.
215+
"""
216+
212217

213218
@dataclass
214219
class ListVPCsRequest:
@@ -257,6 +262,11 @@ class ListVPCsRequest:
257262
Defines whether to filter only for VPCs which are the default one for their Project.
258263
"""
259264

265+
routing_enabled: Optional[bool]
266+
"""
267+
Defines whether to filter only for VPCs which route traffic between their Private Networks.
268+
"""
269+
260270

261271
@dataclass
262272
class CreateVPCRequest:
@@ -280,6 +290,11 @@ class CreateVPCRequest:
280290
Tags for the VPC.
281291
"""
282292

293+
enable_routing: bool
294+
"""
295+
Enable routing between Private Networks in the VPC.
296+
"""
297+
283298

284299
@dataclass
285300
class GetVPCRequest:

scaleway/scaleway/vpc/v2/api.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ def list_vp_cs(
6969
organization_id: Optional[str] = None,
7070
project_id: Optional[str] = None,
7171
is_default: Optional[bool] = None,
72+
routing_enabled: Optional[bool] = None,
7273
) -> ListVPCsResponse:
7374
"""
7475
List VPCs.
@@ -82,6 +83,7 @@ def list_vp_cs(
8283
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
8384
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
8485
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
86+
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
8587
:return: :class:`ListVPCsResponse <ListVPCsResponse>`
8688
8789
Usage:
@@ -106,6 +108,7 @@ def list_vp_cs(
106108
"page": page,
107109
"page_size": page_size or self.client.default_page_size,
108110
"project_id": project_id or self.client.default_project_id,
111+
"routing_enabled": routing_enabled,
109112
"tags": tags,
110113
},
111114
)
@@ -125,6 +128,7 @@ def list_vp_cs_all(
125128
organization_id: Optional[str] = None,
126129
project_id: Optional[str] = None,
127130
is_default: Optional[bool] = None,
131+
routing_enabled: Optional[bool] = None,
128132
) -> List[VPC]:
129133
"""
130134
List VPCs.
@@ -138,6 +142,7 @@ def list_vp_cs_all(
138142
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
139143
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
140144
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
145+
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
141146
:return: :class:`List[ListVPCsResponse] <List[ListVPCsResponse]>`
142147
143148
Usage:
@@ -160,12 +165,14 @@ def list_vp_cs_all(
160165
"organization_id": organization_id,
161166
"project_id": project_id,
162167
"is_default": is_default,
168+
"routing_enabled": routing_enabled,
163169
},
164170
)
165171

166172
def create_vpc(
167173
self,
168174
*,
175+
enable_routing: bool,
169176
region: Optional[Region] = None,
170177
name: Optional[str] = None,
171178
project_id: Optional[str] = None,
@@ -178,12 +185,13 @@ def create_vpc(
178185
:param name: Name for the VPC.
179186
:param project_id: Scaleway Project in which to create the VPC.
180187
:param tags: Tags for the VPC.
188+
:param enable_routing: Enable routing between Private Networks in the VPC.
181189
:return: :class:`VPC <VPC>`
182190
183191
Usage:
184192
::
185193
186-
result = api.create_vpc()
194+
result = api.create_vpc(enable_routing=True)
187195
"""
188196

189197
param_region = validate_path_param(
@@ -195,6 +203,7 @@ def create_vpc(
195203
f"/vpc/v2/regions/{param_region}/vpcs",
196204
body=marshal_CreateVPCRequest(
197205
CreateVPCRequest(
206+
enable_routing=enable_routing,
198207
region=region,
199208
name=name or random_name(prefix="vpc"),
200209
project_id=project_id,

scaleway/scaleway/vpc/v2/marshalling.py

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,9 @@ def unmarshal_VPC(data: Any) -> VPC:
130130
field = data.get("region", None)
131131
args["region"] = field
132132

133+
field = data.get("routing_enabled", None)
134+
args["routing_enabled"] = field
135+
133136
field = data.get("tags", None)
134137
args["tags"] = field
135138

@@ -259,6 +262,9 @@ def marshal_CreateVPCRequest(
259262
) -> Dict[str, Any]:
260263
output: Dict[str, Any] = {}
261264

265+
if request.enable_routing is not None:
266+
output["enable_routing"] = request.enable_routing
267+
262268
if request.name is not None:
263269
output["name"] = request.name
264270

@@ -293,16 +299,20 @@ def marshal_MigrateZonalPrivateNetworksRequest(
293299
[
294300
OneOfPossibility(
295301
"project_id",
296-
request.project_id or defaults.default_project_id
297-
if request.project_id is not None
298-
else None,
302+
(
303+
request.project_id or defaults.default_project_id
304+
if request.project_id is not None
305+
else None
306+
),
299307
defaults.default_project_id,
300308
),
301309
OneOfPossibility(
302310
"organization_id",
303-
request.organization_id or defaults.default_organization_id
304-
if request.organization_id is not None
305-
else None,
311+
(
312+
request.organization_id or defaults.default_organization_id
313+
if request.organization_id is not None
314+
else None
315+
),
306316
defaults.default_organization_id,
307317
),
308318
]

scaleway/scaleway/vpc/v2/types.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,11 @@ class VPC:
209209
Number of Private Networks within this VPC.
210210
"""
211211

212+
routing_enabled: bool
213+
"""
214+
Defines whether the VPC routes traffic between its Private Networks.
215+
"""
216+
212217

213218
@dataclass
214219
class ListVPCsRequest:
@@ -257,6 +262,11 @@ class ListVPCsRequest:
257262
Defines whether to filter only for VPCs which are the default one for their Project.
258263
"""
259264

265+
routing_enabled: Optional[bool]
266+
"""
267+
Defines whether to filter only for VPCs which route traffic between their Private Networks.
268+
"""
269+
260270

261271
@dataclass
262272
class CreateVPCRequest:
@@ -280,6 +290,11 @@ class CreateVPCRequest:
280290
Tags for the VPC.
281291
"""
282292

293+
enable_routing: bool
294+
"""
295+
Enable routing between Private Networks in the VPC.
296+
"""
297+
283298

284299
@dataclass
285300
class GetVPCRequest:

0 commit comments

Comments
 (0)