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
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/interlink/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .types import ListPopsResponse
from .types import ListRoutingPoliciesRequest
from .types import ListRoutingPoliciesResponse
from .types import SetRoutingPolicyRequest
from .types import UpdateLinkRequest
from .types import UpdateRoutingPolicyRequest
from .api import InterlinkV1Beta1API
Expand Down Expand Up @@ -93,6 +94,7 @@
"ListPopsResponse",
"ListRoutingPoliciesRequest",
"ListRoutingPoliciesResponse",
"SetRoutingPolicyRequest",
"UpdateLinkRequest",
"UpdateRoutingPolicyRequest",
"InterlinkV1Beta1API",
Expand Down
53 changes: 53 additions & 0 deletions scaleway-async/scaleway_async/interlink/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Partner,
Pop,
RoutingPolicy,
SetRoutingPolicyRequest,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
)
Expand All @@ -61,6 +62,7 @@
marshal_CreateLinkRequest,
marshal_CreateRoutingPolicyRequest,
marshal_DetachRoutingPolicyRequest,
marshal_SetRoutingPolicyRequest,
marshal_UpdateLinkRequest,
marshal_UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -768,6 +770,8 @@ async def create_link(
partner_id: Optional[str] = None,
peer_asn: Optional[int] = None,
vlan: Optional[int] = None,
routing_policy_v4_id: Optional[str] = None,
routing_policy_v6_id: Optional[str] = None,
) -> Link:
"""
Create a link.
Expand All @@ -784,6 +788,8 @@ async def create_link(
One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set.
:param peer_asn: For self-hosted links we need the peer AS Number to establish BGP session. If not given, a default one will be assigned.
:param vlan: For self-hosted links only, it is possible to choose the VLAN ID. If the VLAN is not available (ie already taken or out of range), an error is returned.
:param routing_policy_v4_id: If set, attaches this routing policy containing IPv4 prefixes to the Link. Hence, a BGP IPv4 session will be created.
:param routing_policy_v6_id: If set, attaches this routing policy containing IPv6 prefixes to the Link. Hence, a BGP IPv6 session will be created.
:return: :class:`Link <Link>`

Usage:
Expand Down Expand Up @@ -813,6 +819,8 @@ async def create_link(
tags=tags,
peer_asn=peer_asn,
vlan=vlan,
routing_policy_v4_id=routing_policy_v4_id,
routing_policy_v6_id=routing_policy_v6_id,
connection_id=connection_id,
partner_id=partner_id,
),
Expand Down Expand Up @@ -1077,6 +1085,51 @@ async def detach_routing_policy(
self._throw_on_error(res)
return unmarshal_Link(res.json())

async def set_routing_policy(
self,
*,
link_id: str,
routing_policy_id: str,
region: Optional[ScwRegion] = None,
) -> Link:
"""
Set a routing policy.
Replace a routing policy from an existing link. This is usefull when route propagation is enabled because it changes the routing policy "in place", without blocking all routes like a attach / detach would do.
:param link_id: ID of the link to set a routing policy from.
:param routing_policy_id: ID of the routing policy to be set.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Link <Link>`

Usage:
::

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

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_link_id = validate_path_param("link_id", link_id)

res = self._request(
"POST",
f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}/set-routing-policy",
body=marshal_SetRoutingPolicyRequest(
SetRoutingPolicyRequest(
link_id=link_id,
routing_policy_id=routing_policy_id,
region=region,
),
self.client,
),
)

self._throw_on_error(res)
return unmarshal_Link(res.json())

async def enable_route_propagation(
self,
*,
Expand Down
19 changes: 19 additions & 0 deletions scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CreateLinkRequest,
CreateRoutingPolicyRequest,
DetachRoutingPolicyRequest,
SetRoutingPolicyRequest,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -732,6 +733,12 @@ def marshal_CreateLinkRequest(
if request.vlan is not None:
output["vlan"] = request.vlan

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

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

return output


Expand Down Expand Up @@ -776,6 +783,18 @@ def marshal_DetachRoutingPolicyRequest(
return output


def marshal_SetRoutingPolicyRequest(
request: SetRoutingPolicyRequest,
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
30 changes: 30 additions & 0 deletions scaleway-async/scaleway_async/interlink/v1beta1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class BgpStatus(str, Enum, metaclass=StrEnumMeta):
UNKNOWN_BGP_STATUS = "unknown_bgp_status"
UP = "up"
DOWN = "down"
DISABLED = "disabled"

def __str__(self) -> str:
return str(self.value)
Expand Down Expand Up @@ -60,6 +61,7 @@ class LinkStatus(str, Enum, metaclass=StrEnumMeta):
DEPROVISIONING = "deprovisioning"
DELETED = "deleted"
LOCKED = "locked"
READY = "ready"

def __str__(self) -> str:
return str(self.value)
Expand Down Expand Up @@ -558,6 +560,16 @@ class CreateLinkRequest:
For self-hosted links only, it is possible to choose the VLAN ID. If the VLAN is not available (ie already taken or out of range), an error is returned.
"""

routing_policy_v4_id: Optional[str] = None
"""
If set, attaches this routing policy containing IPv4 prefixes to the Link. Hence, a BGP IPv4 session will be created.
"""

routing_policy_v6_id: Optional[str] = None
"""
If set, attaches this routing policy containing IPv6 prefixes to the Link. Hence, a BGP IPv6 session will be created.
"""

connection_id: Optional[str] = None

partner_id: Optional[str] = None
Expand Down Expand Up @@ -1093,6 +1105,24 @@ class ListRoutingPoliciesResponse:
total_count: int


@dataclass
class SetRoutingPolicyRequest:
link_id: str
"""
ID of the link to set a routing policy from.
"""

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

region: Optional[ScwRegion] = None
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class UpdateLinkRequest:
link_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/interlink/v1beta1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
from .types import ListPopsResponse
from .types import ListRoutingPoliciesRequest
from .types import ListRoutingPoliciesResponse
from .types import SetRoutingPolicyRequest
from .types import UpdateLinkRequest
from .types import UpdateRoutingPolicyRequest
from .api import InterlinkV1Beta1API
Expand Down Expand Up @@ -93,6 +94,7 @@
"ListPopsResponse",
"ListRoutingPoliciesRequest",
"ListRoutingPoliciesResponse",
"SetRoutingPolicyRequest",
"UpdateLinkRequest",
"UpdateRoutingPolicyRequest",
"InterlinkV1Beta1API",
Expand Down
53 changes: 53 additions & 0 deletions scaleway/scaleway/interlink/v1beta1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
Partner,
Pop,
RoutingPolicy,
SetRoutingPolicyRequest,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
)
Expand All @@ -61,6 +62,7 @@
marshal_CreateLinkRequest,
marshal_CreateRoutingPolicyRequest,
marshal_DetachRoutingPolicyRequest,
marshal_SetRoutingPolicyRequest,
marshal_UpdateLinkRequest,
marshal_UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -766,6 +768,8 @@ def create_link(
partner_id: Optional[str] = None,
peer_asn: Optional[int] = None,
vlan: Optional[int] = None,
routing_policy_v4_id: Optional[str] = None,
routing_policy_v6_id: Optional[str] = None,
) -> Link:
"""
Create a link.
Expand All @@ -782,6 +786,8 @@ def create_link(
One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set.
:param peer_asn: For self-hosted links we need the peer AS Number to establish BGP session. If not given, a default one will be assigned.
:param vlan: For self-hosted links only, it is possible to choose the VLAN ID. If the VLAN is not available (ie already taken or out of range), an error is returned.
:param routing_policy_v4_id: If set, attaches this routing policy containing IPv4 prefixes to the Link. Hence, a BGP IPv4 session will be created.
:param routing_policy_v6_id: If set, attaches this routing policy containing IPv6 prefixes to the Link. Hence, a BGP IPv6 session will be created.
:return: :class:`Link <Link>`

Usage:
Expand Down Expand Up @@ -811,6 +817,8 @@ def create_link(
tags=tags,
peer_asn=peer_asn,
vlan=vlan,
routing_policy_v4_id=routing_policy_v4_id,
routing_policy_v6_id=routing_policy_v6_id,
connection_id=connection_id,
partner_id=partner_id,
),
Expand Down Expand Up @@ -1075,6 +1083,51 @@ def detach_routing_policy(
self._throw_on_error(res)
return unmarshal_Link(res.json())

def set_routing_policy(
self,
*,
link_id: str,
routing_policy_id: str,
region: Optional[ScwRegion] = None,
) -> Link:
"""
Set a routing policy.
Replace a routing policy from an existing link. This is usefull when route propagation is enabled because it changes the routing policy "in place", without blocking all routes like a attach / detach would do.
:param link_id: ID of the link to set a routing policy from.
:param routing_policy_id: ID of the routing policy to be set.
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`Link <Link>`

Usage:
::

result = api.set_routing_policy(
link_id="example",
routing_policy_id="example",
)
"""

param_region = validate_path_param(
"region", region or self.client.default_region
)
param_link_id = validate_path_param("link_id", link_id)

res = self._request(
"POST",
f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}/set-routing-policy",
body=marshal_SetRoutingPolicyRequest(
SetRoutingPolicyRequest(
link_id=link_id,
routing_policy_id=routing_policy_id,
region=region,
),
self.client,
),
)

self._throw_on_error(res)
return unmarshal_Link(res.json())

def enable_route_propagation(
self,
*,
Expand Down
19 changes: 19 additions & 0 deletions scaleway/scaleway/interlink/v1beta1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
CreateLinkRequest,
CreateRoutingPolicyRequest,
DetachRoutingPolicyRequest,
SetRoutingPolicyRequest,
UpdateLinkRequest,
UpdateRoutingPolicyRequest,
)
Expand Down Expand Up @@ -732,6 +733,12 @@ def marshal_CreateLinkRequest(
if request.vlan is not None:
output["vlan"] = request.vlan

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

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

return output


Expand Down Expand Up @@ -776,6 +783,18 @@ def marshal_DetachRoutingPolicyRequest(
return output


def marshal_SetRoutingPolicyRequest(
request: SetRoutingPolicyRequest,
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
Loading