Skip to content

Commit 14f5aba

Browse files
feat(ipam): allow filtering on pn, subnet or vpc id (#518)
Co-authored-by: Laure-di <[email protected]>
1 parent fb56903 commit 14f5aba

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

scaleway-async/scaleway_async/ipam/v1/api.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ async def list_i_ps(
213213
project_id: Optional[str] = None,
214214
zonal: Optional[str] = None,
215215
private_network_id: Optional[str] = None,
216+
subnet_id: Optional[str] = None,
217+
vpc_id: Optional[str] = None,
216218
attached: Optional[bool] = None,
217219
resource_id: Optional[str] = None,
218220
resource_type: Optional[ResourceType] = None,
@@ -231,9 +233,12 @@ async def list_i_ps(
231233
:param page_size: Maximum number of IPs to return per page.
232234
:param project_id: Project ID to filter for. Only IPs belonging to this Project will be returned.
233235
:param zonal: Zone to filter for. Only IPs that are zonal, and in this zone, will be returned.
234-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
236+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
235237
:param private_network_id: Only IPs that are private, and in this Private Network, will be returned.
236-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
238+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
239+
:param subnet_id: Only IPs inside this exact subnet will be returned.
240+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
241+
:param vpc_id: Only IPs owned by resources in this VPC will be returned.
237242
:param attached: Defines whether to filter only for IPs which are attached to a resource.
238243
:param resource_id: Resource ID to filter for. Only IPs attached to this resource will be returned.
239244
:param resource_type: Resource type to filter for. Only IPs attached to this type of resource will be returned.
@@ -271,9 +276,11 @@ async def list_i_ps(
271276
"resource_name": resource_name,
272277
"resource_type": resource_type,
273278
"tags": tags,
279+
"vpc_id": vpc_id,
274280
**resolve_one_of(
275281
[
276282
OneOfPossibility("private_network_id", private_network_id),
283+
OneOfPossibility("subnet_id", subnet_id),
277284
OneOfPossibility("zonal", zonal),
278285
]
279286
),
@@ -293,6 +300,8 @@ async def list_i_ps_all(
293300
project_id: Optional[str] = None,
294301
zonal: Optional[str] = None,
295302
private_network_id: Optional[str] = None,
303+
subnet_id: Optional[str] = None,
304+
vpc_id: Optional[str] = None,
296305
attached: Optional[bool] = None,
297306
resource_id: Optional[str] = None,
298307
resource_type: Optional[ResourceType] = None,
@@ -311,9 +320,12 @@ async def list_i_ps_all(
311320
:param page_size: Maximum number of IPs to return per page.
312321
:param project_id: Project ID to filter for. Only IPs belonging to this Project will be returned.
313322
:param zonal: Zone to filter for. Only IPs that are zonal, and in this zone, will be returned.
314-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
323+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
315324
:param private_network_id: Only IPs that are private, and in this Private Network, will be returned.
316-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
325+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
326+
:param subnet_id: Only IPs inside this exact subnet will be returned.
327+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
328+
:param vpc_id: Only IPs owned by resources in this VPC will be returned.
317329
:param attached: Defines whether to filter only for IPs which are attached to a resource.
318330
:param resource_id: Resource ID to filter for. Only IPs attached to this resource will be returned.
319331
:param resource_type: Resource type to filter for. Only IPs attached to this type of resource will be returned.
@@ -340,6 +352,7 @@ async def list_i_ps_all(
340352
"page": page,
341353
"page_size": page_size,
342354
"project_id": project_id,
355+
"vpc_id": vpc_id,
343356
"attached": attached,
344357
"resource_id": resource_id,
345358
"resource_type": resource_type,
@@ -350,5 +363,6 @@ async def list_i_ps_all(
350363
"resource_name": resource_name,
351364
"zonal": zonal,
352365
"private_network_id": private_network_id,
366+
"subnet_id": subnet_id,
353367
},
354368
)

scaleway-async/scaleway_async/ipam/v1/types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ class ListIPsRequest:
230230
Project ID to filter for. Only IPs belonging to this Project will be returned.
231231
"""
232232

233+
vpc_id: Optional[str]
234+
"""
235+
Only IPs owned by resources in this VPC will be returned.
236+
"""
237+
233238
attached: Optional[bool]
234239
"""
235240
Defines whether to filter only for IPs which are attached to a resource.
@@ -274,6 +279,8 @@ class ListIPsRequest:
274279

275280
private_network_id: Optional[str]
276281

282+
subnet_id: Optional[str]
283+
277284

278285
@dataclass
279286
class ListIPsResponse:

scaleway/scaleway/ipam/v1/api.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def list_i_ps(
213213
project_id: Optional[str] = None,
214214
zonal: Optional[str] = None,
215215
private_network_id: Optional[str] = None,
216+
subnet_id: Optional[str] = None,
217+
vpc_id: Optional[str] = None,
216218
attached: Optional[bool] = None,
217219
resource_id: Optional[str] = None,
218220
resource_type: Optional[ResourceType] = None,
@@ -231,9 +233,12 @@ def list_i_ps(
231233
:param page_size: Maximum number of IPs to return per page.
232234
:param project_id: Project ID to filter for. Only IPs belonging to this Project will be returned.
233235
:param zonal: Zone to filter for. Only IPs that are zonal, and in this zone, will be returned.
234-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
236+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
235237
:param private_network_id: Only IPs that are private, and in this Private Network, will be returned.
236-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
238+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
239+
:param subnet_id: Only IPs inside this exact subnet will be returned.
240+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
241+
:param vpc_id: Only IPs owned by resources in this VPC will be returned.
237242
:param attached: Defines whether to filter only for IPs which are attached to a resource.
238243
:param resource_id: Resource ID to filter for. Only IPs attached to this resource will be returned.
239244
:param resource_type: Resource type to filter for. Only IPs attached to this type of resource will be returned.
@@ -271,9 +276,11 @@ def list_i_ps(
271276
"resource_name": resource_name,
272277
"resource_type": resource_type,
273278
"tags": tags,
279+
"vpc_id": vpc_id,
274280
**resolve_one_of(
275281
[
276282
OneOfPossibility("private_network_id", private_network_id),
283+
OneOfPossibility("subnet_id", subnet_id),
277284
OneOfPossibility("zonal", zonal),
278285
]
279286
),
@@ -293,6 +300,8 @@ def list_i_ps_all(
293300
project_id: Optional[str] = None,
294301
zonal: Optional[str] = None,
295302
private_network_id: Optional[str] = None,
303+
subnet_id: Optional[str] = None,
304+
vpc_id: Optional[str] = None,
296305
attached: Optional[bool] = None,
297306
resource_id: Optional[str] = None,
298307
resource_type: Optional[ResourceType] = None,
@@ -311,9 +320,12 @@ def list_i_ps_all(
311320
:param page_size: Maximum number of IPs to return per page.
312321
:param project_id: Project ID to filter for. Only IPs belonging to this Project will be returned.
313322
:param zonal: Zone to filter for. Only IPs that are zonal, and in this zone, will be returned.
314-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
323+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
315324
:param private_network_id: Only IPs that are private, and in this Private Network, will be returned.
316-
One-Of ('source'): at most one of 'zonal', 'private_network_id' could be set.
325+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
326+
:param subnet_id: Only IPs inside this exact subnet will be returned.
327+
One-Of ('source'): at most one of 'zonal', 'private_network_id', 'subnet_id' could be set.
328+
:param vpc_id: Only IPs owned by resources in this VPC will be returned.
317329
:param attached: Defines whether to filter only for IPs which are attached to a resource.
318330
:param resource_id: Resource ID to filter for. Only IPs attached to this resource will be returned.
319331
:param resource_type: Resource type to filter for. Only IPs attached to this type of resource will be returned.
@@ -340,6 +352,7 @@ def list_i_ps_all(
340352
"page": page,
341353
"page_size": page_size,
342354
"project_id": project_id,
355+
"vpc_id": vpc_id,
343356
"attached": attached,
344357
"resource_id": resource_id,
345358
"resource_type": resource_type,
@@ -350,5 +363,6 @@ def list_i_ps_all(
350363
"resource_name": resource_name,
351364
"zonal": zonal,
352365
"private_network_id": private_network_id,
366+
"subnet_id": subnet_id,
353367
},
354368
)

scaleway/scaleway/ipam/v1/types.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,11 @@ class ListIPsRequest:
230230
Project ID to filter for. Only IPs belonging to this Project will be returned.
231231
"""
232232

233+
vpc_id: Optional[str]
234+
"""
235+
Only IPs owned by resources in this VPC will be returned.
236+
"""
237+
233238
attached: Optional[bool]
234239
"""
235240
Defines whether to filter only for IPs which are attached to a resource.
@@ -274,6 +279,8 @@ class ListIPsRequest:
274279

275280
private_network_id: Optional[str]
276281

282+
subnet_id: Optional[str]
283+
277284

278285
@dataclass
279286
class ListIPsResponse:

0 commit comments

Comments
 (0)