diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py b/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py index 479a0815b..66cc0eaba 100644 --- a/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py +++ b/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py @@ -1,11 +1,20 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. from .types import BgpStatus +from .types import DedicatedConnectionStatus +from .content import DEDICATED_CONNECTION_TRANSIENT_STATUSES +from .types import LinkKind from .types import LinkStatus +from .content import LINK_TRANSIENT_STATUSES +from .types import ListDedicatedConnectionsRequestOrderBy from .types import ListLinksRequestOrderBy from .types import ListPartnersRequestOrderBy from .types import ListPopsRequestOrderBy from .types import ListRoutingPoliciesRequestOrderBy +from .types import BgpConfig +from .types import PartnerHost +from .types import SelfHost +from .types import DedicatedConnection from .types import Link from .types import Partner from .types import Pop @@ -20,10 +29,13 @@ from .types import DetachVpcRequest from .types import DisableRoutePropagationRequest from .types import EnableRoutePropagationRequest +from .types import GetDedicatedConnectionRequest from .types import GetLinkRequest from .types import GetPartnerRequest from .types import GetPopRequest from .types import GetRoutingPolicyRequest +from .types import ListDedicatedConnectionsRequest +from .types import ListDedicatedConnectionsResponse from .types import ListLinksRequest from .types import ListLinksResponse from .types import ListPartnersRequest @@ -38,11 +50,20 @@ __all__ = [ "BgpStatus", + "DedicatedConnectionStatus", + "DEDICATED_CONNECTION_TRANSIENT_STATUSES", + "LinkKind", "LinkStatus", + "LINK_TRANSIENT_STATUSES", + "ListDedicatedConnectionsRequestOrderBy", "ListLinksRequestOrderBy", "ListPartnersRequestOrderBy", "ListPopsRequestOrderBy", "ListRoutingPoliciesRequestOrderBy", + "BgpConfig", + "PartnerHost", + "SelfHost", + "DedicatedConnection", "Link", "Partner", "Pop", @@ -57,10 +78,13 @@ "DetachVpcRequest", "DisableRoutePropagationRequest", "EnableRoutePropagationRequest", + "GetDedicatedConnectionRequest", "GetLinkRequest", "GetPartnerRequest", "GetPopRequest", "GetRoutingPolicyRequest", + "ListDedicatedConnectionsRequest", + "ListDedicatedConnectionsResponse", "ListLinksRequest", "ListLinksResponse", "ListPartnersRequest", diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/api.py b/scaleway-async/scaleway_async/interlink/v1beta1/api.py index 6beb0c7e4..a22550cf9 100644 --- a/scaleway-async/scaleway_async/interlink/v1beta1/api.py +++ b/scaleway-async/scaleway_async/interlink/v1beta1/api.py @@ -1,19 +1,24 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. -from typing import List, Optional +from typing import Awaitable, List, Optional, Union from scaleway_core.api import API from scaleway_core.bridge import ( Region as ScwRegion, ) from scaleway_core.utils import ( + WaitForOptions, validate_path_param, fetch_all_pages_async, + wait_for_resource_async, ) from .types import ( BgpStatus, + DedicatedConnectionStatus, + LinkKind, LinkStatus, + ListDedicatedConnectionsRequestOrderBy, ListLinksRequestOrderBy, ListPartnersRequestOrderBy, ListPopsRequestOrderBy, @@ -22,7 +27,9 @@ AttachVpcRequest, CreateLinkRequest, CreateRoutingPolicyRequest, + DedicatedConnection, Link, + ListDedicatedConnectionsResponse, ListLinksResponse, ListPartnersResponse, ListPopsResponse, @@ -33,11 +40,17 @@ UpdateLinkRequest, UpdateRoutingPolicyRequest, ) +from .content import ( + DEDICATED_CONNECTION_TRANSIENT_STATUSES, + LINK_TRANSIENT_STATUSES, +) from .marshalling import ( + unmarshal_DedicatedConnection, unmarshal_Link, unmarshal_Partner, unmarshal_Pop, unmarshal_RoutingPolicy, + unmarshal_ListDedicatedConnectionsResponse, unmarshal_ListLinksResponse, unmarshal_ListPartnersResponse, unmarshal_ListPopsResponse, @@ -56,6 +69,199 @@ class InterlinkV1Beta1API(API): This API allows you to manage your Scaleway InterLink, to connect your on-premises infrastructure with your Scaleway VPC. """ + async def list_dedicated_connections( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + status: Optional[DedicatedConnectionStatus] = None, + bandwidth_mbps: Optional[int] = None, + pop_id: Optional[str] = None, + ) -> ListDedicatedConnectionsResponse: + """ + List dedicated connections. + For self-hosted users, list their dedicated physical connections in a given region. By default, the connections returned in the list are ordered by name in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Link name to filter for. + :param tags: Tags to filter for. + :param status: Connection status to filter for. + :param bandwidth_mbps: Filter for dedicated connections with this bandwidth size. + :param pop_id: Filter for dedicated connections present in this PoP. + :return: :class:`ListDedicatedConnectionsResponse ` + + Usage: + :: + + result = await api.list_dedicated_connections() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/dedicated-connections", + params={ + "bandwidth_mbps": bandwidth_mbps, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "pop_id": pop_id, + "project_id": project_id or self.client.default_project_id, + "status": status, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDedicatedConnectionsResponse(res.json()) + + async def list_dedicated_connections_all( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + status: Optional[DedicatedConnectionStatus] = None, + bandwidth_mbps: Optional[int] = None, + pop_id: Optional[str] = None, + ) -> List[DedicatedConnection]: + """ + List dedicated connections. + For self-hosted users, list their dedicated physical connections in a given region. By default, the connections returned in the list are ordered by name in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Link name to filter for. + :param tags: Tags to filter for. + :param status: Connection status to filter for. + :param bandwidth_mbps: Filter for dedicated connections with this bandwidth size. + :param pop_id: Filter for dedicated connections present in this PoP. + :return: :class:`List[DedicatedConnection] ` + + Usage: + :: + + result = await api.list_dedicated_connections_all() + """ + + return await fetch_all_pages_async( + type=ListDedicatedConnectionsResponse, + key="connections", + fetcher=self.list_dedicated_connections, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "project_id": project_id, + "organization_id": organization_id, + "name": name, + "tags": tags, + "status": status, + "bandwidth_mbps": bandwidth_mbps, + "pop_id": pop_id, + }, + ) + + async def get_dedicated_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> DedicatedConnection: + """ + Get a dedicated connection. + For self-hosted users, get a dedicated physical connection corresponding to the given ID. The response object includes information such as the connection's name, status and total bandwidth. + :param connection_id: ID of connection to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DedicatedConnection ` + + Usage: + :: + + result = await api.get_dedicated_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/dedicated-connections/{param_connection_id}", + ) + + self._throw_on_error(res) + return unmarshal_DedicatedConnection(res.json()) + + async def wait_for_dedicated_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + options: Optional[ + WaitForOptions[DedicatedConnection, Union[bool, Awaitable[bool]]] + ] = None, + ) -> DedicatedConnection: + """ + Get a dedicated connection. + For self-hosted users, get a dedicated physical connection corresponding to the given ID. The response object includes information such as the connection's name, status and total bandwidth. + :param connection_id: ID of connection to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DedicatedConnection ` + + Usage: + :: + + result = await api.get_dedicated_connection( + connection_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in DEDICATED_CONNECTION_TRANSIENT_STATUSES + ) + + return await wait_for_resource_async( + fetcher=self.get_dedicated_connection, + options=options, + args={ + "connection_id": connection_id, + "region": region, + }, + ) + async def list_partners( self, *, @@ -72,7 +278,7 @@ async def list_partners( :param order_by: Order in which to return results. :param page: Page number to return. :param page_size: Maximum number of partners to return per page. - :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :param pop_ids: Filter for partners present (offering a connection) in one of these PoPs. :return: :class:`ListPartnersResponse ` Usage: @@ -115,7 +321,7 @@ async def list_partners_all( :param order_by: Order in which to return results. :param page: Page number to return. :param page_size: Maximum number of partners to return per page. - :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :param pop_ids: Filter for partners present (offering a connection) in one of these PoPs. :return: :class:`List[Partner] ` Usage: @@ -182,6 +388,7 @@ async def list_pops( hosting_provider_name: Optional[str] = None, partner_id: Optional[str] = None, link_bandwidth_mbps: Optional[int] = None, + dedicated_available: Optional[bool] = None, ) -> ListPopsResponse: """ List PoPs. @@ -192,8 +399,9 @@ async def list_pops( :param page_size: Maximum number of PoPs to return per page. :param name: PoP name to filter for. :param hosting_provider_name: Hosting provider name to filter for. - :param partner_id: Filter for PoPs hosting an available shared port from this partner. - :param link_bandwidth_mbps: Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param partner_id: Filter for PoPs hosting an available shared connection from this partner. + :param link_bandwidth_mbps: Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param dedicated_available: Filter for PoPs with a dedicated connection available for self-hosted links. :return: :class:`ListPopsResponse ` Usage: @@ -210,6 +418,7 @@ async def list_pops( "GET", f"/interlink/v1beta1/regions/{param_region}/pops", params={ + "dedicated_available": dedicated_available, "hosting_provider_name": hosting_provider_name, "link_bandwidth_mbps": link_bandwidth_mbps, "name": name, @@ -234,6 +443,7 @@ async def list_pops_all( hosting_provider_name: Optional[str] = None, partner_id: Optional[str] = None, link_bandwidth_mbps: Optional[int] = None, + dedicated_available: Optional[bool] = None, ) -> List[Pop]: """ List PoPs. @@ -244,8 +454,9 @@ async def list_pops_all( :param page_size: Maximum number of PoPs to return per page. :param name: PoP name to filter for. :param hosting_provider_name: Hosting provider name to filter for. - :param partner_id: Filter for PoPs hosting an available shared port from this partner. - :param link_bandwidth_mbps: Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param partner_id: Filter for PoPs hosting an available shared connection from this partner. + :param link_bandwidth_mbps: Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param dedicated_available: Filter for PoPs with a dedicated connection available for self-hosted links. :return: :class:`List[Pop] ` Usage: @@ -267,6 +478,7 @@ async def list_pops_all( "hosting_provider_name": hosting_provider_name, "partner_id": partner_id, "link_bandwidth_mbps": link_bandwidth_mbps, + "dedicated_available": dedicated_available, }, ) @@ -324,6 +536,8 @@ async def list_links( vpc_id: Optional[str] = None, routing_policy_id: Optional[str] = None, pairing_key: Optional[str] = None, + kind: Optional[LinkKind] = None, + connection_id: Optional[str] = None, ) -> ListLinksResponse: """ List links. @@ -339,12 +553,14 @@ async def list_links( :param status: Link status to filter for. :param bgp_v4_status: BGP IPv4 status to filter for. :param bgp_v6_status: BGP IPv6 status to filter for. - :param pop_id: Filter for links attached to this PoP (via ports). + :param pop_id: Filter for links attached to this PoP (via connections). :param bandwidth_mbps: Filter for link bandwidth (in Mbps). :param partner_id: Filter for links hosted by this partner. :param vpc_id: Filter for links attached to this VPC. :param routing_policy_id: Filter for links using this routing policy. :param pairing_key: Filter for the link with this pairing_key. + :param kind: Filter for hosted or self-hosted links. + :param connection_id: Filter for links self-hosted on this connection. :return: :class:`ListLinksResponse ` Usage: @@ -364,6 +580,8 @@ async def list_links( "bandwidth_mbps": bandwidth_mbps, "bgp_v4_status": bgp_v4_status, "bgp_v6_status": bgp_v6_status, + "connection_id": connection_id, + "kind": kind, "name": name, "order_by": order_by, "organization_id": organization_id @@ -404,6 +622,8 @@ async def list_links_all( vpc_id: Optional[str] = None, routing_policy_id: Optional[str] = None, pairing_key: Optional[str] = None, + kind: Optional[LinkKind] = None, + connection_id: Optional[str] = None, ) -> List[Link]: """ List links. @@ -419,12 +639,14 @@ async def list_links_all( :param status: Link status to filter for. :param bgp_v4_status: BGP IPv4 status to filter for. :param bgp_v6_status: BGP IPv6 status to filter for. - :param pop_id: Filter for links attached to this PoP (via ports). + :param pop_id: Filter for links attached to this PoP (via connections). :param bandwidth_mbps: Filter for link bandwidth (in Mbps). :param partner_id: Filter for links hosted by this partner. :param vpc_id: Filter for links attached to this VPC. :param routing_policy_id: Filter for links using this routing policy. :param pairing_key: Filter for the link with this pairing_key. + :param kind: Filter for hosted or self-hosted links. + :param connection_id: Filter for links self-hosted on this connection. :return: :class:`List[Link] ` Usage: @@ -455,6 +677,8 @@ async def list_links_all( "vpc_id": vpc_id, "routing_policy_id": routing_policy_id, "pairing_key": pairing_key, + "kind": kind, + "connection_id": connection_id, }, ) @@ -466,7 +690,7 @@ async def get_link( ) -> Link: """ Get a link. - Get a link (InterLink connection) for the given link ID. The response object includes information about the link's various configuration details. + Get a link (InterLink session / logical InterLink resource) for the given link ID. The response object includes information about the link's various configuration details. :param link_id: ID of the link to get. :param region: Region to target. If none is passed will use default region from the config. :return: :class:`Link ` @@ -492,6 +716,43 @@ async def get_link( self._throw_on_error(res) return unmarshal_Link(res.json()) + async def wait_for_link( + self, + *, + link_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Link, Union[bool, Awaitable[bool]]]] = None, + ) -> Link: + """ + Get a link. + Get a link (InterLink session / logical InterLink resource) for the given link ID. The response object includes information about the link's various configuration details. + :param link_id: ID of the link to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.get_link( + link_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in LINK_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_link, + options=options, + args={ + "link_id": link_id, + "region": region, + }, + ) + async def create_link( self, *, @@ -501,25 +762,22 @@ async def create_link( region: Optional[ScwRegion] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, - dedicated: Optional[bool] = None, - port_id: Optional[str] = None, + connection_id: Optional[str] = None, partner_id: Optional[str] = None, ) -> Link: """ Create a link. - Create a link (InterLink connection) in a given PoP, specifying its various configuration details. For the moment only hosted links (faciliated by partners) are available, though in the future dedicated and shared links will also be possible. + Create a link (InterLink session / logical InterLink resource) in a given PoP, specifying its various configuration details. Links can either be hosted (faciliated by partners' shared physical connections) or self-hosted (for users who have purchased a dedicated physical connection). :param name: Name of the link. :param pop_id: PoP (location) where the link will be created. - :param bandwidth_mbps: Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + :param bandwidth_mbps: Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the connection. :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 link in. :param tags: List of tags to apply to the link. - :param dedicated: If true, a dedicated link (1 link per port, dedicated to one customer) will be crated. It is not necessary to specify a `port_id` or `partner_id`. A new port will created and assigned to the link. Note that Scaleway has not yet enabled the creation of dedicated links, this field is reserved for future use. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. - :param port_id: If set, a shared link (N links per port, one of which is this customer's port) will be created. As the customer, specify the ID of the port you already have for this link. Note that shared links are not currently available. Note that Scaleway has not yet enabled the creation of shared links, this field is reserved for future use. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. - :param partner_id: If set, a hosted link (N links per port on a partner port) will be created. Specify the ID of the chosen partner, who already has a shareable port with available bandwidth. Note that this is currently the only type of link offered by Scaleway, and therefore this field must be set when creating a link. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. + :param connection_id: If set, creates a self-hosted link using this dedicated physical connection. As the customer, specify the ID of the physical connection you already have for this link. + One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set. + :param partner_id: If set, creates a hosted link on a partner's connection. Specify the ID of the chosen partner, who already has a shared connection with available bandwidth. + One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set. :return: :class:`Link ` Usage: @@ -547,8 +805,7 @@ async def create_link( region=region, project_id=project_id, tags=tags, - dedicated=dedicated, - port_id=port_id, + connection_id=connection_id, partner_id=partner_id, ), self.client, diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/content.py b/scaleway-async/scaleway_async/interlink/v1beta1/content.py new file mode 100644 index 000000000..dea5950ee --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/v1beta1/content.py @@ -0,0 +1,21 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DedicatedConnectionStatus, + LinkStatus, +) + +DEDICATED_CONNECTION_TRANSIENT_STATUSES: List[DedicatedConnectionStatus] = [ + DedicatedConnectionStatus.CONFIGURING, +] +""" +Lists transient statutes of the enum :class:`DedicatedConnectionStatus `. +""" +LINK_TRANSIENT_STATUSES: List[LinkStatus] = [ + LinkStatus.CONFIGURING, +] +""" +Lists transient statutes of the enum :class:`LinkStatus `. +""" diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py b/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py index d8b2c084b..ed47ee5dd 100644 --- a/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py +++ b/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py @@ -10,10 +10,15 @@ resolve_one_of, ) from .types import ( + DedicatedConnection, + BgpConfig, + PartnerHost, + SelfHost, Link, Partner, Pop, RoutingPolicy, + ListDedicatedConnectionsResponse, ListLinksResponse, ListPartnersResponse, ListPopsResponse, @@ -27,10 +32,10 @@ ) -def unmarshal_Link(data: Any) -> Link: +def unmarshal_DedicatedConnection(data: Any) -> DedicatedConnection: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'Link' failed as data isn't a dictionary." + "Unmarshalling the type 'DedicatedConnection' failed as data isn't a dictionary." ) args: Dict[str, Any] = {} @@ -47,6 +52,10 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["organization_id"] = field + field = data.get("status", None) + if field is not None: + args["status"] = field + field = data.get("name", None) if field is not None: args["name"] = field @@ -63,11 +72,133 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["bandwidth_mbps"] = field + field = data.get("available_link_bandwidths", None) + if field is not None: + args["available_link_bandwidths"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("demarcation_info", None) + if field is not None: + args["demarcation_info"] = field + else: + args["demarcation_info"] = None + + return DedicatedConnection(**args) + + +def unmarshal_BgpConfig(data: Any) -> BgpConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BgpConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = field + + field = data.get("ipv6", None) + if field is not None: + args["ipv6"] = field + + return BgpConfig(**args) + + +def unmarshal_PartnerHost(data: Any) -> PartnerHost: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PartnerHost' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + field = data.get("partner_id", None) if field is not None: args["partner_id"] = field + + field = data.get("pairing_key", None) + if field is not None: + args["pairing_key"] = field + + field = data.get("disapproved_reason", None) + if field is not None: + args["disapproved_reason"] = field else: - args["partner_id"] = None + args["disapproved_reason"] = None + + return PartnerHost(**args) + + +def unmarshal_SelfHost(data: Any) -> SelfHost: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SelfHost' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connection_id", None) + if field is not None: + args["connection_id"] = field + + return SelfHost(**args) + + +def unmarshal_Link(data: Any) -> Link: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Link' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("pop_id", None) + if field is not None: + args["pop_id"] = field + + field = data.get("bandwidth_mbps", None) + if field is not None: + args["bandwidth_mbps"] = field field = data.get("status", None) if field is not None: @@ -85,9 +216,9 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["enable_route_propagation"] = field - field = data.get("pairing_key", None) + field = data.get("vlan", None) if field is not None: - args["pairing_key"] = field + args["vlan"] = field field = data.get("region", None) if field is not None: @@ -117,11 +248,29 @@ def unmarshal_Link(data: Any) -> Link: else: args["updated_at"] = None - field = data.get("disapproved_reason", None) + field = data.get("partner", None) if field is not None: - args["disapproved_reason"] = field + args["partner"] = unmarshal_PartnerHost(field) else: - args["disapproved_reason"] = None + args["partner"] = None + + field = data.get("self", None) + if field is not None: + args["self_"] = unmarshal_SelfHost(field) + else: + args["self_"] = None + + field = data.get("scw_bgp_config", None) + if field is not None: + args["scw_bgp_config"] = unmarshal_BgpConfig(field) + else: + args["scw_bgp_config"] = None + + field = data.get("peer_bgp_config", None) + if field is not None: + args["peer_bgp_config"] = unmarshal_BgpConfig(field) + else: + args["peer_bgp_config"] = None return Link(**args) @@ -267,6 +416,31 @@ def unmarshal_RoutingPolicy(data: Any) -> RoutingPolicy: return RoutingPolicy(**args) +def unmarshal_ListDedicatedConnectionsResponse( + data: Any, +) -> ListDedicatedConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDedicatedConnectionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_DedicatedConnection(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDedicatedConnectionsResponse(**args) + + def unmarshal_ListLinksResponse(data: Any) -> ListLinksResponse: if not isinstance(data, dict): raise TypeError( @@ -381,8 +555,7 @@ def marshal_CreateLinkRequest( output.update( resolve_one_of( [ - OneOfPossibility("dedicated", request.dedicated), - OneOfPossibility("port_id", request.port_id), + OneOfPossibility("connection_id", request.connection_id), OneOfPossibility("partner_id", request.partner_id), ] ), diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/types.py b/scaleway-async/scaleway_async/interlink/v1beta1/types.py index 6731f71d9..fe2f1c0f1 100644 --- a/scaleway-async/scaleway_async/interlink/v1beta1/types.py +++ b/scaleway-async/scaleway_async/interlink/v1beta1/types.py @@ -24,6 +24,28 @@ def __str__(self) -> str: return str(self.value) +class DedicatedConnectionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATED = "created" + CONFIGURING = "configuring" + FAILED = "failed" + ACTIVE = "active" + DISABLED = "disabled" + DELETED = "deleted" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class LinkKind(str, Enum, metaclass=StrEnumMeta): + HOSTED = "hosted" + SELF_HOSTED = "self_hosted" + + def __str__(self) -> str: + return str(self.value) + + class LinkStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_LINK_STATUS = "unknown_link_status" CONFIGURING = "configuring" @@ -43,6 +65,20 @@ def __str__(self) -> str: return str(self.value) +class ListDedicatedConnectionsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + UPDATED_AT_ASC = "updated_at_asc" + UPDATED_AT_DESC = "updated_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListLinksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -81,6 +117,118 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class BgpConfig: + asn: int + """ + AS Number of the BGP peer. + """ + + ipv4: str + """ + IPv4 address of the BGP peer. + """ + + ipv6: str + """ + IPv6 address of the BGP peer. + """ + + +@dataclass +class PartnerHost: + partner_id: str + """ + ID of the partner facilitating the link. + """ + + pairing_key: str + """ + Used to identify a link from a user or partner's point of view. + """ + + disapproved_reason: Optional[str] + """ + Reason given by partner to explain why they did not approve the request for a hosted link. + """ + + +@dataclass +class SelfHost: + connection_id: str + """ + Dedicated physical connection supporting the link. + """ + + +@dataclass +class DedicatedConnection: + id: str + """ + Unique identifier of the dedicated connection. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + status: DedicatedConnectionStatus + """ + Status of the dedicated connection. + """ + + name: str + """ + Name of the dedicated connection. + """ + + tags: List[str] + """ + List of tags associated with the dedicated connection. + """ + + pop_id: str + """ + ID of the PoP where the dedicated connection is located. + """ + + bandwidth_mbps: int + """ + Bandwidth size of the dedicated connection. + """ + + available_link_bandwidths: List[int] + """ + Size of the links supported on this dedicated connection. + """ + + region: ScwRegion + """ + Region of the dedicated connection. + """ + + created_at: Optional[datetime] + """ + Creation date of the dedicated connection. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the dedicated connection. + """ + + demarcation_info: Optional[str] + """ + Demarcation details required by the data center to set up the supporting Cross Connect. This generally includes the physical space in the facility, the cabinet or rack the connection should land in, the patch panel to go in, the port designation, and the media type. + """ + + @dataclass class Link: id: str @@ -110,7 +258,7 @@ class Link: pop_id: str """ - ID of the PoP where the link's corresponding port is located. + ID of the PoP where the link's corresponding connection is located. """ bandwidth_mbps: int @@ -118,11 +266,6 @@ class Link: Rate limited bandwidth of the link. """ - partner_id: Optional[str] - """ - ID of the partner facilitating this link. - """ - status: LinkStatus """ Status of the link. @@ -143,9 +286,9 @@ class Link: Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint. """ - pairing_key: str + vlan: int """ - Used to identify a link from a user or partner's point of view. + VLAN of the link. """ region: ScwRegion @@ -173,11 +316,20 @@ class Link: Last modification date of the link. """ - disapproved_reason: Optional[str] + scw_bgp_config: Optional[BgpConfig] """ - Reason given by partner to explain why they did not approve the request for a hosted link. + BGP configuration on Scaleway's side. + """ + + peer_bgp_config: Optional[BgpConfig] + """ + BGP configuration on peer's side (on-premises or other hosting provider). """ + partner: Optional[PartnerHost] + + self_: Optional[SelfHost] + @dataclass class Partner: @@ -251,7 +403,7 @@ class Pop: available_link_bandwidths_mbps: List[int] """ - Available bandwidth in Mbits/s for future hosted_links from available ports in this PoP. + Available bandwidth in Mbits/s for future hosted links from available connections in this PoP. """ region: ScwRegion @@ -363,7 +515,7 @@ class CreateLinkRequest: bandwidth_mbps: int """ - Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the connection. """ region: Optional[ScwRegion] @@ -381,9 +533,7 @@ class CreateLinkRequest: List of tags to apply to the link. """ - dedicated: Optional[bool] - - port_id: Optional[str] + connection_id: Optional[str] partner_id: Optional[str] @@ -499,6 +649,19 @@ class EnableRoutePropagationRequest: """ +@dataclass +class GetDedicatedConnectionRequest: + connection_id: str + """ + ID of connection to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetLinkRequest: link_id: str @@ -551,6 +714,77 @@ class GetRoutingPolicyRequest: """ +@dataclass +class ListDedicatedConnectionsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of connections to return per page. + """ + + project_id: Optional[str] + """ + Project ID to filter for. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. + """ + + name: Optional[str] + """ + Link name to filter for. + """ + + tags: Optional[List[str]] + """ + Tags to filter for. + """ + + status: Optional[DedicatedConnectionStatus] + """ + Connection status to filter for. + """ + + bandwidth_mbps: Optional[int] + """ + Filter for dedicated connections with this bandwidth size. + """ + + pop_id: Optional[str] + """ + Filter for dedicated connections present in this PoP. + """ + + +@dataclass +class ListDedicatedConnectionsResponse: + connections: List[DedicatedConnection] + """ + List of connections on current page. + """ + + total_count: int + """ + Total number of connections returned. + """ + + @dataclass class ListLinksRequest: region: Optional[ScwRegion] @@ -610,7 +844,7 @@ class ListLinksRequest: pop_id: Optional[str] """ - Filter for links attached to this PoP (via ports). + Filter for links attached to this PoP (via connections). """ bandwidth_mbps: Optional[int] @@ -638,6 +872,16 @@ class ListLinksRequest: Filter for the link with this pairing_key. """ + kind: Optional[LinkKind] + """ + Filter for hosted or self-hosted links. + """ + + connection_id: Optional[str] + """ + Filter for links self-hosted on this connection. + """ + @dataclass class ListLinksResponse: @@ -676,7 +920,7 @@ class ListPartnersRequest: pop_ids: Optional[List[str]] """ - Filter for partners present (offering a port) in one of these PoPs. + Filter for partners present (offering a connection) in one of these PoPs. """ @@ -727,12 +971,17 @@ class ListPopsRequest: partner_id: Optional[str] """ - Filter for PoPs hosting an available shared port from this partner. + Filter for PoPs hosting an available shared connection from this partner. """ link_bandwidth_mbps: Optional[int] """ - Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + """ + + dedicated_available: Optional[bool] + """ + Filter for PoPs with a dedicated connection available for self-hosted links. """ diff --git a/scaleway/scaleway/interlink/v1beta1/__init__.py b/scaleway/scaleway/interlink/v1beta1/__init__.py index 479a0815b..66cc0eaba 100644 --- a/scaleway/scaleway/interlink/v1beta1/__init__.py +++ b/scaleway/scaleway/interlink/v1beta1/__init__.py @@ -1,11 +1,20 @@ # This file was automatically generated. DO NOT EDIT. # If you have any remark or suggestion do not hesitate to open an issue. from .types import BgpStatus +from .types import DedicatedConnectionStatus +from .content import DEDICATED_CONNECTION_TRANSIENT_STATUSES +from .types import LinkKind from .types import LinkStatus +from .content import LINK_TRANSIENT_STATUSES +from .types import ListDedicatedConnectionsRequestOrderBy from .types import ListLinksRequestOrderBy from .types import ListPartnersRequestOrderBy from .types import ListPopsRequestOrderBy from .types import ListRoutingPoliciesRequestOrderBy +from .types import BgpConfig +from .types import PartnerHost +from .types import SelfHost +from .types import DedicatedConnection from .types import Link from .types import Partner from .types import Pop @@ -20,10 +29,13 @@ from .types import DetachVpcRequest from .types import DisableRoutePropagationRequest from .types import EnableRoutePropagationRequest +from .types import GetDedicatedConnectionRequest from .types import GetLinkRequest from .types import GetPartnerRequest from .types import GetPopRequest from .types import GetRoutingPolicyRequest +from .types import ListDedicatedConnectionsRequest +from .types import ListDedicatedConnectionsResponse from .types import ListLinksRequest from .types import ListLinksResponse from .types import ListPartnersRequest @@ -38,11 +50,20 @@ __all__ = [ "BgpStatus", + "DedicatedConnectionStatus", + "DEDICATED_CONNECTION_TRANSIENT_STATUSES", + "LinkKind", "LinkStatus", + "LINK_TRANSIENT_STATUSES", + "ListDedicatedConnectionsRequestOrderBy", "ListLinksRequestOrderBy", "ListPartnersRequestOrderBy", "ListPopsRequestOrderBy", "ListRoutingPoliciesRequestOrderBy", + "BgpConfig", + "PartnerHost", + "SelfHost", + "DedicatedConnection", "Link", "Partner", "Pop", @@ -57,10 +78,13 @@ "DetachVpcRequest", "DisableRoutePropagationRequest", "EnableRoutePropagationRequest", + "GetDedicatedConnectionRequest", "GetLinkRequest", "GetPartnerRequest", "GetPopRequest", "GetRoutingPolicyRequest", + "ListDedicatedConnectionsRequest", + "ListDedicatedConnectionsResponse", "ListLinksRequest", "ListLinksResponse", "ListPartnersRequest", diff --git a/scaleway/scaleway/interlink/v1beta1/api.py b/scaleway/scaleway/interlink/v1beta1/api.py index 9df780597..f7b89eb04 100644 --- a/scaleway/scaleway/interlink/v1beta1/api.py +++ b/scaleway/scaleway/interlink/v1beta1/api.py @@ -8,12 +8,17 @@ Region as ScwRegion, ) from scaleway_core.utils import ( + WaitForOptions, validate_path_param, fetch_all_pages, + wait_for_resource, ) from .types import ( BgpStatus, + DedicatedConnectionStatus, + LinkKind, LinkStatus, + ListDedicatedConnectionsRequestOrderBy, ListLinksRequestOrderBy, ListPartnersRequestOrderBy, ListPopsRequestOrderBy, @@ -22,7 +27,9 @@ AttachVpcRequest, CreateLinkRequest, CreateRoutingPolicyRequest, + DedicatedConnection, Link, + ListDedicatedConnectionsResponse, ListLinksResponse, ListPartnersResponse, ListPopsResponse, @@ -33,11 +40,17 @@ UpdateLinkRequest, UpdateRoutingPolicyRequest, ) +from .content import ( + DEDICATED_CONNECTION_TRANSIENT_STATUSES, + LINK_TRANSIENT_STATUSES, +) from .marshalling import ( + unmarshal_DedicatedConnection, unmarshal_Link, unmarshal_Partner, unmarshal_Pop, unmarshal_RoutingPolicy, + unmarshal_ListDedicatedConnectionsResponse, unmarshal_ListLinksResponse, unmarshal_ListPartnersResponse, unmarshal_ListPopsResponse, @@ -56,6 +69,197 @@ class InterlinkV1Beta1API(API): This API allows you to manage your Scaleway InterLink, to connect your on-premises infrastructure with your Scaleway VPC. """ + def list_dedicated_connections( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + status: Optional[DedicatedConnectionStatus] = None, + bandwidth_mbps: Optional[int] = None, + pop_id: Optional[str] = None, + ) -> ListDedicatedConnectionsResponse: + """ + List dedicated connections. + For self-hosted users, list their dedicated physical connections in a given region. By default, the connections returned in the list are ordered by name in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Link name to filter for. + :param tags: Tags to filter for. + :param status: Connection status to filter for. + :param bandwidth_mbps: Filter for dedicated connections with this bandwidth size. + :param pop_id: Filter for dedicated connections present in this PoP. + :return: :class:`ListDedicatedConnectionsResponse ` + + Usage: + :: + + result = api.list_dedicated_connections() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/dedicated-connections", + params={ + "bandwidth_mbps": bandwidth_mbps, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "pop_id": pop_id, + "project_id": project_id or self.client.default_project_id, + "status": status, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListDedicatedConnectionsResponse(res.json()) + + def list_dedicated_connections_all( + self, + *, + region: Optional[ScwRegion] = None, + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + project_id: Optional[str] = None, + organization_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + status: Optional[DedicatedConnectionStatus] = None, + bandwidth_mbps: Optional[int] = None, + pop_id: Optional[str] = None, + ) -> List[DedicatedConnection]: + """ + List dedicated connections. + For self-hosted users, list their dedicated physical connections in a given region. By default, the connections returned in the list are ordered by name in ascending order, though this can be modified via the `order_by` field. + :param region: Region to target. If none is passed will use default region from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Link name to filter for. + :param tags: Tags to filter for. + :param status: Connection status to filter for. + :param bandwidth_mbps: Filter for dedicated connections with this bandwidth size. + :param pop_id: Filter for dedicated connections present in this PoP. + :return: :class:`List[DedicatedConnection] ` + + Usage: + :: + + result = api.list_dedicated_connections_all() + """ + + return fetch_all_pages( + type=ListDedicatedConnectionsResponse, + key="connections", + fetcher=self.list_dedicated_connections, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "project_id": project_id, + "organization_id": organization_id, + "name": name, + "tags": tags, + "status": status, + "bandwidth_mbps": bandwidth_mbps, + "pop_id": pop_id, + }, + ) + + def get_dedicated_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> DedicatedConnection: + """ + Get a dedicated connection. + For self-hosted users, get a dedicated physical connection corresponding to the given ID. The response object includes information such as the connection's name, status and total bandwidth. + :param connection_id: ID of connection to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DedicatedConnection ` + + Usage: + :: + + result = api.get_dedicated_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/dedicated-connections/{param_connection_id}", + ) + + self._throw_on_error(res) + return unmarshal_DedicatedConnection(res.json()) + + def wait_for_dedicated_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[DedicatedConnection, bool]] = None, + ) -> DedicatedConnection: + """ + Get a dedicated connection. + For self-hosted users, get a dedicated physical connection corresponding to the given ID. The response object includes information such as the connection's name, status and total bandwidth. + :param connection_id: ID of connection to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`DedicatedConnection ` + + Usage: + :: + + result = api.get_dedicated_connection( + connection_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in DEDICATED_CONNECTION_TRANSIENT_STATUSES + ) + + return wait_for_resource( + fetcher=self.get_dedicated_connection, + options=options, + args={ + "connection_id": connection_id, + "region": region, + }, + ) + def list_partners( self, *, @@ -72,7 +276,7 @@ def list_partners( :param order_by: Order in which to return results. :param page: Page number to return. :param page_size: Maximum number of partners to return per page. - :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :param pop_ids: Filter for partners present (offering a connection) in one of these PoPs. :return: :class:`ListPartnersResponse ` Usage: @@ -115,7 +319,7 @@ def list_partners_all( :param order_by: Order in which to return results. :param page: Page number to return. :param page_size: Maximum number of partners to return per page. - :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :param pop_ids: Filter for partners present (offering a connection) in one of these PoPs. :return: :class:`List[Partner] ` Usage: @@ -182,6 +386,7 @@ def list_pops( hosting_provider_name: Optional[str] = None, partner_id: Optional[str] = None, link_bandwidth_mbps: Optional[int] = None, + dedicated_available: Optional[bool] = None, ) -> ListPopsResponse: """ List PoPs. @@ -192,8 +397,9 @@ def list_pops( :param page_size: Maximum number of PoPs to return per page. :param name: PoP name to filter for. :param hosting_provider_name: Hosting provider name to filter for. - :param partner_id: Filter for PoPs hosting an available shared port from this partner. - :param link_bandwidth_mbps: Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param partner_id: Filter for PoPs hosting an available shared connection from this partner. + :param link_bandwidth_mbps: Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param dedicated_available: Filter for PoPs with a dedicated connection available for self-hosted links. :return: :class:`ListPopsResponse ` Usage: @@ -210,6 +416,7 @@ def list_pops( "GET", f"/interlink/v1beta1/regions/{param_region}/pops", params={ + "dedicated_available": dedicated_available, "hosting_provider_name": hosting_provider_name, "link_bandwidth_mbps": link_bandwidth_mbps, "name": name, @@ -234,6 +441,7 @@ def list_pops_all( hosting_provider_name: Optional[str] = None, partner_id: Optional[str] = None, link_bandwidth_mbps: Optional[int] = None, + dedicated_available: Optional[bool] = None, ) -> List[Pop]: """ List PoPs. @@ -244,8 +452,9 @@ def list_pops_all( :param page_size: Maximum number of PoPs to return per page. :param name: PoP name to filter for. :param hosting_provider_name: Hosting provider name to filter for. - :param partner_id: Filter for PoPs hosting an available shared port from this partner. - :param link_bandwidth_mbps: Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param partner_id: Filter for PoPs hosting an available shared connection from this partner. + :param link_bandwidth_mbps: Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + :param dedicated_available: Filter for PoPs with a dedicated connection available for self-hosted links. :return: :class:`List[Pop] ` Usage: @@ -267,6 +476,7 @@ def list_pops_all( "hosting_provider_name": hosting_provider_name, "partner_id": partner_id, "link_bandwidth_mbps": link_bandwidth_mbps, + "dedicated_available": dedicated_available, }, ) @@ -324,6 +534,8 @@ def list_links( vpc_id: Optional[str] = None, routing_policy_id: Optional[str] = None, pairing_key: Optional[str] = None, + kind: Optional[LinkKind] = None, + connection_id: Optional[str] = None, ) -> ListLinksResponse: """ List links. @@ -339,12 +551,14 @@ def list_links( :param status: Link status to filter for. :param bgp_v4_status: BGP IPv4 status to filter for. :param bgp_v6_status: BGP IPv6 status to filter for. - :param pop_id: Filter for links attached to this PoP (via ports). + :param pop_id: Filter for links attached to this PoP (via connections). :param bandwidth_mbps: Filter for link bandwidth (in Mbps). :param partner_id: Filter for links hosted by this partner. :param vpc_id: Filter for links attached to this VPC. :param routing_policy_id: Filter for links using this routing policy. :param pairing_key: Filter for the link with this pairing_key. + :param kind: Filter for hosted or self-hosted links. + :param connection_id: Filter for links self-hosted on this connection. :return: :class:`ListLinksResponse ` Usage: @@ -364,6 +578,8 @@ def list_links( "bandwidth_mbps": bandwidth_mbps, "bgp_v4_status": bgp_v4_status, "bgp_v6_status": bgp_v6_status, + "connection_id": connection_id, + "kind": kind, "name": name, "order_by": order_by, "organization_id": organization_id @@ -404,6 +620,8 @@ def list_links_all( vpc_id: Optional[str] = None, routing_policy_id: Optional[str] = None, pairing_key: Optional[str] = None, + kind: Optional[LinkKind] = None, + connection_id: Optional[str] = None, ) -> List[Link]: """ List links. @@ -419,12 +637,14 @@ def list_links_all( :param status: Link status to filter for. :param bgp_v4_status: BGP IPv4 status to filter for. :param bgp_v6_status: BGP IPv6 status to filter for. - :param pop_id: Filter for links attached to this PoP (via ports). + :param pop_id: Filter for links attached to this PoP (via connections). :param bandwidth_mbps: Filter for link bandwidth (in Mbps). :param partner_id: Filter for links hosted by this partner. :param vpc_id: Filter for links attached to this VPC. :param routing_policy_id: Filter for links using this routing policy. :param pairing_key: Filter for the link with this pairing_key. + :param kind: Filter for hosted or self-hosted links. + :param connection_id: Filter for links self-hosted on this connection. :return: :class:`List[Link] ` Usage: @@ -455,6 +675,8 @@ def list_links_all( "vpc_id": vpc_id, "routing_policy_id": routing_policy_id, "pairing_key": pairing_key, + "kind": kind, + "connection_id": connection_id, }, ) @@ -466,7 +688,7 @@ def get_link( ) -> Link: """ Get a link. - Get a link (InterLink connection) for the given link ID. The response object includes information about the link's various configuration details. + Get a link (InterLink session / logical InterLink resource) for the given link ID. The response object includes information about the link's various configuration details. :param link_id: ID of the link to get. :param region: Region to target. If none is passed will use default region from the config. :return: :class:`Link ` @@ -492,6 +714,43 @@ def get_link( self._throw_on_error(res) return unmarshal_Link(res.json()) + def wait_for_link( + self, + *, + link_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[Link, bool]] = None, + ) -> Link: + """ + Get a link. + Get a link (InterLink session / logical InterLink resource) for the given link ID. The response object includes information about the link's various configuration details. + :param link_id: ID of the link to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.get_link( + link_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in LINK_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_link, + options=options, + args={ + "link_id": link_id, + "region": region, + }, + ) + def create_link( self, *, @@ -501,25 +760,22 @@ def create_link( region: Optional[ScwRegion] = None, project_id: Optional[str] = None, tags: Optional[List[str]] = None, - dedicated: Optional[bool] = None, - port_id: Optional[str] = None, + connection_id: Optional[str] = None, partner_id: Optional[str] = None, ) -> Link: """ Create a link. - Create a link (InterLink connection) in a given PoP, specifying its various configuration details. For the moment only hosted links (faciliated by partners) are available, though in the future dedicated and shared links will also be possible. + Create a link (InterLink session / logical InterLink resource) in a given PoP, specifying its various configuration details. Links can either be hosted (faciliated by partners' shared physical connections) or self-hosted (for users who have purchased a dedicated physical connection). :param name: Name of the link. :param pop_id: PoP (location) where the link will be created. - :param bandwidth_mbps: Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + :param bandwidth_mbps: Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the connection. :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 link in. :param tags: List of tags to apply to the link. - :param dedicated: If true, a dedicated link (1 link per port, dedicated to one customer) will be crated. It is not necessary to specify a `port_id` or `partner_id`. A new port will created and assigned to the link. Note that Scaleway has not yet enabled the creation of dedicated links, this field is reserved for future use. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. - :param port_id: If set, a shared link (N links per port, one of which is this customer's port) will be created. As the customer, specify the ID of the port you already have for this link. Note that shared links are not currently available. Note that Scaleway has not yet enabled the creation of shared links, this field is reserved for future use. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. - :param partner_id: If set, a hosted link (N links per port on a partner port) will be created. Specify the ID of the chosen partner, who already has a shareable port with available bandwidth. Note that this is currently the only type of link offered by Scaleway, and therefore this field must be set when creating a link. - One-Of ('link_kind'): at most one of 'dedicated', 'port_id', 'partner_id' could be set. + :param connection_id: If set, creates a self-hosted link using this dedicated physical connection. As the customer, specify the ID of the physical connection you already have for this link. + One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set. + :param partner_id: If set, creates a hosted link on a partner's connection. Specify the ID of the chosen partner, who already has a shared connection with available bandwidth. + One-Of ('host'): at most one of 'connection_id', 'partner_id' could be set. :return: :class:`Link ` Usage: @@ -547,8 +803,7 @@ def create_link( region=region, project_id=project_id, tags=tags, - dedicated=dedicated, - port_id=port_id, + connection_id=connection_id, partner_id=partner_id, ), self.client, diff --git a/scaleway/scaleway/interlink/v1beta1/content.py b/scaleway/scaleway/interlink/v1beta1/content.py new file mode 100644 index 000000000..dea5950ee --- /dev/null +++ b/scaleway/scaleway/interlink/v1beta1/content.py @@ -0,0 +1,21 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + DedicatedConnectionStatus, + LinkStatus, +) + +DEDICATED_CONNECTION_TRANSIENT_STATUSES: List[DedicatedConnectionStatus] = [ + DedicatedConnectionStatus.CONFIGURING, +] +""" +Lists transient statutes of the enum :class:`DedicatedConnectionStatus `. +""" +LINK_TRANSIENT_STATUSES: List[LinkStatus] = [ + LinkStatus.CONFIGURING, +] +""" +Lists transient statutes of the enum :class:`LinkStatus `. +""" diff --git a/scaleway/scaleway/interlink/v1beta1/marshalling.py b/scaleway/scaleway/interlink/v1beta1/marshalling.py index d8b2c084b..ed47ee5dd 100644 --- a/scaleway/scaleway/interlink/v1beta1/marshalling.py +++ b/scaleway/scaleway/interlink/v1beta1/marshalling.py @@ -10,10 +10,15 @@ resolve_one_of, ) from .types import ( + DedicatedConnection, + BgpConfig, + PartnerHost, + SelfHost, Link, Partner, Pop, RoutingPolicy, + ListDedicatedConnectionsResponse, ListLinksResponse, ListPartnersResponse, ListPopsResponse, @@ -27,10 +32,10 @@ ) -def unmarshal_Link(data: Any) -> Link: +def unmarshal_DedicatedConnection(data: Any) -> DedicatedConnection: if not isinstance(data, dict): raise TypeError( - "Unmarshalling the type 'Link' failed as data isn't a dictionary." + "Unmarshalling the type 'DedicatedConnection' failed as data isn't a dictionary." ) args: Dict[str, Any] = {} @@ -47,6 +52,10 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["organization_id"] = field + field = data.get("status", None) + if field is not None: + args["status"] = field + field = data.get("name", None) if field is not None: args["name"] = field @@ -63,11 +72,133 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["bandwidth_mbps"] = field + field = data.get("available_link_bandwidths", None) + if field is not None: + args["available_link_bandwidths"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("demarcation_info", None) + if field is not None: + args["demarcation_info"] = field + else: + args["demarcation_info"] = None + + return DedicatedConnection(**args) + + +def unmarshal_BgpConfig(data: Any) -> BgpConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BgpConfig' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = field + + field = data.get("ipv6", None) + if field is not None: + args["ipv6"] = field + + return BgpConfig(**args) + + +def unmarshal_PartnerHost(data: Any) -> PartnerHost: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PartnerHost' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + field = data.get("partner_id", None) if field is not None: args["partner_id"] = field + + field = data.get("pairing_key", None) + if field is not None: + args["pairing_key"] = field + + field = data.get("disapproved_reason", None) + if field is not None: + args["disapproved_reason"] = field else: - args["partner_id"] = None + args["disapproved_reason"] = None + + return PartnerHost(**args) + + +def unmarshal_SelfHost(data: Any) -> SelfHost: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SelfHost' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connection_id", None) + if field is not None: + args["connection_id"] = field + + return SelfHost(**args) + + +def unmarshal_Link(data: Any) -> Link: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Link' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("pop_id", None) + if field is not None: + args["pop_id"] = field + + field = data.get("bandwidth_mbps", None) + if field is not None: + args["bandwidth_mbps"] = field field = data.get("status", None) if field is not None: @@ -85,9 +216,9 @@ def unmarshal_Link(data: Any) -> Link: if field is not None: args["enable_route_propagation"] = field - field = data.get("pairing_key", None) + field = data.get("vlan", None) if field is not None: - args["pairing_key"] = field + args["vlan"] = field field = data.get("region", None) if field is not None: @@ -117,11 +248,29 @@ def unmarshal_Link(data: Any) -> Link: else: args["updated_at"] = None - field = data.get("disapproved_reason", None) + field = data.get("partner", None) if field is not None: - args["disapproved_reason"] = field + args["partner"] = unmarshal_PartnerHost(field) else: - args["disapproved_reason"] = None + args["partner"] = None + + field = data.get("self", None) + if field is not None: + args["self_"] = unmarshal_SelfHost(field) + else: + args["self_"] = None + + field = data.get("scw_bgp_config", None) + if field is not None: + args["scw_bgp_config"] = unmarshal_BgpConfig(field) + else: + args["scw_bgp_config"] = None + + field = data.get("peer_bgp_config", None) + if field is not None: + args["peer_bgp_config"] = unmarshal_BgpConfig(field) + else: + args["peer_bgp_config"] = None return Link(**args) @@ -267,6 +416,31 @@ def unmarshal_RoutingPolicy(data: Any) -> RoutingPolicy: return RoutingPolicy(**args) +def unmarshal_ListDedicatedConnectionsResponse( + data: Any, +) -> ListDedicatedConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListDedicatedConnectionsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_DedicatedConnection(v) for v in field] + if field is not None + else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListDedicatedConnectionsResponse(**args) + + def unmarshal_ListLinksResponse(data: Any) -> ListLinksResponse: if not isinstance(data, dict): raise TypeError( @@ -381,8 +555,7 @@ def marshal_CreateLinkRequest( output.update( resolve_one_of( [ - OneOfPossibility("dedicated", request.dedicated), - OneOfPossibility("port_id", request.port_id), + OneOfPossibility("connection_id", request.connection_id), OneOfPossibility("partner_id", request.partner_id), ] ), diff --git a/scaleway/scaleway/interlink/v1beta1/types.py b/scaleway/scaleway/interlink/v1beta1/types.py index 6731f71d9..fe2f1c0f1 100644 --- a/scaleway/scaleway/interlink/v1beta1/types.py +++ b/scaleway/scaleway/interlink/v1beta1/types.py @@ -24,6 +24,28 @@ def __str__(self) -> str: return str(self.value) +class DedicatedConnectionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATED = "created" + CONFIGURING = "configuring" + FAILED = "failed" + ACTIVE = "active" + DISABLED = "disabled" + DELETED = "deleted" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class LinkKind(str, Enum, metaclass=StrEnumMeta): + HOSTED = "hosted" + SELF_HOSTED = "self_hosted" + + def __str__(self) -> str: + return str(self.value) + + class LinkStatus(str, Enum, metaclass=StrEnumMeta): UNKNOWN_LINK_STATUS = "unknown_link_status" CONFIGURING = "configuring" @@ -43,6 +65,20 @@ def __str__(self) -> str: return str(self.value) +class ListDedicatedConnectionsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + UPDATED_AT_ASC = "updated_at_asc" + UPDATED_AT_DESC = "updated_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + class ListLinksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): CREATED_AT_ASC = "created_at_asc" CREATED_AT_DESC = "created_at_desc" @@ -81,6 +117,118 @@ def __str__(self) -> str: return str(self.value) +@dataclass +class BgpConfig: + asn: int + """ + AS Number of the BGP peer. + """ + + ipv4: str + """ + IPv4 address of the BGP peer. + """ + + ipv6: str + """ + IPv6 address of the BGP peer. + """ + + +@dataclass +class PartnerHost: + partner_id: str + """ + ID of the partner facilitating the link. + """ + + pairing_key: str + """ + Used to identify a link from a user or partner's point of view. + """ + + disapproved_reason: Optional[str] + """ + Reason given by partner to explain why they did not approve the request for a hosted link. + """ + + +@dataclass +class SelfHost: + connection_id: str + """ + Dedicated physical connection supporting the link. + """ + + +@dataclass +class DedicatedConnection: + id: str + """ + Unique identifier of the dedicated connection. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + status: DedicatedConnectionStatus + """ + Status of the dedicated connection. + """ + + name: str + """ + Name of the dedicated connection. + """ + + tags: List[str] + """ + List of tags associated with the dedicated connection. + """ + + pop_id: str + """ + ID of the PoP where the dedicated connection is located. + """ + + bandwidth_mbps: int + """ + Bandwidth size of the dedicated connection. + """ + + available_link_bandwidths: List[int] + """ + Size of the links supported on this dedicated connection. + """ + + region: ScwRegion + """ + Region of the dedicated connection. + """ + + created_at: Optional[datetime] + """ + Creation date of the dedicated connection. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the dedicated connection. + """ + + demarcation_info: Optional[str] + """ + Demarcation details required by the data center to set up the supporting Cross Connect. This generally includes the physical space in the facility, the cabinet or rack the connection should land in, the patch panel to go in, the port designation, and the media type. + """ + + @dataclass class Link: id: str @@ -110,7 +258,7 @@ class Link: pop_id: str """ - ID of the PoP where the link's corresponding port is located. + ID of the PoP where the link's corresponding connection is located. """ bandwidth_mbps: int @@ -118,11 +266,6 @@ class Link: Rate limited bandwidth of the link. """ - partner_id: Optional[str] - """ - ID of the partner facilitating this link. - """ - status: LinkStatus """ Status of the link. @@ -143,9 +286,9 @@ class Link: Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint. """ - pairing_key: str + vlan: int """ - Used to identify a link from a user or partner's point of view. + VLAN of the link. """ region: ScwRegion @@ -173,11 +316,20 @@ class Link: Last modification date of the link. """ - disapproved_reason: Optional[str] + scw_bgp_config: Optional[BgpConfig] """ - Reason given by partner to explain why they did not approve the request for a hosted link. + BGP configuration on Scaleway's side. + """ + + peer_bgp_config: Optional[BgpConfig] + """ + BGP configuration on peer's side (on-premises or other hosting provider). """ + partner: Optional[PartnerHost] + + self_: Optional[SelfHost] + @dataclass class Partner: @@ -251,7 +403,7 @@ class Pop: available_link_bandwidths_mbps: List[int] """ - Available bandwidth in Mbits/s for future hosted_links from available ports in this PoP. + Available bandwidth in Mbits/s for future hosted links from available connections in this PoP. """ region: ScwRegion @@ -363,7 +515,7 @@ class CreateLinkRequest: bandwidth_mbps: int """ - Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the connection. """ region: Optional[ScwRegion] @@ -381,9 +533,7 @@ class CreateLinkRequest: List of tags to apply to the link. """ - dedicated: Optional[bool] - - port_id: Optional[str] + connection_id: Optional[str] partner_id: Optional[str] @@ -499,6 +649,19 @@ class EnableRoutePropagationRequest: """ +@dataclass +class GetDedicatedConnectionRequest: + connection_id: str + """ + ID of connection to get. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class GetLinkRequest: link_id: str @@ -551,6 +714,77 @@ class GetRoutingPolicyRequest: """ +@dataclass +class ListDedicatedConnectionsRequest: + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListDedicatedConnectionsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of connections to return per page. + """ + + project_id: Optional[str] + """ + Project ID to filter for. + """ + + organization_id: Optional[str] + """ + Organization ID to filter for. + """ + + name: Optional[str] + """ + Link name to filter for. + """ + + tags: Optional[List[str]] + """ + Tags to filter for. + """ + + status: Optional[DedicatedConnectionStatus] + """ + Connection status to filter for. + """ + + bandwidth_mbps: Optional[int] + """ + Filter for dedicated connections with this bandwidth size. + """ + + pop_id: Optional[str] + """ + Filter for dedicated connections present in this PoP. + """ + + +@dataclass +class ListDedicatedConnectionsResponse: + connections: List[DedicatedConnection] + """ + List of connections on current page. + """ + + total_count: int + """ + Total number of connections returned. + """ + + @dataclass class ListLinksRequest: region: Optional[ScwRegion] @@ -610,7 +844,7 @@ class ListLinksRequest: pop_id: Optional[str] """ - Filter for links attached to this PoP (via ports). + Filter for links attached to this PoP (via connections). """ bandwidth_mbps: Optional[int] @@ -638,6 +872,16 @@ class ListLinksRequest: Filter for the link with this pairing_key. """ + kind: Optional[LinkKind] + """ + Filter for hosted or self-hosted links. + """ + + connection_id: Optional[str] + """ + Filter for links self-hosted on this connection. + """ + @dataclass class ListLinksResponse: @@ -676,7 +920,7 @@ class ListPartnersRequest: pop_ids: Optional[List[str]] """ - Filter for partners present (offering a port) in one of these PoPs. + Filter for partners present (offering a connection) in one of these PoPs. """ @@ -727,12 +971,17 @@ class ListPopsRequest: partner_id: Optional[str] """ - Filter for PoPs hosting an available shared port from this partner. + Filter for PoPs hosting an available shared connection from this partner. """ link_bandwidth_mbps: Optional[int] """ - Filter for PoPs with a shared port allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + Filter for PoPs with a shared connection allowing this bandwidth size. Note that we cannot guarantee that PoPs returned will have available capacity. + """ + + dedicated_available: Optional[bool] + """ + Filter for PoPs with a dedicated connection available for self-hosted links. """