Skip to content

Commit 85b477f

Browse files
authored
feat(interlink): add support for RoutingPolicyV4ID, RoutingPolicyV6ID and IsIPv6 (#1022)
1 parent 06be066 commit 85b477f

File tree

6 files changed

+192
-24
lines changed

6 files changed

+192
-24
lines changed

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

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
CreateLinkRequest,
2929
CreateRoutingPolicyRequest,
3030
DedicatedConnection,
31+
DetachRoutingPolicyRequest,
3132
Link,
3233
ListDedicatedConnectionsResponse,
3334
ListLinksResponse,
@@ -59,6 +60,7 @@
5960
marshal_AttachVpcRequest,
6061
marshal_CreateLinkRequest,
6162
marshal_CreateRoutingPolicyRequest,
63+
marshal_DetachRoutingPolicyRequest,
6264
marshal_UpdateLinkRequest,
6365
marshal_UpdateRoutingPolicyRequest,
6466
)
@@ -1031,12 +1033,14 @@ async def detach_routing_policy(
10311033
self,
10321034
*,
10331035
link_id: str,
1036+
routing_policy_id: str,
10341037
region: Optional[ScwRegion] = None,
10351038
) -> Link:
10361039
"""
10371040
Detach a routing policy.
10381041
Detach a routing policy from an existing link. Without a routing policy, all routes across the link are blocked by default.
10391042
:param link_id: ID of the link to detach a routing policy from.
1043+
:param routing_policy_id: ID of the routing policy to be detached.
10401044
:param region: Region to target. If none is passed will use default region from the config.
10411045
:return: :class:`Link <Link>`
10421046
@@ -1045,6 +1049,7 @@ async def detach_routing_policy(
10451049
10461050
result = await api.detach_routing_policy(
10471051
link_id="example",
1052+
routing_policy_id="example",
10481053
)
10491054
"""
10501055

@@ -1056,7 +1061,14 @@ async def detach_routing_policy(
10561061
res = self._request(
10571062
"POST",
10581063
f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}/detach-routing-policy",
1059-
body={},
1064+
body=marshal_DetachRoutingPolicyRequest(
1065+
DetachRoutingPolicyRequest(
1066+
link_id=link_id,
1067+
routing_policy_id=routing_policy_id,
1068+
region=region,
1069+
),
1070+
self.client,
1071+
),
10601072
)
10611073

10621074
self._throw_on_error(res)
@@ -1143,6 +1155,7 @@ async def list_routing_policies(
11431155
organization_id: Optional[str] = None,
11441156
name: Optional[str] = None,
11451157
tags: Optional[List[str]] = None,
1158+
ipv6: Optional[bool] = None,
11461159
) -> ListRoutingPoliciesResponse:
11471160
"""
11481161
List routing policies.
@@ -1155,6 +1168,7 @@ async def list_routing_policies(
11551168
:param organization_id: Organization ID to filter for.
11561169
:param name: Routing policy name to filter for.
11571170
:param tags: Tags to filter for.
1171+
:param ipv6: Filter for the routing policies based on IP prefixes version.
11581172
:return: :class:`ListRoutingPoliciesResponse <ListRoutingPoliciesResponse>`
11591173
11601174
Usage:
@@ -1171,6 +1185,7 @@ async def list_routing_policies(
11711185
"GET",
11721186
f"/interlink/v1beta1/regions/{param_region}/routing-policies",
11731187
params={
1188+
"ipv6": ipv6,
11741189
"name": name,
11751190
"order_by": order_by,
11761191
"organization_id": organization_id
@@ -1196,6 +1211,7 @@ async def list_routing_policies_all(
11961211
organization_id: Optional[str] = None,
11971212
name: Optional[str] = None,
11981213
tags: Optional[List[str]] = None,
1214+
ipv6: Optional[bool] = None,
11991215
) -> List[RoutingPolicy]:
12001216
"""
12011217
List routing policies.
@@ -1208,6 +1224,7 @@ async def list_routing_policies_all(
12081224
:param organization_id: Organization ID to filter for.
12091225
:param name: Routing policy name to filter for.
12101226
:param tags: Tags to filter for.
1227+
:param ipv6: Filter for the routing policies based on IP prefixes version.
12111228
:return: :class:`List[RoutingPolicy] <List[RoutingPolicy]>`
12121229
12131230
Usage:
@@ -1229,6 +1246,7 @@ async def list_routing_policies_all(
12291246
"organization_id": organization_id,
12301247
"name": name,
12311248
"tags": tags,
1249+
"ipv6": ipv6,
12321250
},
12331251
)
12341252

@@ -1272,6 +1290,7 @@ async def create_routing_policy(
12721290
self,
12731291
*,
12741292
name: str,
1293+
is_ipv6: bool,
12751294
region: Optional[ScwRegion] = None,
12761295
project_id: Optional[str] = None,
12771296
tags: Optional[List[str]] = None,
@@ -1282,6 +1301,7 @@ async def create_routing_policy(
12821301
Create a routing policy.
12831302
Create a routing policy. Routing policies allow you to set IP prefix filters to define the incoming route announcements to accept from the peer, and the outgoing routes to announce to the peer.
12841303
:param name: Name of the routing policy.
1304+
:param is_ipv6: IP prefixes version of the routing policy.
12851305
:param region: Region to target. If none is passed will use default region from the config.
12861306
:param project_id: ID of the Project to create the routing policy in.
12871307
:param tags: List of tags to apply to the routing policy.
@@ -1294,6 +1314,7 @@ async def create_routing_policy(
12941314
12951315
result = await api.create_routing_policy(
12961316
name="example",
1317+
is_ipv6=False,
12971318
)
12981319
"""
12991320

@@ -1307,6 +1328,7 @@ async def create_routing_policy(
13071328
body=marshal_CreateRoutingPolicyRequest(
13081329
CreateRoutingPolicyRequest(
13091330
name=name,
1331+
is_ipv6=is_ipv6,
13101332
region=region,
13111333
project_id=project_id,
13121334
tags=tags,

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

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
AttachVpcRequest,
2828
CreateLinkRequest,
2929
CreateRoutingPolicyRequest,
30+
DetachRoutingPolicyRequest,
3031
UpdateLinkRequest,
3132
UpdateRoutingPolicyRequest,
3233
)
@@ -272,6 +273,18 @@ def unmarshal_Link(data: Any) -> Link:
272273
else:
273274
args["peer_bgp_config"] = None
274275

276+
field = data.get("routing_policy_v4_id", None)
277+
if field is not None:
278+
args["routing_policy_v4_id"] = field
279+
else:
280+
args["routing_policy_v4_id"] = None
281+
282+
field = data.get("routing_policy_v6_id", None)
283+
if field is not None:
284+
args["routing_policy_v6_id"] = field
285+
else:
286+
args["routing_policy_v6_id"] = None
287+
275288
return Link(**args)
276289

277290

@@ -397,6 +410,10 @@ def unmarshal_RoutingPolicy(data: Any) -> RoutingPolicy:
397410
if field is not None:
398411
args["prefix_filter_out"] = field
399412

413+
field = data.get("is_ipv6", None)
414+
if field is not None:
415+
args["is_ipv6"] = field
416+
400417
field = data.get("region", None)
401418
if field is not None:
402419
args["region"] = field
@@ -591,6 +608,9 @@ def marshal_CreateRoutingPolicyRequest(
591608
if request.name is not None:
592609
output["name"] = request.name
593610

611+
if request.is_ipv6 is not None:
612+
output["is_ipv6"] = request.is_ipv6
613+
594614
if request.project_id is not None:
595615
output["project_id"] = request.project_id or defaults.default_project_id
596616

@@ -606,6 +626,18 @@ def marshal_CreateRoutingPolicyRequest(
606626
return output
607627

608628

629+
def marshal_DetachRoutingPolicyRequest(
630+
request: DetachRoutingPolicyRequest,
631+
defaults: ProfileDefaults,
632+
) -> Dict[str, Any]:
633+
output: Dict[str, Any] = {}
634+
635+
if request.routing_policy_id is not None:
636+
output["routing_policy_id"] = request.routing_policy_id
637+
638+
return output
639+
640+
609641
def marshal_UpdateLinkRequest(
610642
request: UpdateLinkRequest,
611643
defaults: ProfileDefaults,

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

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -286,24 +286,14 @@ class Link:
286286
Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint.
287287
"""
288288

289-
vlan: int
290-
"""
291-
VLAN of the link.
292-
"""
293-
294-
region: ScwRegion
295-
"""
296-
Region of the link.
297-
"""
298-
299289
vpc_id: Optional[str]
300290
"""
301291
ID of the Scaleway VPC attached to the link.
302292
"""
303293

304294
routing_policy_id: Optional[str]
305295
"""
306-
ID of the routing policy attached to the link.
296+
Deprecated. Use routing_policy_v4_id or routing_policy_v6_id instead.
307297
"""
308298

309299
created_at: Optional[datetime]
@@ -316,6 +306,16 @@ class Link:
316306
Last modification date of the link.
317307
"""
318308

309+
vlan: int
310+
"""
311+
VLAN of the link.
312+
"""
313+
314+
region: ScwRegion
315+
"""
316+
Region of the link.
317+
"""
318+
319319
scw_bgp_config: Optional[BgpConfig]
320320
"""
321321
BGP configuration on Scaleway's side.
@@ -326,6 +326,16 @@ class Link:
326326
BGP configuration on peer's side (on-premises or other hosting provider).
327327
"""
328328

329+
routing_policy_v4_id: Optional[str]
330+
"""
331+
ID of the routing policy IPv4 attached to the link.
332+
"""
333+
334+
routing_policy_v6_id: Optional[str]
335+
"""
336+
ID of the routing policy IPv6 attached to the link.
337+
"""
338+
329339
partner: Optional[PartnerHost]
330340

331341
self_: Optional[SelfHost]
@@ -449,6 +459,11 @@ class RoutingPolicy:
449459
IP prefix filters to advertise to the peer (ranges of routes to advertise).
450460
"""
451461

462+
is_ipv6: bool
463+
"""
464+
IP prefixes version of the routing policy.
465+
"""
466+
452467
region: ScwRegion
453468
"""
454469
Region of the routing policy.
@@ -550,6 +565,11 @@ class CreateRoutingPolicyRequest:
550565
Name of the routing policy.
551566
"""
552567

568+
is_ipv6: bool
569+
"""
570+
IP prefixes version of the routing policy.
571+
"""
572+
553573
region: Optional[ScwRegion]
554574
"""
555575
Region to target. If none is passed will use default region from the config.
@@ -609,6 +629,11 @@ class DetachRoutingPolicyRequest:
609629
ID of the link to detach a routing policy from.
610630
"""
611631

632+
routing_policy_id: str
633+
"""
634+
ID of the routing policy to be detached.
635+
"""
636+
612637
region: Optional[ScwRegion]
613638
"""
614639
Region to target. If none is passed will use default region from the config.
@@ -1045,6 +1070,11 @@ class ListRoutingPoliciesRequest:
10451070
Tags to filter for.
10461071
"""
10471072

1073+
ipv6: Optional[bool]
1074+
"""
1075+
Filter for the routing policies based on IP prefixes version.
1076+
"""
1077+
10481078

10491079
@dataclass
10501080
class ListRoutingPoliciesResponse:

0 commit comments

Comments
 (0)