From eec741094352edccb55bc813583a2f26cc65185c Mon Sep 17 00:00:00 2001 From: scaleway-bot Date: Mon, 16 Dec 2024 14:06:50 +0000 Subject: [PATCH] feat: update generated APIs --- .../scaleway_async/interlink/__init__.py | 2 + .../interlink/v1beta1/__init__.py | 75 ++ .../scaleway_async/interlink/v1beta1/api.py | 1147 +++++++++++++++++ .../interlink/v1beta1/marshalling.py | 456 +++++++ .../scaleway_async/interlink/v1beta1/types.py | 845 ++++++++++++ scaleway/scaleway/interlink/__init__.py | 2 + .../scaleway/interlink/v1beta1/__init__.py | 75 ++ scaleway/scaleway/interlink/v1beta1/api.py | 1147 +++++++++++++++++ .../scaleway/interlink/v1beta1/marshalling.py | 456 +++++++ scaleway/scaleway/interlink/v1beta1/types.py | 845 ++++++++++++ 10 files changed, 5050 insertions(+) create mode 100644 scaleway-async/scaleway_async/interlink/__init__.py create mode 100644 scaleway-async/scaleway_async/interlink/v1beta1/__init__.py create mode 100644 scaleway-async/scaleway_async/interlink/v1beta1/api.py create mode 100644 scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py create mode 100644 scaleway-async/scaleway_async/interlink/v1beta1/types.py create mode 100644 scaleway/scaleway/interlink/__init__.py create mode 100644 scaleway/scaleway/interlink/v1beta1/__init__.py create mode 100644 scaleway/scaleway/interlink/v1beta1/api.py create mode 100644 scaleway/scaleway/interlink/v1beta1/marshalling.py create mode 100644 scaleway/scaleway/interlink/v1beta1/types.py diff --git a/scaleway-async/scaleway_async/interlink/__init__.py b/scaleway-async/scaleway_async/interlink/__init__.py new file mode 100644 index 00000000..8b74a5ed --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py b/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py new file mode 100644 index 00000000..479a0815 --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/v1beta1/__init__.py @@ -0,0 +1,75 @@ +# 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 LinkStatus +from .types import ListLinksRequestOrderBy +from .types import ListPartnersRequestOrderBy +from .types import ListPopsRequestOrderBy +from .types import ListRoutingPoliciesRequestOrderBy +from .types import Link +from .types import Partner +from .types import Pop +from .types import RoutingPolicy +from .types import AttachRoutingPolicyRequest +from .types import AttachVpcRequest +from .types import CreateLinkRequest +from .types import CreateRoutingPolicyRequest +from .types import DeleteLinkRequest +from .types import DeleteRoutingPolicyRequest +from .types import DetachRoutingPolicyRequest +from .types import DetachVpcRequest +from .types import DisableRoutePropagationRequest +from .types import EnableRoutePropagationRequest +from .types import GetLinkRequest +from .types import GetPartnerRequest +from .types import GetPopRequest +from .types import GetRoutingPolicyRequest +from .types import ListLinksRequest +from .types import ListLinksResponse +from .types import ListPartnersRequest +from .types import ListPartnersResponse +from .types import ListPopsRequest +from .types import ListPopsResponse +from .types import ListRoutingPoliciesRequest +from .types import ListRoutingPoliciesResponse +from .types import UpdateLinkRequest +from .types import UpdateRoutingPolicyRequest +from .api import InterlinkV1Beta1API + +__all__ = [ + "BgpStatus", + "LinkStatus", + "ListLinksRequestOrderBy", + "ListPartnersRequestOrderBy", + "ListPopsRequestOrderBy", + "ListRoutingPoliciesRequestOrderBy", + "Link", + "Partner", + "Pop", + "RoutingPolicy", + "AttachRoutingPolicyRequest", + "AttachVpcRequest", + "CreateLinkRequest", + "CreateRoutingPolicyRequest", + "DeleteLinkRequest", + "DeleteRoutingPolicyRequest", + "DetachRoutingPolicyRequest", + "DetachVpcRequest", + "DisableRoutePropagationRequest", + "EnableRoutePropagationRequest", + "GetLinkRequest", + "GetPartnerRequest", + "GetPopRequest", + "GetRoutingPolicyRequest", + "ListLinksRequest", + "ListLinksResponse", + "ListPartnersRequest", + "ListPartnersResponse", + "ListPopsRequest", + "ListPopsResponse", + "ListRoutingPoliciesRequest", + "ListRoutingPoliciesResponse", + "UpdateLinkRequest", + "UpdateRoutingPolicyRequest", + "InterlinkV1Beta1API", +] diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/api.py b/scaleway-async/scaleway_async/interlink/v1beta1/api.py new file mode 100644 index 00000000..b52e7794 --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/v1beta1/api.py @@ -0,0 +1,1147 @@ +# 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 scaleway_core.api import API +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + validate_path_param, + fetch_all_pages_async, +) +from .types import ( + BgpStatus, + LinkStatus, + ListLinksRequestOrderBy, + ListPartnersRequestOrderBy, + ListPopsRequestOrderBy, + ListRoutingPoliciesRequestOrderBy, + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + Link, + ListLinksResponse, + ListPartnersResponse, + ListPopsResponse, + ListRoutingPoliciesResponse, + Partner, + Pop, + RoutingPolicy, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +) +from .marshalling import ( + unmarshal_Link, + unmarshal_Partner, + unmarshal_Pop, + unmarshal_RoutingPolicy, + unmarshal_ListLinksResponse, + unmarshal_ListPartnersResponse, + unmarshal_ListPopsResponse, + unmarshal_ListRoutingPoliciesResponse, + marshal_AttachRoutingPolicyRequest, + marshal_AttachVpcRequest, + marshal_CreateLinkRequest, + marshal_CreateRoutingPolicyRequest, + marshal_UpdateLinkRequest, + marshal_UpdateRoutingPolicyRequest, +) + + +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_partners( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPartnersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pop_ids: Optional[List[str]] = None, + ) -> ListPartnersResponse: + """ + List available partners. + List all available partners. By default, the partners 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 partners to return per page. + :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :return: :class:`ListPartnersResponse ` + + Usage: + :: + + result = await api.list_partners() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/partners", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "pop_ids": pop_ids, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPartnersResponse(res.json()) + + async def list_partners_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPartnersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pop_ids: Optional[List[str]] = None, + ) -> List[Partner]: + """ + List available partners. + List all available partners. By default, the partners 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 partners to return per page. + :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :return: :class:`List[Partner] ` + + Usage: + :: + + result = await api.list_partners_all() + """ + + return await fetch_all_pages_async( + type=ListPartnersResponse, + key="partners", + fetcher=self.list_partners, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "pop_ids": pop_ids, + }, + ) + + async def get_partner( + self, + *, + partner_id: str, + region: Optional[Region] = None, + ) -> Partner: + """ + Get a partner. + Get a partner for the given partner IP. The response object includes information such as the partner's name, email address and portal URL. + :param partner_id: ID of partner to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Partner ` + + Usage: + :: + + result = await api.get_partner( + partner_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_partner_id = validate_path_param("partner_id", partner_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/partners/{param_partner_id}", + ) + + self._throw_on_error(res) + return unmarshal_Partner(res.json()) + + async def list_pops( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPopsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + hosting_provider_name: Optional[str] = None, + partner_id: Optional[str] = None, + link_bandwidth_mbps: Optional[int] = None, + ) -> ListPopsResponse: + """ + List PoPs. + List all available PoPs (locations) for a given region. By default, the results are returned in ascending alphabetical order by name. + :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 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. + :return: :class:`ListPopsResponse ` + + Usage: + :: + + result = await api.list_pops() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/pops", + params={ + "hosting_provider_name": hosting_provider_name, + "link_bandwidth_mbps": link_bandwidth_mbps, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "partner_id": partner_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPopsResponse(res.json()) + + async def list_pops_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPopsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + hosting_provider_name: Optional[str] = None, + partner_id: Optional[str] = None, + link_bandwidth_mbps: Optional[int] = None, + ) -> List[Pop]: + """ + List PoPs. + List all available PoPs (locations) for a given region. By default, the results are returned in ascending alphabetical order by name. + :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 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. + :return: :class:`List[Pop] ` + + Usage: + :: + + result = await api.list_pops_all() + """ + + return await fetch_all_pages_async( + type=ListPopsResponse, + key="pops", + fetcher=self.list_pops, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "hosting_provider_name": hosting_provider_name, + "partner_id": partner_id, + "link_bandwidth_mbps": link_bandwidth_mbps, + }, + ) + + async def get_pop( + self, + *, + pop_id: str, + region: Optional[Region] = None, + ) -> Pop: + """ + Get a PoP. + Get a PoP for the given PoP ID. The response object includes the PoP's name and information about its physical location. + :param pop_id: ID of PoP to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Pop ` + + Usage: + :: + + result = await api.get_pop( + pop_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_pop_id = validate_path_param("pop_id", pop_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/pops/{param_pop_id}", + ) + + self._throw_on_error(res) + return unmarshal_Pop(res.json()) + + async def list_links( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListLinksRequestOrderBy] = 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[LinkStatus] = None, + bgp_v4_status: Optional[BgpStatus] = None, + bgp_v6_status: Optional[BgpStatus] = None, + pop_id: Optional[str] = None, + bandwidth_mbps: Optional[int] = None, + partner_id: Optional[str] = None, + vpc_id: Optional[str] = None, + routing_policy_id: Optional[str] = None, + pairing_key: Optional[str] = None, + ) -> ListLinksResponse: + """ + List links. + List all your links (InterLink connections). A number of filters are available, including Project ID, name, tags and status. + :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 links 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: 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 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. + :return: :class:`ListLinksResponse ` + + Usage: + :: + + result = await api.list_links() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/links", + params={ + "bandwidth_mbps": bandwidth_mbps, + "bgp_v4_status": bgp_v4_status, + "bgp_v6_status": bgp_v6_status, + "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, + "pairing_key": pairing_key, + "partner_id": partner_id, + "pop_id": pop_id, + "project_id": project_id or self.client.default_project_id, + "routing_policy_id": routing_policy_id, + "status": status, + "tags": tags, + "vpc_id": vpc_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListLinksResponse(res.json()) + + async def list_links_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListLinksRequestOrderBy] = 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[LinkStatus] = None, + bgp_v4_status: Optional[BgpStatus] = None, + bgp_v6_status: Optional[BgpStatus] = None, + pop_id: Optional[str] = None, + bandwidth_mbps: Optional[int] = None, + partner_id: Optional[str] = None, + vpc_id: Optional[str] = None, + routing_policy_id: Optional[str] = None, + pairing_key: Optional[str] = None, + ) -> List[Link]: + """ + List links. + List all your links (InterLink connections). A number of filters are available, including Project ID, name, tags and status. + :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 links 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: 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 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. + :return: :class:`List[Link] ` + + Usage: + :: + + result = await api.list_links_all() + """ + + return await fetch_all_pages_async( + type=ListLinksResponse, + key="links", + fetcher=self.list_links, + 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, + "bgp_v4_status": bgp_v4_status, + "bgp_v6_status": bgp_v6_status, + "pop_id": pop_id, + "bandwidth_mbps": bandwidth_mbps, + "partner_id": partner_id, + "vpc_id": vpc_id, + "routing_policy_id": routing_policy_id, + "pairing_key": pairing_key, + }, + ) + + async def get_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> 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. + :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", + ) + """ + + 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( + "GET", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def create_link( + self, + *, + name: str, + pop_id: str, + bandwidth_mbps: int, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + dedicated: Optional[bool] = None, + port_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. + :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 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. + :return: :class:`Link ` + + Usage: + :: + + result = await api.create_link( + name="example", + pop_id="example", + bandwidth_mbps=1, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/interlink/v1beta1/regions/{param_region}/links", + body=marshal_CreateLinkRequest( + CreateLinkRequest( + name=name, + pop_id=pop_id, + bandwidth_mbps=bandwidth_mbps, + region=region, + project_id=project_id, + tags=tags, + dedicated=dedicated, + port_id=port_id, + partner_id=partner_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def update_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Link: + """ + Update a link. + Update an existing link, specified by its link ID. Only its name and tags can be updated. + :param link_id: ID of the link to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the link. + :param tags: List of tags to apply to the link. + :return: :class:`Link ` + + Usage: + :: + + result = await api.update_link( + link_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( + "PATCH", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + body=marshal_UpdateLinkRequest( + UpdateLinkRequest( + link_id=link_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def delete_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Delete a link. + Delete an existing link, specified by its link ID. Note that as well as deleting the link here on the Scaleway side, it is also necessary to request deletion from the partner on their side. Only when this action has been carried out on both sides will the resource be completely deleted. + :param link_id: ID of the link to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.delete_link( + link_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( + "DELETE", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def attach_vpc( + self, + *, + link_id: str, + vpc_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Attach a VPC. + Attach a VPC to an existing link. This facilitates communication between the resources in your Scaleway VPC, and your on-premises infrastructure. + :param link_id: ID of the link to attach VPC to. + :param vpc_id: ID of the VPC to attach. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.attach_vpc( + link_id="example", + vpc_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}/attach-vpc", + body=marshal_AttachVpcRequest( + AttachVpcRequest( + link_id=link_id, + vpc_id=vpc_id, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def detach_vpc( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Detach a VPC. + Detach a VPC from an existing link. + :param link_id: ID of the link to detach the VPC from. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.detach_vpc( + link_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}/detach-vpc", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def attach_routing_policy( + self, + *, + link_id: str, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Attach a routing policy. + Attach a routing policy to an existing link. As all routes across the link are blocked by default, you must attach a routing policy to set IP prefix filters for allowed routes, facilitating traffic flow. + :param link_id: ID of the link to attach a routing policy to. + :param routing_policy_id: ID of the routing policy to be attached. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.attach_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}/attach-routing-policy", + body=marshal_AttachRoutingPolicyRequest( + AttachRoutingPolicyRequest( + 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 detach_routing_policy( + self, + *, + link_id: str, + region: Optional[Region] = 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 region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.detach_routing_policy( + link_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}/detach-routing-policy", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def enable_route_propagation( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Enable route propagation. + Enable all allowed prefixes (defined in a routing policy) to be announced in the BGP session. This allows traffic to flow between the attached VPC and the on-premises infrastructure along the announced routes. Note that by default, even when route propagation is enabled, all routes are blocked. It is essential to attach a routing policy to define the ranges of routes to announce. + :param link_id: ID of the link on which to enable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.enable_route_propagation( + link_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}/enable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def disable_route_propagation( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Disable route propagation. + Prevent any prefixes from being announced in the BGP session. Traffic will not be able to flow over the InterLink until route propagation is re-enabled. + :param link_id: ID of the link on which to disable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = await api.disable_route_propagation( + link_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}/disable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + async def list_routing_policies( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = 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, + ) -> ListRoutingPoliciesResponse: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple links (InterLink connections). + :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 routing policies to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :return: :class:`ListRoutingPoliciesResponse ` + + Usage: + :: + + result = await api.list_routing_policies() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/routing-policies", + params={ + "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, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListRoutingPoliciesResponse(res.json()) + + async def list_routing_policies_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = 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, + ) -> List[RoutingPolicy]: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple links (InterLink connections). + :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 routing policies to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :return: :class:`List[RoutingPolicy] ` + + Usage: + :: + + result = await api.list_routing_policies_all() + """ + + return await fetch_all_pages_async( + type=ListRoutingPoliciesResponse, + key="routing_policies", + fetcher=self.list_routing_policies, + 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, + }, + ) + + async def get_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> RoutingPolicy: + """ + Get routing policy. + Get a routing policy for the given routing policy ID. The response object gives information including the policy's name, tags and prefix filters. + :param routing_policy_id: ID of the routing policy to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = await api.get_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + async def create_routing_policy( + self, + *, + name: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + prefix_filter_in: Optional[List[str]] = None, + prefix_filter_out: Optional[List[str]] = None, + ) -> RoutingPolicy: + """ + 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 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. + :param prefix_filter_in: IP prefixes to accept from the peer (ranges of route announcements to accept). + :param prefix_filter_out: IP prefix filters to advertise to the peer (ranges of routes to advertise). + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = await api.create_routing_policy( + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/interlink/v1beta1/regions/{param_region}/routing-policies", + body=marshal_CreateRoutingPolicyRequest( + CreateRoutingPolicyRequest( + name=name, + region=region, + project_id=project_id, + tags=tags, + prefix_filter_in=prefix_filter_in, + prefix_filter_out=prefix_filter_out, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + async def update_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + prefix_filter_in: Optional[List[str]] = None, + prefix_filter_out: Optional[List[str]] = None, + ) -> RoutingPolicy: + """ + Update a routing policy. + Update an existing routing policy, specified by its routing policy ID. Its name, tags and incoming/outgoing prefix filters can be updated. + :param routing_policy_id: ID of the routing policy to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the routing policy. + :param tags: List of tags to apply to the routing policy. + :param prefix_filter_in: IP prefixes to accept from the peer (ranges of route announcements to accept). + :param prefix_filter_out: IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = await api.update_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "PATCH", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + body=marshal_UpdateRoutingPolicyRequest( + UpdateRoutingPolicyRequest( + routing_policy_id=routing_policy_id, + region=region, + name=name, + tags=tags, + prefix_filter_in=prefix_filter_in, + prefix_filter_out=prefix_filter_out, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + async def delete_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> None: + """ + Delete a routing policy. + Delete an existing routing policy, specified by its routing policy ID. + :param routing_policy_id: ID of the routing policy to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "DELETE", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py b/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py new file mode 100644 index 00000000..a48b937d --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/v1beta1/marshalling.py @@ -0,0 +1,456 @@ +# 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 Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + Link, + Partner, + Pop, + RoutingPolicy, + ListLinksResponse, + ListPartnersResponse, + ListPopsResponse, + ListRoutingPoliciesResponse, + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +) + + +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("partner_id", None) + if field is not None: + args["partner_id"] = field + else: + args["partner_id"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("bgp_v4_status", None) + if field is not None: + args["bgp_v4_status"] = field + + field = data.get("bgp_v6_status", None) + if field is not None: + args["bgp_v6_status"] = field + + field = data.get("enable_route_propagation", None) + if field is not None: + args["enable_route_propagation"] = field + + field = data.get("pairing_key", None) + if field is not None: + args["pairing_key"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("vpc_id", None) + if field is not None: + args["vpc_id"] = field + else: + args["vpc_id"] = None + + field = data.get("routing_policy_id", None) + if field is not None: + args["routing_policy_id"] = field + else: + args["routing_policy_id"] = None + + 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 + + return Link(**args) + + +def unmarshal_Partner(data: Any) -> Partner: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Partner' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("contact_email", None) + if field is not None: + args["contact_email"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("portal_url", None) + if field is not None: + args["portal_url"] = 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 + + return Partner(**args) + + +def unmarshal_Pop(data: Any) -> Pop: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Pop' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("hosting_provider_name", None) + if field is not None: + args["hosting_provider_name"] = field + + field = data.get("address", None) + if field is not None: + args["address"] = field + + field = data.get("city", None) + if field is not None: + args["city"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + return Pop(**args) + + +def unmarshal_RoutingPolicy(data: Any) -> RoutingPolicy: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RoutingPolicy' 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("prefix_filter_in", None) + if field is not None: + args["prefix_filter_in"] = field + + field = data.get("prefix_filter_out", None) + if field is not None: + args["prefix_filter_out"] = 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 + + return RoutingPolicy(**args) + + +def unmarshal_ListLinksResponse(data: Any) -> ListLinksResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListLinksResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("links", None) + if field is not None: + args["links"] = ( + [unmarshal_Link(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 ListLinksResponse(**args) + + +def unmarshal_ListPartnersResponse(data: Any) -> ListPartnersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPartnersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("partners", None) + if field is not None: + args["partners"] = ( + [unmarshal_Partner(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 ListPartnersResponse(**args) + + +def unmarshal_ListPopsResponse(data: Any) -> ListPopsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPopsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pops", None) + if field is not None: + args["pops"] = [unmarshal_Pop(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 ListPopsResponse(**args) + + +def unmarshal_ListRoutingPoliciesResponse(data: Any) -> ListRoutingPoliciesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRoutingPoliciesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("routing_policies", None) + if field is not None: + args["routing_policies"] = ( + [unmarshal_RoutingPolicy(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 ListRoutingPoliciesResponse(**args) + + +def marshal_AttachRoutingPolicyRequest( + request: AttachRoutingPolicyRequest, + 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_AttachVpcRequest( + request: AttachVpcRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.vpc_id is not None: + output["vpc_id"] = request.vpc_id + + return output + + +def marshal_CreateLinkRequest( + request: CreateLinkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("dedicated", request.dedicated), + OneOfPossibility("port_id", request.port_id), + OneOfPossibility("partner_id", request.partner_id), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.pop_id is not None: + output["pop_id"] = request.pop_id + + if request.bandwidth_mbps is not None: + output["bandwidth_mbps"] = request.bandwidth_mbps + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateRoutingPolicyRequest( + request: CreateRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.prefix_filter_in is not None: + output["prefix_filter_in"] = request.prefix_filter_in + + if request.prefix_filter_out is not None: + output["prefix_filter_out"] = request.prefix_filter_out + + return output + + +def marshal_UpdateLinkRequest( + request: UpdateLinkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateRoutingPolicyRequest( + request: UpdateRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.prefix_filter_in is not None: + output["prefix_filter_in"] = request.prefix_filter_in + + if request.prefix_filter_out is not None: + output["prefix_filter_out"] = request.prefix_filter_out + + return output diff --git a/scaleway-async/scaleway_async/interlink/v1beta1/types.py b/scaleway-async/scaleway_async/interlink/v1beta1/types.py new file mode 100644 index 00000000..2d5bec27 --- /dev/null +++ b/scaleway-async/scaleway_async/interlink/v1beta1/types.py @@ -0,0 +1,845 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class BgpStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_BGP_STATUS = "unknown_bgp_status" + UP = "up" + DOWN = "down" + + def __str__(self) -> str: + return str(self.value) + + +class LinkStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_LINK_STATUS = "unknown_link_status" + CONFIGURING = "configuring" + FAILED = "failed" + REQUESTED = "requested" + REFUSED = "refused" + EXPIRED = "expired" + PROVISIONING = "provisioning" + ACTIVE = "active" + LIMITED_CONNECTIVITY = "limited_connectivity" + ALL_DOWN = "all_down" + DEPROVISIONING = "deprovisioning" + DELETED = "deleted" + LOCKED = "locked" + + 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" + 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 ListPartnersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPopsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListRoutingPoliciesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class Link: + id: str + """ + Unique identifier of the link. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the link. + """ + + tags: List[str] + """ + List of tags associated with the link. + """ + + pop_id: str + """ + ID of the PoP where the link's corresponding port is located. + """ + + bandwidth_mbps: int + """ + Rate limited bandwidth of the link. + """ + + partner_id: Optional[str] + """ + ID of the partner facilitating this link. + """ + + status: LinkStatus + """ + Status of the link. + """ + + bgp_v4_status: BgpStatus + """ + Status of the link's BGP IPv4 session. + """ + + bgp_v6_status: BgpStatus + """ + Status of the link's BGP IPv6 session. + """ + + enable_route_propagation: bool + """ + Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint. + """ + + pairing_key: str + """ + Used to identify a link from a user or partner's point of view. + """ + + region: Region + """ + 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. + """ + + created_at: Optional[datetime] + """ + Creation date of the link. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the link. + """ + + +@dataclass +class Partner: + id: str + """ + Unique identifier of the partner. + """ + + name: str + """ + Name of the partner. + """ + + contact_email: str + """ + Contact email address of partner. + """ + + logo_url: str + """ + Image URL of the partner's logo. + """ + + portal_url: str + """ + URL of the partner's portal. + """ + + created_at: Optional[datetime] + """ + Creation date of the partner. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the partner. + """ + + +@dataclass +class Pop: + id: str + """ + Unique identifier of the PoP. + """ + + name: str + """ + Name of the PoP. It is the common reference of Hosting DC (ex: TH2). + """ + + hosting_provider_name: str + """ + Name of the PoP's hosting provider, e.g. Telehouse for TH2 or OpCore for DC3. + """ + + address: str + """ + Physical address of the PoP. + """ + + city: str + """ + City where PoP is located. + """ + + logo_url: str + """ + Image URL of the PoP's logo. + """ + + region: Region + """ + Region of the PoP. + """ + + +@dataclass +class RoutingPolicy: + id: str + """ + Unique identifier of the routing policy. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the routing policy. + """ + + tags: List[str] + """ + List of tags associated with the routing policy. + """ + + prefix_filter_in: List[str] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: List[str] + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + region: Region + """ + Region of the routing policy. + """ + + created_at: Optional[datetime] + """ + Creation date of the routing policy. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the routing policy. + """ + + +@dataclass +class AttachRoutingPolicyRequest: + link_id: str + """ + ID of the link to attach a routing policy to. + """ + + routing_policy_id: str + """ + ID of the routing policy to be attached. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class AttachVpcRequest: + link_id: str + """ + ID of the link to attach VPC to. + """ + + vpc_id: str + """ + ID of the VPC to attach. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateLinkRequest: + name: str + """ + Name of the link. + """ + + pop_id: str + """ + PoP (location) where the link will be created. + """ + + bandwidth_mbps: int + """ + Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to create the link in. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the link. + """ + + dedicated: Optional[bool] + + port_id: Optional[str] + + partner_id: Optional[str] + + +@dataclass +class CreateRoutingPolicyRequest: + name: str + """ + Name of the routing policy. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to create the routing policy in. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[List[str]] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[List[str]] + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class DeleteLinkRequest: + link_id: str + """ + ID of the link to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachRoutingPolicyRequest: + link_id: str + """ + ID of the link to detach a routing policy from. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachVpcRequest: + link_id: str + """ + ID of the link to detach the VPC from. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DisableRoutePropagationRequest: + link_id: str + """ + ID of the link on which to disable route propagation. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class EnableRoutePropagationRequest: + link_id: str + """ + ID of the link on which to enable route propagation. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetLinkRequest: + link_id: str + """ + ID of the link to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetPartnerRequest: + partner_id: str + """ + ID of partner to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetPopRequest: + pop_id: str + """ + ID of PoP to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListLinksRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListLinksRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of links 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[LinkStatus] + """ + Link status to filter for. + """ + + bgp_v4_status: Optional[BgpStatus] + """ + BGP IPv4 status to filter for. + """ + + bgp_v6_status: Optional[BgpStatus] + """ + BGP IPv6 status to filter for. + """ + + pop_id: Optional[str] + """ + Filter for links attached to this PoP (via ports). + """ + + bandwidth_mbps: Optional[int] + """ + Filter for link bandwidth (in Mbps). + """ + + partner_id: Optional[str] + """ + Filter for links hosted by this partner. + """ + + vpc_id: Optional[str] + """ + Filter for links attached to this VPC. + """ + + routing_policy_id: Optional[str] + """ + Filter for links using this routing policy. + """ + + pairing_key: Optional[str] + """ + Filter for the link with this pairing_key. + """ + + +@dataclass +class ListLinksResponse: + links: List[Link] + """ + List of links on the current page. + """ + + total_count: int + """ + Total number of links. + """ + + +@dataclass +class ListPartnersRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListPartnersRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of partners to return per page. + """ + + pop_ids: Optional[List[str]] + """ + Filter for partners present (offering a port) in one of these PoPs. + """ + + +@dataclass +class ListPartnersResponse: + partners: List[Partner] + """ + List of partners on current page. + """ + + total_count: int + """ + Total number of partners returned. + """ + + +@dataclass +class ListPopsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListPopsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of PoPs to return per page. + """ + + name: Optional[str] + """ + PoP name to filter for. + """ + + hosting_provider_name: Optional[str] + """ + Hosting provider name to filter for. + """ + + partner_id: Optional[str] + """ + Filter for PoPs hosting an available shared port 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. + """ + + +@dataclass +class ListPopsResponse: + pops: List[Pop] + """ + List of PoPs on the current page. + """ + + total_count: int + """ + Total number of PoPs. + """ + + +@dataclass +class ListRoutingPoliciesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListRoutingPoliciesRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of routing policies 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] + """ + Routing policy name to filter for. + """ + + tags: Optional[List[str]] + """ + Tags to filter for. + """ + + +@dataclass +class ListRoutingPoliciesResponse: + routing_policies: List[RoutingPolicy] + + total_count: int + + +@dataclass +class UpdateLinkRequest: + link_id: str + """ + ID of the link to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the link. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the link. + """ + + +@dataclass +class UpdateRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the routing policy. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[List[str]] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[List[str]] + """ + IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + """ diff --git a/scaleway/scaleway/interlink/__init__.py b/scaleway/scaleway/interlink/__init__.py new file mode 100644 index 00000000..8b74a5ed --- /dev/null +++ b/scaleway/scaleway/interlink/__init__.py @@ -0,0 +1,2 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. diff --git a/scaleway/scaleway/interlink/v1beta1/__init__.py b/scaleway/scaleway/interlink/v1beta1/__init__.py new file mode 100644 index 00000000..479a0815 --- /dev/null +++ b/scaleway/scaleway/interlink/v1beta1/__init__.py @@ -0,0 +1,75 @@ +# 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 LinkStatus +from .types import ListLinksRequestOrderBy +from .types import ListPartnersRequestOrderBy +from .types import ListPopsRequestOrderBy +from .types import ListRoutingPoliciesRequestOrderBy +from .types import Link +from .types import Partner +from .types import Pop +from .types import RoutingPolicy +from .types import AttachRoutingPolicyRequest +from .types import AttachVpcRequest +from .types import CreateLinkRequest +from .types import CreateRoutingPolicyRequest +from .types import DeleteLinkRequest +from .types import DeleteRoutingPolicyRequest +from .types import DetachRoutingPolicyRequest +from .types import DetachVpcRequest +from .types import DisableRoutePropagationRequest +from .types import EnableRoutePropagationRequest +from .types import GetLinkRequest +from .types import GetPartnerRequest +from .types import GetPopRequest +from .types import GetRoutingPolicyRequest +from .types import ListLinksRequest +from .types import ListLinksResponse +from .types import ListPartnersRequest +from .types import ListPartnersResponse +from .types import ListPopsRequest +from .types import ListPopsResponse +from .types import ListRoutingPoliciesRequest +from .types import ListRoutingPoliciesResponse +from .types import UpdateLinkRequest +from .types import UpdateRoutingPolicyRequest +from .api import InterlinkV1Beta1API + +__all__ = [ + "BgpStatus", + "LinkStatus", + "ListLinksRequestOrderBy", + "ListPartnersRequestOrderBy", + "ListPopsRequestOrderBy", + "ListRoutingPoliciesRequestOrderBy", + "Link", + "Partner", + "Pop", + "RoutingPolicy", + "AttachRoutingPolicyRequest", + "AttachVpcRequest", + "CreateLinkRequest", + "CreateRoutingPolicyRequest", + "DeleteLinkRequest", + "DeleteRoutingPolicyRequest", + "DetachRoutingPolicyRequest", + "DetachVpcRequest", + "DisableRoutePropagationRequest", + "EnableRoutePropagationRequest", + "GetLinkRequest", + "GetPartnerRequest", + "GetPopRequest", + "GetRoutingPolicyRequest", + "ListLinksRequest", + "ListLinksResponse", + "ListPartnersRequest", + "ListPartnersResponse", + "ListPopsRequest", + "ListPopsResponse", + "ListRoutingPoliciesRequest", + "ListRoutingPoliciesResponse", + "UpdateLinkRequest", + "UpdateRoutingPolicyRequest", + "InterlinkV1Beta1API", +] diff --git a/scaleway/scaleway/interlink/v1beta1/api.py b/scaleway/scaleway/interlink/v1beta1/api.py new file mode 100644 index 00000000..6b059dbe --- /dev/null +++ b/scaleway/scaleway/interlink/v1beta1/api.py @@ -0,0 +1,1147 @@ +# 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 scaleway_core.api import API +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + validate_path_param, + fetch_all_pages, +) +from .types import ( + BgpStatus, + LinkStatus, + ListLinksRequestOrderBy, + ListPartnersRequestOrderBy, + ListPopsRequestOrderBy, + ListRoutingPoliciesRequestOrderBy, + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + Link, + ListLinksResponse, + ListPartnersResponse, + ListPopsResponse, + ListRoutingPoliciesResponse, + Partner, + Pop, + RoutingPolicy, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +) +from .marshalling import ( + unmarshal_Link, + unmarshal_Partner, + unmarshal_Pop, + unmarshal_RoutingPolicy, + unmarshal_ListLinksResponse, + unmarshal_ListPartnersResponse, + unmarshal_ListPopsResponse, + unmarshal_ListRoutingPoliciesResponse, + marshal_AttachRoutingPolicyRequest, + marshal_AttachVpcRequest, + marshal_CreateLinkRequest, + marshal_CreateRoutingPolicyRequest, + marshal_UpdateLinkRequest, + marshal_UpdateRoutingPolicyRequest, +) + + +class InterlinkV1Beta1API(API): + """ + This API allows you to manage your Scaleway InterLink, to connect your on-premises infrastructure with your Scaleway VPC. + """ + + def list_partners( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPartnersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pop_ids: Optional[List[str]] = None, + ) -> ListPartnersResponse: + """ + List available partners. + List all available partners. By default, the partners 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 partners to return per page. + :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :return: :class:`ListPartnersResponse ` + + Usage: + :: + + result = api.list_partners() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/partners", + params={ + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "pop_ids": pop_ids, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPartnersResponse(res.json()) + + def list_partners_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPartnersRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + pop_ids: Optional[List[str]] = None, + ) -> List[Partner]: + """ + List available partners. + List all available partners. By default, the partners 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 partners to return per page. + :param pop_ids: Filter for partners present (offering a port) in one of these PoPs. + :return: :class:`List[Partner] ` + + Usage: + :: + + result = api.list_partners_all() + """ + + return fetch_all_pages( + type=ListPartnersResponse, + key="partners", + fetcher=self.list_partners, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "pop_ids": pop_ids, + }, + ) + + def get_partner( + self, + *, + partner_id: str, + region: Optional[Region] = None, + ) -> Partner: + """ + Get a partner. + Get a partner for the given partner IP. The response object includes information such as the partner's name, email address and portal URL. + :param partner_id: ID of partner to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Partner ` + + Usage: + :: + + result = api.get_partner( + partner_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_partner_id = validate_path_param("partner_id", partner_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/partners/{param_partner_id}", + ) + + self._throw_on_error(res) + return unmarshal_Partner(res.json()) + + def list_pops( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPopsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + hosting_provider_name: Optional[str] = None, + partner_id: Optional[str] = None, + link_bandwidth_mbps: Optional[int] = None, + ) -> ListPopsResponse: + """ + List PoPs. + List all available PoPs (locations) for a given region. By default, the results are returned in ascending alphabetical order by name. + :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 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. + :return: :class:`ListPopsResponse ` + + Usage: + :: + + result = api.list_pops() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/pops", + params={ + "hosting_provider_name": hosting_provider_name, + "link_bandwidth_mbps": link_bandwidth_mbps, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "partner_id": partner_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPopsResponse(res.json()) + + def list_pops_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListPopsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + name: Optional[str] = None, + hosting_provider_name: Optional[str] = None, + partner_id: Optional[str] = None, + link_bandwidth_mbps: Optional[int] = None, + ) -> List[Pop]: + """ + List PoPs. + List all available PoPs (locations) for a given region. By default, the results are returned in ascending alphabetical order by name. + :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 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. + :return: :class:`List[Pop] ` + + Usage: + :: + + result = api.list_pops_all() + """ + + return fetch_all_pages( + type=ListPopsResponse, + key="pops", + fetcher=self.list_pops, + args={ + "region": region, + "order_by": order_by, + "page": page, + "page_size": page_size, + "name": name, + "hosting_provider_name": hosting_provider_name, + "partner_id": partner_id, + "link_bandwidth_mbps": link_bandwidth_mbps, + }, + ) + + def get_pop( + self, + *, + pop_id: str, + region: Optional[Region] = None, + ) -> Pop: + """ + Get a PoP. + Get a PoP for the given PoP ID. The response object includes the PoP's name and information about its physical location. + :param pop_id: ID of PoP to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Pop ` + + Usage: + :: + + result = api.get_pop( + pop_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_pop_id = validate_path_param("pop_id", pop_id) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/pops/{param_pop_id}", + ) + + self._throw_on_error(res) + return unmarshal_Pop(res.json()) + + def list_links( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListLinksRequestOrderBy] = 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[LinkStatus] = None, + bgp_v4_status: Optional[BgpStatus] = None, + bgp_v6_status: Optional[BgpStatus] = None, + pop_id: Optional[str] = None, + bandwidth_mbps: Optional[int] = None, + partner_id: Optional[str] = None, + vpc_id: Optional[str] = None, + routing_policy_id: Optional[str] = None, + pairing_key: Optional[str] = None, + ) -> ListLinksResponse: + """ + List links. + List all your links (InterLink connections). A number of filters are available, including Project ID, name, tags and status. + :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 links 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: 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 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. + :return: :class:`ListLinksResponse ` + + Usage: + :: + + result = api.list_links() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/links", + params={ + "bandwidth_mbps": bandwidth_mbps, + "bgp_v4_status": bgp_v4_status, + "bgp_v6_status": bgp_v6_status, + "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, + "pairing_key": pairing_key, + "partner_id": partner_id, + "pop_id": pop_id, + "project_id": project_id or self.client.default_project_id, + "routing_policy_id": routing_policy_id, + "status": status, + "tags": tags, + "vpc_id": vpc_id, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListLinksResponse(res.json()) + + def list_links_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListLinksRequestOrderBy] = 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[LinkStatus] = None, + bgp_v4_status: Optional[BgpStatus] = None, + bgp_v6_status: Optional[BgpStatus] = None, + pop_id: Optional[str] = None, + bandwidth_mbps: Optional[int] = None, + partner_id: Optional[str] = None, + vpc_id: Optional[str] = None, + routing_policy_id: Optional[str] = None, + pairing_key: Optional[str] = None, + ) -> List[Link]: + """ + List links. + List all your links (InterLink connections). A number of filters are available, including Project ID, name, tags and status. + :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 links 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: 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 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. + :return: :class:`List[Link] ` + + Usage: + :: + + result = api.list_links_all() + """ + + return fetch_all_pages( + type=ListLinksResponse, + key="links", + fetcher=self.list_links, + 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, + "bgp_v4_status": bgp_v4_status, + "bgp_v6_status": bgp_v6_status, + "pop_id": pop_id, + "bandwidth_mbps": bandwidth_mbps, + "partner_id": partner_id, + "vpc_id": vpc_id, + "routing_policy_id": routing_policy_id, + "pairing_key": pairing_key, + }, + ) + + def get_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> 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. + :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", + ) + """ + + 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( + "GET", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def create_link( + self, + *, + name: str, + pop_id: str, + bandwidth_mbps: int, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + dedicated: Optional[bool] = None, + port_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. + :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 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. + :return: :class:`Link ` + + Usage: + :: + + result = api.create_link( + name="example", + pop_id="example", + bandwidth_mbps=1, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/interlink/v1beta1/regions/{param_region}/links", + body=marshal_CreateLinkRequest( + CreateLinkRequest( + name=name, + pop_id=pop_id, + bandwidth_mbps=bandwidth_mbps, + region=region, + project_id=project_id, + tags=tags, + dedicated=dedicated, + port_id=port_id, + partner_id=partner_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def update_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> Link: + """ + Update a link. + Update an existing link, specified by its link ID. Only its name and tags can be updated. + :param link_id: ID of the link to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the link. + :param tags: List of tags to apply to the link. + :return: :class:`Link ` + + Usage: + :: + + result = api.update_link( + link_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( + "PATCH", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + body=marshal_UpdateLinkRequest( + UpdateLinkRequest( + link_id=link_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def delete_link( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Delete a link. + Delete an existing link, specified by its link ID. Note that as well as deleting the link here on the Scaleway side, it is also necessary to request deletion from the partner on their side. Only when this action has been carried out on both sides will the resource be completely deleted. + :param link_id: ID of the link to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.delete_link( + link_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( + "DELETE", + f"/interlink/v1beta1/regions/{param_region}/links/{param_link_id}", + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def attach_vpc( + self, + *, + link_id: str, + vpc_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Attach a VPC. + Attach a VPC to an existing link. This facilitates communication between the resources in your Scaleway VPC, and your on-premises infrastructure. + :param link_id: ID of the link to attach VPC to. + :param vpc_id: ID of the VPC to attach. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.attach_vpc( + link_id="example", + vpc_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}/attach-vpc", + body=marshal_AttachVpcRequest( + AttachVpcRequest( + link_id=link_id, + vpc_id=vpc_id, + region=region, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def detach_vpc( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Detach a VPC. + Detach a VPC from an existing link. + :param link_id: ID of the link to detach the VPC from. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.detach_vpc( + link_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}/detach-vpc", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def attach_routing_policy( + self, + *, + link_id: str, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Attach a routing policy. + Attach a routing policy to an existing link. As all routes across the link are blocked by default, you must attach a routing policy to set IP prefix filters for allowed routes, facilitating traffic flow. + :param link_id: ID of the link to attach a routing policy to. + :param routing_policy_id: ID of the routing policy to be attached. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.attach_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}/attach-routing-policy", + body=marshal_AttachRoutingPolicyRequest( + AttachRoutingPolicyRequest( + 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 detach_routing_policy( + self, + *, + link_id: str, + region: Optional[Region] = 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 region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.detach_routing_policy( + link_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}/detach-routing-policy", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def enable_route_propagation( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Enable route propagation. + Enable all allowed prefixes (defined in a routing policy) to be announced in the BGP session. This allows traffic to flow between the attached VPC and the on-premises infrastructure along the announced routes. Note that by default, even when route propagation is enabled, all routes are blocked. It is essential to attach a routing policy to define the ranges of routes to announce. + :param link_id: ID of the link on which to enable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.enable_route_propagation( + link_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}/enable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def disable_route_propagation( + self, + *, + link_id: str, + region: Optional[Region] = None, + ) -> Link: + """ + Disable route propagation. + Prevent any prefixes from being announced in the BGP session. Traffic will not be able to flow over the InterLink until route propagation is re-enabled. + :param link_id: ID of the link on which to disable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Link ` + + Usage: + :: + + result = api.disable_route_propagation( + link_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}/disable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Link(res.json()) + + def list_routing_policies( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = 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, + ) -> ListRoutingPoliciesResponse: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple links (InterLink connections). + :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 routing policies to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :return: :class:`ListRoutingPoliciesResponse ` + + Usage: + :: + + result = api.list_routing_policies() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/routing-policies", + params={ + "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, + "project_id": project_id or self.client.default_project_id, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListRoutingPoliciesResponse(res.json()) + + def list_routing_policies_all( + self, + *, + region: Optional[Region] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = 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, + ) -> List[RoutingPolicy]: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple links (InterLink connections). + :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 routing policies to return per page. + :param project_id: Project ID to filter for. + :param organization_id: Organization ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :return: :class:`List[RoutingPolicy] ` + + Usage: + :: + + result = api.list_routing_policies_all() + """ + + return fetch_all_pages( + type=ListRoutingPoliciesResponse, + key="routing_policies", + fetcher=self.list_routing_policies, + 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, + }, + ) + + def get_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> RoutingPolicy: + """ + Get routing policy. + Get a routing policy for the given routing policy ID. The response object gives information including the policy's name, tags and prefix filters. + :param routing_policy_id: ID of the routing policy to get. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = api.get_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "GET", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + def create_routing_policy( + self, + *, + name: str, + region: Optional[Region] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + prefix_filter_in: Optional[List[str]] = None, + prefix_filter_out: Optional[List[str]] = None, + ) -> RoutingPolicy: + """ + 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 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. + :param prefix_filter_in: IP prefixes to accept from the peer (ranges of route announcements to accept). + :param prefix_filter_out: IP prefix filters to advertise to the peer (ranges of routes to advertise). + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = api.create_routing_policy( + name="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/interlink/v1beta1/regions/{param_region}/routing-policies", + body=marshal_CreateRoutingPolicyRequest( + CreateRoutingPolicyRequest( + name=name, + region=region, + project_id=project_id, + tags=tags, + prefix_filter_in=prefix_filter_in, + prefix_filter_out=prefix_filter_out, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + def update_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + prefix_filter_in: Optional[List[str]] = None, + prefix_filter_out: Optional[List[str]] = None, + ) -> RoutingPolicy: + """ + Update a routing policy. + Update an existing routing policy, specified by its routing policy ID. Its name, tags and incoming/outgoing prefix filters can be updated. + :param routing_policy_id: ID of the routing policy to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the routing policy. + :param tags: List of tags to apply to the routing policy. + :param prefix_filter_in: IP prefixes to accept from the peer (ranges of route announcements to accept). + :param prefix_filter_out: IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + :return: :class:`RoutingPolicy ` + + Usage: + :: + + result = api.update_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "PATCH", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + body=marshal_UpdateRoutingPolicyRequest( + UpdateRoutingPolicyRequest( + routing_policy_id=routing_policy_id, + region=region, + name=name, + tags=tags, + prefix_filter_in=prefix_filter_in, + prefix_filter_out=prefix_filter_out, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_RoutingPolicy(res.json()) + + def delete_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[Region] = None, + ) -> None: + """ + Delete a routing policy. + Delete an existing routing policy, specified by its routing policy ID. + :param routing_policy_id: ID of the routing policy to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_routing_policy( + routing_policy_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_routing_policy_id = validate_path_param( + "routing_policy_id", routing_policy_id + ) + + res = self._request( + "DELETE", + f"/interlink/v1beta1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway/scaleway/interlink/v1beta1/marshalling.py b/scaleway/scaleway/interlink/v1beta1/marshalling.py new file mode 100644 index 00000000..a48b937d --- /dev/null +++ b/scaleway/scaleway/interlink/v1beta1/marshalling.py @@ -0,0 +1,456 @@ +# 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 Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + Link, + Partner, + Pop, + RoutingPolicy, + ListLinksResponse, + ListPartnersResponse, + ListPopsResponse, + ListRoutingPoliciesResponse, + AttachRoutingPolicyRequest, + AttachVpcRequest, + CreateLinkRequest, + CreateRoutingPolicyRequest, + UpdateLinkRequest, + UpdateRoutingPolicyRequest, +) + + +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("partner_id", None) + if field is not None: + args["partner_id"] = field + else: + args["partner_id"] = None + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("bgp_v4_status", None) + if field is not None: + args["bgp_v4_status"] = field + + field = data.get("bgp_v6_status", None) + if field is not None: + args["bgp_v6_status"] = field + + field = data.get("enable_route_propagation", None) + if field is not None: + args["enable_route_propagation"] = field + + field = data.get("pairing_key", None) + if field is not None: + args["pairing_key"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + field = data.get("vpc_id", None) + if field is not None: + args["vpc_id"] = field + else: + args["vpc_id"] = None + + field = data.get("routing_policy_id", None) + if field is not None: + args["routing_policy_id"] = field + else: + args["routing_policy_id"] = None + + 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 + + return Link(**args) + + +def unmarshal_Partner(data: Any) -> Partner: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Partner' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("contact_email", None) + if field is not None: + args["contact_email"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("portal_url", None) + if field is not None: + args["portal_url"] = 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 + + return Partner(**args) + + +def unmarshal_Pop(data: Any) -> Pop: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Pop' 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("name", None) + if field is not None: + args["name"] = field + + field = data.get("hosting_provider_name", None) + if field is not None: + args["hosting_provider_name"] = field + + field = data.get("address", None) + if field is not None: + args["address"] = field + + field = data.get("city", None) + if field is not None: + args["city"] = field + + field = data.get("logo_url", None) + if field is not None: + args["logo_url"] = field + + field = data.get("region", None) + if field is not None: + args["region"] = field + + return Pop(**args) + + +def unmarshal_RoutingPolicy(data: Any) -> RoutingPolicy: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RoutingPolicy' 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("prefix_filter_in", None) + if field is not None: + args["prefix_filter_in"] = field + + field = data.get("prefix_filter_out", None) + if field is not None: + args["prefix_filter_out"] = 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 + + return RoutingPolicy(**args) + + +def unmarshal_ListLinksResponse(data: Any) -> ListLinksResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListLinksResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("links", None) + if field is not None: + args["links"] = ( + [unmarshal_Link(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 ListLinksResponse(**args) + + +def unmarshal_ListPartnersResponse(data: Any) -> ListPartnersResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPartnersResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("partners", None) + if field is not None: + args["partners"] = ( + [unmarshal_Partner(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 ListPartnersResponse(**args) + + +def unmarshal_ListPopsResponse(data: Any) -> ListPopsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPopsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pops", None) + if field is not None: + args["pops"] = [unmarshal_Pop(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 ListPopsResponse(**args) + + +def unmarshal_ListRoutingPoliciesResponse(data: Any) -> ListRoutingPoliciesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListRoutingPoliciesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("routing_policies", None) + if field is not None: + args["routing_policies"] = ( + [unmarshal_RoutingPolicy(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 ListRoutingPoliciesResponse(**args) + + +def marshal_AttachRoutingPolicyRequest( + request: AttachRoutingPolicyRequest, + 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_AttachVpcRequest( + request: AttachVpcRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.vpc_id is not None: + output["vpc_id"] = request.vpc_id + + return output + + +def marshal_CreateLinkRequest( + request: CreateLinkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility("dedicated", request.dedicated), + OneOfPossibility("port_id", request.port_id), + OneOfPossibility("partner_id", request.partner_id), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.pop_id is not None: + output["pop_id"] = request.pop_id + + if request.bandwidth_mbps is not None: + output["bandwidth_mbps"] = request.bandwidth_mbps + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreateRoutingPolicyRequest( + request: CreateRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.prefix_filter_in is not None: + output["prefix_filter_in"] = request.prefix_filter_in + + if request.prefix_filter_out is not None: + output["prefix_filter_out"] = request.prefix_filter_out + + return output + + +def marshal_UpdateLinkRequest( + request: UpdateLinkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_UpdateRoutingPolicyRequest( + request: UpdateRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.prefix_filter_in is not None: + output["prefix_filter_in"] = request.prefix_filter_in + + if request.prefix_filter_out is not None: + output["prefix_filter_out"] = request.prefix_filter_out + + return output diff --git a/scaleway/scaleway/interlink/v1beta1/types.py b/scaleway/scaleway/interlink/v1beta1/types.py new file mode 100644 index 00000000..2d5bec27 --- /dev/null +++ b/scaleway/scaleway/interlink/v1beta1/types.py @@ -0,0 +1,845 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Region, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class BgpStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_BGP_STATUS = "unknown_bgp_status" + UP = "up" + DOWN = "down" + + def __str__(self) -> str: + return str(self.value) + + +class LinkStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_LINK_STATUS = "unknown_link_status" + CONFIGURING = "configuring" + FAILED = "failed" + REQUESTED = "requested" + REFUSED = "refused" + EXPIRED = "expired" + PROVISIONING = "provisioning" + ACTIVE = "active" + LIMITED_CONNECTIVITY = "limited_connectivity" + ALL_DOWN = "all_down" + DEPROVISIONING = "deprovisioning" + DELETED = "deleted" + LOCKED = "locked" + + 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" + 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 ListPartnersRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPopsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListRoutingPoliciesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class Link: + id: str + """ + Unique identifier of the link. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the link. + """ + + tags: List[str] + """ + List of tags associated with the link. + """ + + pop_id: str + """ + ID of the PoP where the link's corresponding port is located. + """ + + bandwidth_mbps: int + """ + Rate limited bandwidth of the link. + """ + + partner_id: Optional[str] + """ + ID of the partner facilitating this link. + """ + + status: LinkStatus + """ + Status of the link. + """ + + bgp_v4_status: BgpStatus + """ + Status of the link's BGP IPv4 session. + """ + + bgp_v6_status: BgpStatus + """ + Status of the link's BGP IPv6 session. + """ + + enable_route_propagation: bool + """ + Defines whether route propagation is enabled or not. To enable or disable route propagation, use the dedicated endpoint. + """ + + pairing_key: str + """ + Used to identify a link from a user or partner's point of view. + """ + + region: Region + """ + 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. + """ + + created_at: Optional[datetime] + """ + Creation date of the link. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the link. + """ + + +@dataclass +class Partner: + id: str + """ + Unique identifier of the partner. + """ + + name: str + """ + Name of the partner. + """ + + contact_email: str + """ + Contact email address of partner. + """ + + logo_url: str + """ + Image URL of the partner's logo. + """ + + portal_url: str + """ + URL of the partner's portal. + """ + + created_at: Optional[datetime] + """ + Creation date of the partner. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the partner. + """ + + +@dataclass +class Pop: + id: str + """ + Unique identifier of the PoP. + """ + + name: str + """ + Name of the PoP. It is the common reference of Hosting DC (ex: TH2). + """ + + hosting_provider_name: str + """ + Name of the PoP's hosting provider, e.g. Telehouse for TH2 or OpCore for DC3. + """ + + address: str + """ + Physical address of the PoP. + """ + + city: str + """ + City where PoP is located. + """ + + logo_url: str + """ + Image URL of the PoP's logo. + """ + + region: Region + """ + Region of the PoP. + """ + + +@dataclass +class RoutingPolicy: + id: str + """ + Unique identifier of the routing policy. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the routing policy. + """ + + tags: List[str] + """ + List of tags associated with the routing policy. + """ + + prefix_filter_in: List[str] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: List[str] + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + region: Region + """ + Region of the routing policy. + """ + + created_at: Optional[datetime] + """ + Creation date of the routing policy. + """ + + updated_at: Optional[datetime] + """ + Last modification date of the routing policy. + """ + + +@dataclass +class AttachRoutingPolicyRequest: + link_id: str + """ + ID of the link to attach a routing policy to. + """ + + routing_policy_id: str + """ + ID of the routing policy to be attached. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class AttachVpcRequest: + link_id: str + """ + ID of the link to attach VPC to. + """ + + vpc_id: str + """ + ID of the VPC to attach. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class CreateLinkRequest: + name: str + """ + Name of the link. + """ + + pop_id: str + """ + PoP (location) where the link will be created. + """ + + bandwidth_mbps: int + """ + Desired bandwidth for the link. Must be compatible with available link bandwidths and remaining bandwidth capacity of the port. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to create the link in. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the link. + """ + + dedicated: Optional[bool] + + port_id: Optional[str] + + partner_id: Optional[str] + + +@dataclass +class CreateRoutingPolicyRequest: + name: str + """ + Name of the routing policy. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] + """ + ID of the Project to create the routing policy in. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[List[str]] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[List[str]] + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class DeleteLinkRequest: + link_id: str + """ + ID of the link to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to delete. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachRoutingPolicyRequest: + link_id: str + """ + ID of the link to detach a routing policy from. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachVpcRequest: + link_id: str + """ + ID of the link to detach the VPC from. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DisableRoutePropagationRequest: + link_id: str + """ + ID of the link on which to disable route propagation. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class EnableRoutePropagationRequest: + link_id: str + """ + ID of the link on which to enable route propagation. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetLinkRequest: + link_id: str + """ + ID of the link to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetPartnerRequest: + partner_id: str + """ + ID of partner to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetPopRequest: + pop_id: str + """ + ID of PoP to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to get. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListLinksRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListLinksRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of links 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[LinkStatus] + """ + Link status to filter for. + """ + + bgp_v4_status: Optional[BgpStatus] + """ + BGP IPv4 status to filter for. + """ + + bgp_v6_status: Optional[BgpStatus] + """ + BGP IPv6 status to filter for. + """ + + pop_id: Optional[str] + """ + Filter for links attached to this PoP (via ports). + """ + + bandwidth_mbps: Optional[int] + """ + Filter for link bandwidth (in Mbps). + """ + + partner_id: Optional[str] + """ + Filter for links hosted by this partner. + """ + + vpc_id: Optional[str] + """ + Filter for links attached to this VPC. + """ + + routing_policy_id: Optional[str] + """ + Filter for links using this routing policy. + """ + + pairing_key: Optional[str] + """ + Filter for the link with this pairing_key. + """ + + +@dataclass +class ListLinksResponse: + links: List[Link] + """ + List of links on the current page. + """ + + total_count: int + """ + Total number of links. + """ + + +@dataclass +class ListPartnersRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListPartnersRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of partners to return per page. + """ + + pop_ids: Optional[List[str]] + """ + Filter for partners present (offering a port) in one of these PoPs. + """ + + +@dataclass +class ListPartnersResponse: + partners: List[Partner] + """ + List of partners on current page. + """ + + total_count: int + """ + Total number of partners returned. + """ + + +@dataclass +class ListPopsRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListPopsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of PoPs to return per page. + """ + + name: Optional[str] + """ + PoP name to filter for. + """ + + hosting_provider_name: Optional[str] + """ + Hosting provider name to filter for. + """ + + partner_id: Optional[str] + """ + Filter for PoPs hosting an available shared port 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. + """ + + +@dataclass +class ListPopsResponse: + pops: List[Pop] + """ + List of PoPs on the current page. + """ + + total_count: int + """ + Total number of PoPs. + """ + + +@dataclass +class ListRoutingPoliciesRequest: + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + order_by: Optional[ListRoutingPoliciesRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Maximum number of routing policies 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] + """ + Routing policy name to filter for. + """ + + tags: Optional[List[str]] + """ + Tags to filter for. + """ + + +@dataclass +class ListRoutingPoliciesResponse: + routing_policies: List[RoutingPolicy] + + total_count: int + + +@dataclass +class UpdateLinkRequest: + link_id: str + """ + ID of the link to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the link. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the link. + """ + + +@dataclass +class UpdateRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to update. + """ + + region: Optional[Region] + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] + """ + Name of the routing policy. + """ + + tags: Optional[List[str]] + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[List[str]] + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[List[str]] + """ + IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + """