Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion scaleway-async/scaleway_async/interlink/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
CreateLinkRequest,
CreateRoutingPolicyRequest,
DedicatedConnection,
DetachRoutingPolicyRequest,
Link,
ListDedicatedConnectionsResponse,
ListLinksResponse,
Expand Down Expand Up @@ -59,6 +60,7 @@
marshal_AttachVpcRequest,
marshal_CreateLinkRequest,
marshal_CreateRoutingPolicyRequest,
marshal_DetachRoutingPolicyRequest,
marshal_UpdateLinkRequest,
marshal_UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -1031,12 +1033,14 @@ async def detach_routing_policy(
self,
*,
link_id: str,
routing_policy_id: str,
region: Optional[ScwRegion] = None,
) -> Link:
"""
Detach a routing policy.
Detach a routing policy from an existing link. Without a routing policy, all routes across the link are blocked by default.
:param link_id: ID of the link to detach a routing policy from.
:param routing_policy_id: ID of the routing policy to be detached.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Link <Link>`

Expand All @@ -1045,6 +1049,7 @@ async def detach_routing_policy(

result = await api.detach_routing_policy(
link_id="example",
routing_policy_id="example",
)
"""

Expand All @@ -1056,7 +1061,14 @@ async def detach_routing_policy(
res = self._request(
"POST",
f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}/detach-routing-policy",
body={},
body=marshal_DetachRoutingPolicyRequest(
DetachRoutingPolicyRequest(
link_id=link_id,
routing_policy_id=routing_policy_id,
region=region,
),
self.client,
),
)

self._throw_on_error(res)
Expand Down Expand Up @@ -1143,6 +1155,7 @@ async def list_routing_policies(
organization_id: Optional[str] = None,
name: Optional[str] = None,
tags: Optional[List[str]] = None,
ipv6: Optional[bool] = None,
) -> ListRoutingPoliciesResponse:
"""
List routing policies.
Expand All @@ -1155,6 +1168,7 @@ async def list_routing_policies(
:param organization_id: Organization ID to filter for.
:param name: Routing policy name to filter for.
:param tags: Tags to filter for.
:param ipv6: Filter for the routing policies based on IP prefixes version.
:return: :class:`ListRoutingPoliciesResponse <ListRoutingPoliciesResponse>`

Usage:
Expand All @@ -1171,6 +1185,7 @@ async def list_routing_policies(
"GET",
f"/interlink/v1beta1/regions/{param_region}/routing-policies",
params={
"ipv6": ipv6,
"name": name,
"order_by": order_by,
"organization_id": organization_id
Expand All @@ -1196,6 +1211,7 @@ async def list_routing_policies_all(
organization_id: Optional[str] = None,
name: Optional[str] = None,
tags: Optional[List[str]] = None,
ipv6: Optional[bool] = None,
) -> List[RoutingPolicy]:
"""
List routing policies.
Expand All @@ -1208,6 +1224,7 @@ async def list_routing_policies_all(
:param organization_id: Organization ID to filter for.
:param name: Routing policy name to filter for.
:param tags: Tags to filter for.
:param ipv6: Filter for the routing policies based on IP prefixes version.
:return: :class:`List[RoutingPolicy] <List[RoutingPolicy]>`

Usage:
Expand All @@ -1229,6 +1246,7 @@ async def list_routing_policies_all(
"organization_id": organization_id,
"name": name,
"tags": tags,
"ipv6": ipv6,
},
)

Expand Down Expand Up @@ -1272,6 +1290,7 @@ async def create_routing_policy(
self,
*,
name: str,
is_ipv6: bool,
region: Optional[ScwRegion] = None,
project_id: Optional[str] = None,
tags: Optional[List[str]] = None,
Expand All @@ -1282,6 +1301,7 @@ async def create_routing_policy(
Create a routing policy.
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.
:param name: Name of the routing policy.
:param is_ipv6: IP prefixes version of the routing policy.
:param region: Region to target. If none is passed will use default region from the config.
:param project_id: ID of the Project to create the routing policy in.
:param tags: List of tags to apply to the routing policy.
Expand All @@ -1294,6 +1314,7 @@ async def create_routing_policy(

result = await api.create_routing_policy(
name="example",
is_ipv6=False,
)
"""

Expand All @@ -1307,6 +1328,7 @@ async def create_routing_policy(
body=marshal_CreateRoutingPolicyRequest(
CreateRoutingPolicyRequest(
name=name,
is_ipv6=is_ipv6,
region=region,
project_id=project_id,
tags=tags,
Expand Down
32 changes: 32 additions & 0 deletions scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
AttachVpcRequest,
CreateLinkRequest,
CreateRoutingPolicyRequest,
DetachRoutingPolicyRequest,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -272,6 +273,18 @@ def unmarshal_Link(data: Any) -> Link:
else:
args["peer_bgp_config"] = None

field = data.get("routing_policy_v4_id", None)
if field is not None:
args["routing_policy_v4_id"] = field
else:
args["routing_policy_v4_id"] = None

field = data.get("routing_policy_v6_id", None)
if field is not None:
args["routing_policy_v6_id"] = field
else:
args["routing_policy_v6_id"] = None

return Link(**args)


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

field = data.get("is_ipv6", None)
if field is not None:
args["is_ipv6"] = field

field = data.get("region", None)
if field is not None:
args["region"] = field
Expand Down Expand Up @@ -591,6 +608,9 @@ def marshal_CreateRoutingPolicyRequest(
if request.name is not None:
output["name"] = request.name

if request.is_ipv6 is not None:
output["is_ipv6"] = request.is_ipv6

if request.project_id is not None:
output["project_id"] = request.project_id or defaults.default_project_id

Expand All @@ -606,6 +626,18 @@ def marshal_CreateRoutingPolicyRequest(
return output


def marshal_DetachRoutingPolicyRequest(
request: DetachRoutingPolicyRequest,
defaults: ProfileDefaults,
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.routing_policy_id is not None:
output["routing_policy_id"] = request.routing_policy_id

return output


def marshal_UpdateLinkRequest(
request: UpdateLinkRequest,
defaults: ProfileDefaults,
Expand Down
52 changes: 41 additions & 11 deletions scaleway-async/scaleway_async/interlink/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,24 +286,14 @@ class Link:
Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint.
"""

vlan: int
"""
VLAN of the link.
"""

region: ScwRegion
"""
Region of the link.
"""

vpc_id: Optional[str]
"""
ID of the Scaleway VPC attached to the link.
"""

routing_policy_id: Optional[str]
"""
ID of the routing policy attached to the link.
Deprecated. Use routing_policy_v4_id or routing_policy_v6_id instead.
"""

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

vlan: int
"""
VLAN of the link.
"""

region: ScwRegion
"""
Region of the link.
"""

scw_bgp_config: Optional[BgpConfig]
"""
BGP configuration on Scaleway's side.
Expand All @@ -326,6 +326,16 @@ class Link:
BGP configuration on peer's side (on-premises or other hosting provider).
"""

routing_policy_v4_id: Optional[str]
"""
ID of the routing policy IPv4 attached to the link.
"""

routing_policy_v6_id: Optional[str]
"""
ID of the routing policy IPv6 attached to the link.
"""

partner: Optional[PartnerHost]

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

is_ipv6: bool
"""
IP prefixes version of the routing policy.
"""

region: ScwRegion
"""
Region of the routing policy.
Expand Down Expand Up @@ -550,6 +565,11 @@ class CreateRoutingPolicyRequest:
Name of the routing policy.
"""

is_ipv6: bool
"""
IP prefixes version of the routing policy.
"""

region: Optional[ScwRegion]
"""
Region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -609,6 +629,11 @@ class DetachRoutingPolicyRequest:
ID of the link to detach a routing policy from.
"""

routing_policy_id: str
"""
ID of the routing policy to be detached.
"""

region: Optional[ScwRegion]
"""
Region to target. If none is passed will use default region from the config.
Expand Down Expand Up @@ -1045,6 +1070,11 @@ class ListRoutingPoliciesRequest:
Tags to filter for.
"""

ipv6: Optional[bool]
"""
Filter for the routing policies based on IP prefixes version.
"""


@dataclass
class ListRoutingPoliciesResponse:
Expand Down
Loading