diff --git a/scaleway-async/scaleway_async/s2s_vpn/__init__.py b/scaleway-async/scaleway_async/s2s_vpn/__init__.py new file mode 100644 index 00000000..8b74a5ed --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/__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/s2s_vpn/v1alpha1/__init__.py b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/__init__.py new file mode 100644 index 00000000..6260bc94 --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/__init__.py @@ -0,0 +1,123 @@ +# 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 BgpSessionStatus +from .types import ConnectionDhGroup +from .types import ConnectionEncryption +from .types import ConnectionInitiationPolicy +from .types import ConnectionIntegrity +from .types import ConnectionStatus +from .types import CreateConnectionRequestInitiationPolicy +from .types import ListConnectionsRequestOrderBy +from .types import ListCustomerGatewaysRequestOrderBy +from .types import ListRoutingPoliciesRequestOrderBy +from .types import ListVpnGatewaysRequestOrderBy +from .types import TunnelStatus +from .types import VpnGatewayStatus +from .content import VPN_GATEWAY_TRANSIENT_STATUSES +from .types import BgpSession +from .types import ConnectionCipher +from .types import VpnGatewayPrivateConfig +from .types import VpnGatewayPublicConfig +from .types import CreateConnectionRequestBgpConfig +from .types import Connection +from .types import CreateVpnGatewayRequestPublicConfig +from .types import CustomerGateway +from .types import RoutingPolicy +from .types import GatewayType +from .types import VpnGateway +from .types import CreateConnectionRequest +from .types import CreateConnectionResponse +from .types import CreateCustomerGatewayRequest +from .types import CreateRoutingPolicyRequest +from .types import CreateVpnGatewayRequest +from .types import DeleteConnectionRequest +from .types import DeleteCustomerGatewayRequest +from .types import DeleteRoutingPolicyRequest +from .types import DeleteVpnGatewayRequest +from .types import DetachRoutingPolicyRequest +from .types import DisableRoutePropagationRequest +from .types import EnableRoutePropagationRequest +from .types import GetConnectionRequest +from .types import GetCustomerGatewayRequest +from .types import GetRoutingPolicyRequest +from .types import GetVpnGatewayRequest +from .types import ListConnectionsRequest +from .types import ListConnectionsResponse +from .types import ListCustomerGatewaysRequest +from .types import ListCustomerGatewaysResponse +from .types import ListRoutingPoliciesRequest +from .types import ListRoutingPoliciesResponse +from .types import ListVpnGatewayTypesRequest +from .types import ListVpnGatewayTypesResponse +from .types import ListVpnGatewaysRequest +from .types import ListVpnGatewaysResponse +from .types import RenewConnectionPskRequest +from .types import RenewConnectionPskResponse +from .types import SetRoutingPolicyRequest +from .types import UpdateConnectionRequest +from .types import UpdateCustomerGatewayRequest +from .types import UpdateRoutingPolicyRequest +from .types import UpdateVpnGatewayRequest +from .api import S2SVpnV1Alpha1API + +__all__ = [ + "BgpSessionStatus", + "ConnectionDhGroup", + "ConnectionEncryption", + "ConnectionInitiationPolicy", + "ConnectionIntegrity", + "ConnectionStatus", + "CreateConnectionRequestInitiationPolicy", + "ListConnectionsRequestOrderBy", + "ListCustomerGatewaysRequestOrderBy", + "ListRoutingPoliciesRequestOrderBy", + "ListVpnGatewaysRequestOrderBy", + "TunnelStatus", + "VpnGatewayStatus", + "VPN_GATEWAY_TRANSIENT_STATUSES", + "BgpSession", + "ConnectionCipher", + "VpnGatewayPrivateConfig", + "VpnGatewayPublicConfig", + "CreateConnectionRequestBgpConfig", + "Connection", + "CreateVpnGatewayRequestPublicConfig", + "CustomerGateway", + "RoutingPolicy", + "GatewayType", + "VpnGateway", + "CreateConnectionRequest", + "CreateConnectionResponse", + "CreateCustomerGatewayRequest", + "CreateRoutingPolicyRequest", + "CreateVpnGatewayRequest", + "DeleteConnectionRequest", + "DeleteCustomerGatewayRequest", + "DeleteRoutingPolicyRequest", + "DeleteVpnGatewayRequest", + "DetachRoutingPolicyRequest", + "DisableRoutePropagationRequest", + "EnableRoutePropagationRequest", + "GetConnectionRequest", + "GetCustomerGatewayRequest", + "GetRoutingPolicyRequest", + "GetVpnGatewayRequest", + "ListConnectionsRequest", + "ListConnectionsResponse", + "ListCustomerGatewaysRequest", + "ListCustomerGatewaysResponse", + "ListRoutingPoliciesRequest", + "ListRoutingPoliciesResponse", + "ListVpnGatewayTypesRequest", + "ListVpnGatewayTypesResponse", + "ListVpnGatewaysRequest", + "ListVpnGatewaysResponse", + "RenewConnectionPskRequest", + "RenewConnectionPskResponse", + "SetRoutingPolicyRequest", + "UpdateConnectionRequest", + "UpdateCustomerGatewayRequest", + "UpdateRoutingPolicyRequest", + "UpdateVpnGatewayRequest", + "S2SVpnV1Alpha1API", +] diff --git a/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/api.py b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/api.py new file mode 100644 index 00000000..04f94464 --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/api.py @@ -0,0 +1,1565 @@ +# 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 Awaitable, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + ConnectionStatus, + CreateConnectionRequestInitiationPolicy, + ListConnectionsRequestOrderBy, + ListCustomerGatewaysRequestOrderBy, + ListRoutingPoliciesRequestOrderBy, + ListVpnGatewaysRequestOrderBy, + VpnGatewayStatus, + Connection, + ConnectionCipher, + CreateConnectionRequest, + CreateConnectionRequestBgpConfig, + CreateConnectionResponse, + CreateCustomerGatewayRequest, + CreateRoutingPolicyRequest, + CreateVpnGatewayRequest, + CreateVpnGatewayRequestPublicConfig, + CustomerGateway, + DetachRoutingPolicyRequest, + GatewayType, + ListConnectionsResponse, + ListCustomerGatewaysResponse, + ListRoutingPoliciesResponse, + ListVpnGatewayTypesResponse, + ListVpnGatewaysResponse, + RenewConnectionPskResponse, + RoutingPolicy, + SetRoutingPolicyRequest, + UpdateConnectionRequest, + UpdateCustomerGatewayRequest, + UpdateRoutingPolicyRequest, + UpdateVpnGatewayRequest, + VpnGateway, +) +from .content import ( + VPN_GATEWAY_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Connection, + unmarshal_CustomerGateway, + unmarshal_RoutingPolicy, + unmarshal_VpnGateway, + unmarshal_CreateConnectionResponse, + unmarshal_ListConnectionsResponse, + unmarshal_ListCustomerGatewaysResponse, + unmarshal_ListRoutingPoliciesResponse, + unmarshal_ListVpnGatewayTypesResponse, + unmarshal_ListVpnGatewaysResponse, + unmarshal_RenewConnectionPskResponse, + marshal_CreateConnectionRequest, + marshal_CreateCustomerGatewayRequest, + marshal_CreateRoutingPolicyRequest, + marshal_CreateVpnGatewayRequest, + marshal_DetachRoutingPolicyRequest, + marshal_SetRoutingPolicyRequest, + marshal_UpdateConnectionRequest, + marshal_UpdateCustomerGatewayRequest, + marshal_UpdateRoutingPolicyRequest, + marshal_UpdateVpnGatewayRequest, +) + + +class S2SVpnV1Alpha1API(API): + """ + This API allows you to manage your Site-to-Site VPN. + """ + + async def list_vpn_gateway_types( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVpnGatewayTypesResponse: + """ + List VPN gateway types. + List the different VPN gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available VPN gateway type. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of VPN gateway types to return per page. + :return: :class:`ListVpnGatewayTypesResponse ` + + Usage: + :: + + result = await api.list_vpn_gateway_types() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateway-types", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVpnGatewayTypesResponse(res.json()) + + async def list_vpn_gateway_types_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> list[GatewayType]: + """ + List VPN gateway types. + List the different VPN gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available VPN gateway type. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of VPN gateway types to return per page. + :return: :class:`list[GatewayType] ` + + Usage: + :: + + result = await api.list_vpn_gateway_types_all() + """ + + return await fetch_all_pages_async( + type=ListVpnGatewayTypesResponse, + key="gateway_types", + fetcher=self.list_vpn_gateway_types, + args={ + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + async def list_vpn_gateways( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVpnGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[VpnGatewayStatus]] = None, + gateway_types: Optional[list[str]] = None, + private_network_ids: Optional[list[str]] = None, + ) -> ListVpnGatewaysResponse: + """ + List VPN gateways. + List all your VPN gateways. 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 page: Page number to return. + :param page_size: Maximum number of VPN gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: VPN gateway name to filter for. + :param tags: Tags to filter for. + :param statuses: VPN gateway statuses to filter for. + :param gateway_types: Filter for VPN gateways of these types. + :param private_network_ids: Filter for VPN gateways attached to these private networks. + :return: :class:`ListVpnGatewaysResponse ` + + Usage: + :: + + result = await api.list_vpn_gateways() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways", + params={ + "gateway_types": gateway_types, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "project_id": project_id or self.client.default_project_id, + "statuses": statuses, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVpnGatewaysResponse(res.json()) + + async def list_vpn_gateways_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVpnGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[VpnGatewayStatus]] = None, + gateway_types: Optional[list[str]] = None, + private_network_ids: Optional[list[str]] = None, + ) -> list[VpnGateway]: + """ + List VPN gateways. + List all your VPN gateways. 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 page: Page number to return. + :param page_size: Maximum number of VPN gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: VPN gateway name to filter for. + :param tags: Tags to filter for. + :param statuses: VPN gateway statuses to filter for. + :param gateway_types: Filter for VPN gateways of these types. + :param private_network_ids: Filter for VPN gateways attached to these private networks. + :return: :class:`list[VpnGateway] ` + + Usage: + :: + + result = await api.list_vpn_gateways_all() + """ + + return await fetch_all_pages_async( + type=ListVpnGatewaysResponse, + key="gateways", + fetcher=self.list_vpn_gateways, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "statuses": statuses, + "gateway_types": gateway_types, + "private_network_ids": private_network_ids, + }, + ) + + async def get_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> VpnGateway: + """ + Get a VPN gateway. + Get a VPN gateway for the given VPN gateway ID. + :param gateway_id: ID of the requested VPN gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = await api.get_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + async def wait_for_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + options: Optional[ + WaitForOptions[VpnGateway, Union[bool, Awaitable[bool]]] + ] = None, + ) -> VpnGateway: + """ + Get a VPN gateway. + Get a VPN gateway for the given VPN gateway ID. + :param gateway_id: ID of the requested VPN gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = await api.get_vpn_gateway( + gateway_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in VPN_GATEWAY_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_vpn_gateway, + options=options, + args={ + "gateway_id": gateway_id, + "region": region, + }, + ) + + async def create_vpn_gateway( + self, + *, + name: str, + gateway_type: str, + private_network_id: str, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + public_config: Optional[CreateVpnGatewayRequestPublicConfig] = None, + ipam_private_ipv4_id: Optional[str] = None, + ipam_private_ipv6_id: Optional[str] = None, + zone: Optional[ScwZone] = None, + ) -> VpnGateway: + """ + Create VPN gateway. + :param name: Name of the VPN gateway. + :param gateway_type: VPN gateway type (commercial offer type). + :param private_network_id: ID of the Private Network to attach to the VPN gateway. + :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 VPN gateway in. + :param tags: List of tags to apply to the VPN gateway. + :param public_config: Public endpoint configuration of the VPN gateway. + One-Of ('endpoint'): at most one of 'public_config' could be set. + :param ipam_private_ipv4_id: ID of the IPAM private IPv4 address to attach to the VPN gateway. + :param ipam_private_ipv6_id: ID of the IPAM private IPv6 address to attach to the VPN gateway. + :param zone: Availability Zone where the VPN gateway should be provisioned. If no zone is specified, the VPN gateway will be automatically placed. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = await api.create_vpn_gateway( + name="example", + gateway_type="example", + private_network_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways", + body=marshal_CreateVpnGatewayRequest( + CreateVpnGatewayRequest( + name=name, + gateway_type=gateway_type, + private_network_id=private_network_id, + region=region, + project_id=project_id, + tags=tags, + ipam_private_ipv4_id=ipam_private_ipv4_id, + ipam_private_ipv6_id=ipam_private_ipv6_id, + zone=zone, + public_config=public_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + async def update_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> VpnGateway: + """ + Update a VPN gateway. + Update an existing VPN gateway, specified by its VPN gateway ID. Only its name and tags can be updated. + :param gateway_id: ID of the VPN gateway to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the VPN gateway. + :param tags: List of tags to apply to the VPN Gateway. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = await api.update_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + body=marshal_UpdateVpnGatewayRequest( + UpdateVpnGatewayRequest( + gateway_id=gateway_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + async def delete_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> VpnGateway: + """ + Delete a VPN gateway. + Delete an existing VPN gateway, specified by its VPN gateway ID. + :param gateway_id: ID of the VPN gateway to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = await api.delete_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + async def list_connections( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListConnectionsRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[ConnectionStatus]] = None, + is_ipv6: Optional[bool] = None, + routing_policy_ids: Optional[list[str]] = None, + route_propagation_enabled: Optional[bool] = None, + vpn_gateway_ids: Optional[list[str]] = None, + customer_gateway_ids: Optional[list[str]] = None, + ) -> ListConnectionsResponse: + """ + List connections. + List all your 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 page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Connection name to filter for. + :param tags: Tags to filter for. + :param statuses: Connection statuses to filter for. + :param is_ipv6: Filter connections with IP version of IPSec tunnel. + :param routing_policy_ids: Filter for connections using these routing policies. + :param route_propagation_enabled: Filter for connections with route propagation enabled. + :param vpn_gateway_ids: Filter for connections attached to these VPN gateways. + :param customer_gateway_ids: Filter for connections attached to these customer gateways. + :return: :class:`ListConnectionsResponse ` + + Usage: + :: + + result = await api.list_connections() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections", + params={ + "customer_gateway_ids": customer_gateway_ids, + "is_ipv6": is_ipv6, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "route_propagation_enabled": route_propagation_enabled, + "routing_policy_ids": routing_policy_ids, + "statuses": statuses, + "tags": tags, + "vpn_gateway_ids": vpn_gateway_ids, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListConnectionsResponse(res.json()) + + async def list_connections_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListConnectionsRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[ConnectionStatus]] = None, + is_ipv6: Optional[bool] = None, + routing_policy_ids: Optional[list[str]] = None, + route_propagation_enabled: Optional[bool] = None, + vpn_gateway_ids: Optional[list[str]] = None, + customer_gateway_ids: Optional[list[str]] = None, + ) -> list[Connection]: + """ + List connections. + List all your 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 page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Connection name to filter for. + :param tags: Tags to filter for. + :param statuses: Connection statuses to filter for. + :param is_ipv6: Filter connections with IP version of IPSec tunnel. + :param routing_policy_ids: Filter for connections using these routing policies. + :param route_propagation_enabled: Filter for connections with route propagation enabled. + :param vpn_gateway_ids: Filter for connections attached to these VPN gateways. + :param customer_gateway_ids: Filter for connections attached to these customer gateways. + :return: :class:`list[Connection] ` + + Usage: + :: + + result = await api.list_connections_all() + """ + + return await fetch_all_pages_async( + type=ListConnectionsResponse, + key="connections", + fetcher=self.list_connections, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "statuses": statuses, + "is_ipv6": is_ipv6, + "routing_policy_ids": routing_policy_ids, + "route_propagation_enabled": route_propagation_enabled, + "vpn_gateway_ids": vpn_gateway_ids, + "customer_gateway_ids": customer_gateway_ids, + }, + ) + + async def get_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + Get a connection. + Get a connection for the given connection ID. The response object includes information about the connection's various configuration details. + :param connection_id: ID of the requested connection. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.get_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def create_connection( + self, + *, + name: str, + is_ipv6: bool, + initiation_policy: CreateConnectionRequestInitiationPolicy, + ikev2_ciphers: list[ConnectionCipher], + esp_ciphers: list[ConnectionCipher], + enable_route_propagation: bool, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + vpn_gateway_id: str, + customer_gateway_id: str, + bgp_config_ipv4: Optional[CreateConnectionRequestBgpConfig] = None, + bgp_config_ipv6: Optional[CreateConnectionRequestBgpConfig] = None, + ) -> CreateConnectionResponse: + """ + Create a connection. + :param name: Name of the connection. + :param is_ipv6: Defines IP version of the IPSec Tunnel. + :param initiation_policy: Who initiates the IPsec tunnel. + :param ikev2_ciphers: List of IKE v2 ciphers proposed for the IPsec tunnel. + :param esp_ciphers: List of ESP ciphers proposed for the IPsec tunnel. + :param enable_route_propagation: Defines whether route propagation is enabled or not. + :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 connection in. + :param tags: List of tags to apply to the connection. + :param vpn_gateway_id: ID of the VPN gateway to attach to the connection. + :param customer_gateway_id: ID of the customer gateway to attach to the connection. + :param bgp_config_ipv4: BGP config of IPv4 session, including interco private IPv4 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + :param bgp_config_ipv6: BGP config of IPv6 session, including interco private IPv6 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + :return: :class:`CreateConnectionResponse ` + + Usage: + :: + + result = await api.create_connection( + name="example", + is_ipv6=False, + initiation_policy=CreateConnectionRequestInitiationPolicy.unknown_initiation_policy, + ikev2_ciphers=[], + esp_ciphers=[], + enable_route_propagation=False, + vpn_gateway_id="example", + customer_gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections", + body=marshal_CreateConnectionRequest( + CreateConnectionRequest( + name=name, + is_ipv6=is_ipv6, + initiation_policy=initiation_policy, + ikev2_ciphers=ikev2_ciphers, + esp_ciphers=esp_ciphers, + enable_route_propagation=enable_route_propagation, + region=region, + project_id=project_id, + tags=tags, + vpn_gateway_id=vpn_gateway_id, + customer_gateway_id=customer_gateway_id, + bgp_config_ipv4=bgp_config_ipv4, + bgp_config_ipv6=bgp_config_ipv6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CreateConnectionResponse(res.json()) + + async def update_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + initiation_policy: Optional[CreateConnectionRequestInitiationPolicy] = None, + ikev2_ciphers: Optional[list[ConnectionCipher]] = None, + esp_ciphers: Optional[list[ConnectionCipher]] = None, + ) -> Connection: + """ + Update a connection. + Update an existing connection, specified by its connection ID. + :param connection_id: ID of the connection to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the connection. + :param tags: List of tags to apply to the connection. + :param initiation_policy: Who initiates the IPsec tunnel. + :param ikev2_ciphers: List of IKE v2 ciphers proposed for the IPsec tunnel. + :param esp_ciphers: List of ESP ciphers proposed for the IPsec tunnel. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.update_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + body=marshal_UpdateConnectionRequest( + UpdateConnectionRequest( + connection_id=connection_id, + region=region, + name=name, + tags=tags, + initiation_policy=initiation_policy, + ikev2_ciphers=ikev2_ciphers, + esp_ciphers=esp_ciphers, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def delete_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a connection. + Delete an existing connection, specified by its connection ID. + :param connection_id: ID of the connection to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + ) + + self._throw_on_error(res) + + async def renew_connection_psk( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> RenewConnectionPskResponse: + """ + Renew pre-shared key. + Renew pre-shared key for a given connection. + :param connection_id: ID of the connection to renew the PSK. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`RenewConnectionPskResponse ` + + Usage: + :: + + result = await api.renew_connection_psk( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/renew-psk", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_RenewConnectionPskResponse(res.json()) + + async def set_routing_policy( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + routing_policy_v4: Optional[str] = None, + routing_policy_v6: Optional[str] = None, + ) -> Connection: + """ + Set a new routing policy. + Set a new routing policy on a connection, overriding the existing one if present, specified by its connection ID. + :param connection_id: ID of the connection whose routing policy is being updated. + :param region: Region to target. If none is passed will use default region from the config. + :param routing_policy_v4: ID of the routing policy to set for the BGP IPv4 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :param routing_policy_v6: ID of the routing policy to set for the BGP IPv6 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.set_routing_policy( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/set-routing-policy", + body=marshal_SetRoutingPolicyRequest( + SetRoutingPolicyRequest( + connection_id=connection_id, + region=region, + routing_policy_v4=routing_policy_v4, + routing_policy_v6=routing_policy_v6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def detach_routing_policy( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + routing_policy_v4: Optional[str] = None, + routing_policy_v6: Optional[str] = None, + ) -> Connection: + """ + Detach a routing policy. + Detach an existing routing policy from a connection, specified by its connection ID. + :param connection_id: ID of the connection from which routing policy is being detached. + :param region: Region to target. If none is passed will use default region from the config. + :param routing_policy_v4: ID of the routing policy to detach from the BGP IPv4 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :param routing_policy_v6: ID of the routing policy to detach from the BGP IPv6 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.detach_routing_policy( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/detach-routing-policy", + body=marshal_DetachRoutingPolicyRequest( + DetachRoutingPolicyRequest( + connection_id=connection_id, + region=region, + routing_policy_v4=routing_policy_v4, + routing_policy_v6=routing_policy_v6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def enable_route_propagation( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + 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 connection_id: ID of the connection on which to enable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.enable_route_propagation( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/enable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def disable_route_propagation( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + Disable route propagation. + Prevent any prefixes from being announced in the BGP session. Traffic will not be able to flow over the VPN Gateway until route propagation is re-enabled. + :param connection_id: ID of the connection on which to disable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = await api.disable_route_propagation( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/disable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + async def list_customer_gateways( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> ListCustomerGatewaysResponse: + """ + List customer gateways. + List all your customer gateways. A number of filters are available, including Project ID, name, and tags. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of customer gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Customer gateway name to filter for. + :param tags: Tags to filter for. + :return: :class:`ListCustomerGatewaysResponse ` + + Usage: + :: + + result = await api.list_customer_gateways() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways", + params={ + "name": name, + "order_by": order_by, + "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_ListCustomerGatewaysResponse(res.json()) + + async def list_customer_gateways_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> list[CustomerGateway]: + """ + List customer gateways. + List all your customer gateways. A number of filters are available, including Project ID, name, and tags. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of customer gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Customer gateway name to filter for. + :param tags: Tags to filter for. + :return: :class:`list[CustomerGateway] ` + + Usage: + :: + + result = await api.list_customer_gateways_all() + """ + + return await fetch_all_pages_async( + type=ListCustomerGatewaysResponse, + key="gateways", + fetcher=self.list_customer_gateways, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + }, + ) + + async def get_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> CustomerGateway: + """ + Get a customer gateway. + Get a customer gateway for the given customer gateway ID. + :param gateway_id: ID of the requested customer gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = await api.get_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + async def create_customer_gateway( + self, + *, + name: str, + asn: int, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv4_public: Optional[str] = None, + ipv6_public: Optional[str] = None, + ) -> CustomerGateway: + """ + Create a customer gateway. + :param name: Name of the customer gateway. + :param asn: AS Number of the customer gateway. + :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 customer gateway in. + :param tags: List of tags to apply to the customer gateway. + :param ipv4_public: Public IPv4 address of the customer gateway. + :param ipv6_public: Public IPv6 address of the customer gateway. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = await api.create_customer_gateway( + name="example", + asn=1, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways", + body=marshal_CreateCustomerGatewayRequest( + CreateCustomerGatewayRequest( + name=name, + asn=asn, + region=region, + project_id=project_id, + tags=tags, + ipv4_public=ipv4_public, + ipv6_public=ipv6_public, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + async def update_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv4_public: Optional[str] = None, + ipv6_public: Optional[str] = None, + asn: Optional[int] = None, + ) -> CustomerGateway: + """ + Update a customer gateway. + Update an existing customer gateway, specified by its customer gateway ID. You can update its name, tags, public IPv4 & IPv6 address and AS Number. + :param gateway_id: ID of the customer gateway to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the customer gateway. + :param tags: List of tags to apply to the customer gateway. + :param ipv4_public: Public IPv4 address of the customer gateway. + :param ipv6_public: Public IPv6 address of the customer gateway. + :param asn: AS Number of the customer gateway. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = await api.update_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + body=marshal_UpdateCustomerGatewayRequest( + UpdateCustomerGatewayRequest( + gateway_id=gateway_id, + region=region, + name=name, + tags=tags, + ipv4_public=ipv4_public, + ipv6_public=ipv6_public, + asn=asn, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + async def delete_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a customer gateway. + Delete an existing customer gateway, specified by its customer gateway ID. + :param gateway_id: ID of the customer gateway to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = await api.delete_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + + async def list_routing_policies( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv6: Optional[bool] = None, + ) -> ListRoutingPoliciesResponse: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple connections (S2S VPN connections). + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of routing policies to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :param ipv6: Filter for the routing policies based on IP prefixes version. + :return: :class:`ListRoutingPoliciesResponse ` + + Usage: + :: + + result = await api.list_routing_policies() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies", + params={ + "ipv6": ipv6, + "name": name, + "order_by": order_by, + "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[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv6: Optional[bool] = None, + ) -> list[RoutingPolicy]: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple connections (S2S VPN connections). + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of routing policies to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :param ipv6: Filter for the routing policies based on IP prefixes version. + :return: :class:`list[RoutingPolicy] ` + + 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, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "ipv6": ipv6, + }, + ) + + async def get_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[ScwRegion] = 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"/s2s-vpn/v1alpha1/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, + is_ipv6: bool, + region: Optional[ScwRegion] = 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 customer gateway, and the outgoing routes to announce to the customer gateway. + :param name: Name of the routing policy. + :param is_ipv6: IP prefixes version of the routing policy. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project to create the routing policy in. + :param tags: List of tags to apply to the routing policy. + :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", + is_ipv6=False, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies", + body=marshal_CreateRoutingPolicyRequest( + CreateRoutingPolicyRequest( + name=name, + is_ipv6=is_ipv6, + 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[ScwRegion] = 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"/s2s-vpn/v1alpha1/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[ScwRegion] = 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"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/content.py b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/content.py new file mode 100644 index 00000000..d65e22e6 --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/content.py @@ -0,0 +1,15 @@ +# 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 ( + VpnGatewayStatus, +) + +VPN_GATEWAY_TRANSIENT_STATUSES: list[VpnGatewayStatus] = [ + VpnGatewayStatus.CONFIGURING, + VpnGatewayStatus.PROVISIONING, + VpnGatewayStatus.DEPROVISIONING, +] +""" +Lists transient statutes of the enum :class:`VpnGatewayStatus `. +""" diff --git a/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/marshalling.py b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/marshalling.py new file mode 100644 index 00000000..bdb63081 --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/marshalling.py @@ -0,0 +1,1098 @@ +# 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 +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + BgpSessionStatus, + ConnectionInitiationPolicy, + ConnectionStatus, + TunnelStatus, + VpnGatewayStatus, + BgpSession, + ConnectionCipher, + Connection, + CustomerGateway, + RoutingPolicy, + VpnGatewayPrivateConfig, + VpnGatewayPublicConfig, + VpnGateway, + CreateConnectionResponse, + ListConnectionsResponse, + ListCustomerGatewaysResponse, + ListRoutingPoliciesResponse, + GatewayType, + ListVpnGatewayTypesResponse, + ListVpnGatewaysResponse, + RenewConnectionPskResponse, + CreateConnectionRequestBgpConfig, + CreateConnectionRequest, + CreateCustomerGatewayRequest, + CreateRoutingPolicyRequest, + CreateVpnGatewayRequestPublicConfig, + CreateVpnGatewayRequest, + DetachRoutingPolicyRequest, + SetRoutingPolicyRequest, + UpdateConnectionRequest, + UpdateCustomerGatewayRequest, + UpdateRoutingPolicyRequest, + UpdateVpnGatewayRequest, +) + + +def unmarshal_BgpSession(data: Any) -> BgpSession: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BgpSession' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + 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("private_ip", None) + if field is not None: + args["private_ip"] = field + else: + args["private_ip"] = None + + return BgpSession(**args) + + +def unmarshal_ConnectionCipher(data: Any) -> ConnectionCipher: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ConnectionCipher' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("encryption", None) + if field is not None: + args["encryption"] = field + else: + args["encryption"] = None + + field = data.get("integrity", None) + if field is not None: + args["integrity"] = field + else: + args["integrity"] = None + + field = data.get("dh_group", None) + if field is not None: + args["dh_group"] = field + else: + args["dh_group"] = None + + return ConnectionCipher(**args) + + +def unmarshal_Connection(data: Any) -> Connection: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Connection' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = ConnectionStatus.UNKNOWN_STATUS + + field = data.get("is_ipv6", None) + if field is not None: + args["is_ipv6"] = field + else: + args["is_ipv6"] = False + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("initiation_policy", None) + if field is not None: + args["initiation_policy"] = field + else: + args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY + + field = data.get("ikev2_ciphers", None) + if field is not None: + args["ikev2_ciphers"] = ( + [unmarshal_ConnectionCipher(v) for v in field] + if field is not None + else None + ) + else: + args["ikev2_ciphers"] = [] + + field = data.get("esp_ciphers", None) + if field is not None: + args["esp_ciphers"] = ( + [unmarshal_ConnectionCipher(v) for v in field] + if field is not None + else None + ) + else: + args["esp_ciphers"] = [] + + field = data.get("route_propagation_enabled", None) + if field is not None: + args["route_propagation_enabled"] = field + else: + args["route_propagation_enabled"] = False + + field = data.get("vpn_gateway_id", None) + if field is not None: + args["vpn_gateway_id"] = field + else: + args["vpn_gateway_id"] = None + + field = data.get("customer_gateway_id", None) + if field is not None: + args["customer_gateway_id"] = field + else: + args["customer_gateway_id"] = None + + field = data.get("tunnel_status", None) + if field is not None: + args["tunnel_status"] = field + else: + args["tunnel_status"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("bgp_status_ipv4", None) + if field is not None: + args["bgp_status_ipv4"] = field + else: + args["bgp_status_ipv4"] = BgpSessionStatus.UNKNOWN_STATUS + + field = data.get("bgp_status_ipv6", None) + if field is not None: + args["bgp_status_ipv6"] = field + else: + args["bgp_status_ipv6"] = BgpSessionStatus.UNKNOWN_STATUS + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("tunnel_status_ipv4", None) + if field is not None: + args["tunnel_status_ipv4"] = field + else: + args["tunnel_status_ipv4"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("tunnel_status_ipv6", None) + if field is not None: + args["tunnel_status_ipv6"] = field + else: + args["tunnel_status_ipv6"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("bgp_session_ipv4", None) + if field is not None: + args["bgp_session_ipv4"] = unmarshal_BgpSession(field) + else: + args["bgp_session_ipv4"] = None + + field = data.get("bgp_session_ipv6", None) + if field is not None: + args["bgp_session_ipv6"] = unmarshal_BgpSession(field) + else: + args["bgp_session_ipv6"] = None + + return Connection(**args) + + +def unmarshal_CustomerGateway(data: Any) -> CustomerGateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CustomerGateway' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + else: + args["asn"] = 0 + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("public_ipv4", None) + if field is not None: + args["public_ipv4"] = field + else: + args["public_ipv4"] = None + + field = data.get("public_ipv6", None) + if field is not None: + args["public_ipv6"] = field + else: + args["public_ipv6"] = None + + return CustomerGateway(**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 + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("is_ipv6", None) + if field is not None: + args["is_ipv6"] = field + else: + args["is_ipv6"] = False + + field = data.get("prefix_filter_in", None) + if field is not None: + args["prefix_filter_in"] = field + else: + args["prefix_filter_in"] = [] + + field = data.get("prefix_filter_out", None) + if field is not None: + args["prefix_filter_out"] = field + else: + args["prefix_filter_out"] = [] + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = 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 RoutingPolicy(**args) + + +def unmarshal_VpnGatewayPrivateConfig(data: Any) -> VpnGatewayPrivateConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGatewayPrivateConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + return VpnGatewayPrivateConfig(**args) + + +def unmarshal_VpnGatewayPublicConfig(data: Any) -> VpnGatewayPublicConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGatewayPublicConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("ipam_ipv4_id", None) + if field is not None: + args["ipam_ipv4_id"] = field + else: + args["ipam_ipv4_id"] = None + + field = data.get("ipam_ipv6_id", None) + if field is not None: + args["ipam_ipv6_id"] = field + else: + args["ipam_ipv6_id"] = None + + return VpnGatewayPublicConfig(**args) + + +def unmarshal_VpnGateway(data: Any) -> VpnGateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGateway' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = VpnGatewayStatus.UNKNOWN_STATUS + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("gateway_type", None) + if field is not None: + args["gateway_type"] = field + else: + args["gateway_type"] = None + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + + field = data.get("ipam_private_ipv4_id", None) + if field is not None: + args["ipam_private_ipv4_id"] = field + else: + args["ipam_private_ipv4_id"] = None + + field = data.get("ipam_private_ipv6_id", None) + if field is not None: + args["ipam_private_ipv6_id"] = field + else: + args["ipam_private_ipv6_id"] = None + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + else: + args["asn"] = 0 + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + else: + args["zone"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("public_config", None) + if field is not None: + args["public_config"] = unmarshal_VpnGatewayPublicConfig(field) + else: + args["public_config"] = None + + field = data.get("private_config", None) + if field is not None: + args["private_config"] = unmarshal_VpnGatewayPrivateConfig(field) + else: + args["private_config"] = None + + return VpnGateway(**args) + + +def unmarshal_CreateConnectionResponse(data: Any) -> CreateConnectionResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CreateConnectionResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("pre_shared_key", None) + if field is not None: + args["pre_shared_key"] = field + else: + args["pre_shared_key"] = None + + field = data.get("connection", None) + if field is not None: + args["connection"] = unmarshal_Connection(field) + else: + args["connection"] = None + + return CreateConnectionResponse(**args) + + +def unmarshal_ListConnectionsResponse(data: Any) -> ListConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListConnectionsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_Connection(v) for v in field] if field is not None else None + ) + else: + args["connections"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListConnectionsResponse(**args) + + +def unmarshal_ListCustomerGatewaysResponse(data: Any) -> ListCustomerGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListCustomerGatewaysResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_CustomerGateway(v) for v in field] if field is not None else None + ) + else: + args["gateways"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListCustomerGatewaysResponse(**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 + ) + else: + args["routing_policies"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListRoutingPoliciesResponse(**args) + + +def unmarshal_GatewayType(data: Any) -> GatewayType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GatewayType' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + else: + args["bandwidth"] = None + + field = data.get("allowed_connections", None) + if field is not None: + args["allowed_connections"] = field + else: + args["allowed_connections"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + return GatewayType(**args) + + +def unmarshal_ListVpnGatewayTypesResponse(data: Any) -> ListVpnGatewayTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVpnGatewayTypesResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateway_types", None) + if field is not None: + args["gateway_types"] = ( + [unmarshal_GatewayType(v) for v in field] if field is not None else None + ) + else: + args["gateway_types"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListVpnGatewayTypesResponse(**args) + + +def unmarshal_ListVpnGatewaysResponse(data: Any) -> ListVpnGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVpnGatewaysResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_VpnGateway(v) for v in field] if field is not None else None + ) + else: + args["gateways"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListVpnGatewaysResponse(**args) + + +def unmarshal_RenewConnectionPskResponse(data: Any) -> RenewConnectionPskResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RenewConnectionPskResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("pre_shared_key", None) + if field is not None: + args["pre_shared_key"] = field + else: + args["pre_shared_key"] = None + + field = data.get("connection", None) + if field is not None: + args["connection"] = unmarshal_Connection(field) + else: + args["connection"] = None + + return RenewConnectionPskResponse(**args) + + +def marshal_ConnectionCipher( + request: ConnectionCipher, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.encryption is not None: + output["encryption"] = request.encryption + + if request.integrity is not None: + output["integrity"] = request.integrity + + if request.dh_group is not None: + output["dh_group"] = request.dh_group + + return output + + +def marshal_CreateConnectionRequestBgpConfig( + request: CreateConnectionRequestBgpConfig, + 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_CreateConnectionRequest( + request: CreateConnectionRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.is_ipv6 is not None: + output["is_ipv6"] = request.is_ipv6 + + if request.initiation_policy is not None: + output["initiation_policy"] = request.initiation_policy + + if request.ikev2_ciphers is not None: + output["ikev2_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.ikev2_ciphers + ] + + if request.esp_ciphers is not None: + output["esp_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.esp_ciphers + ] + + if request.enable_route_propagation is not None: + output["enable_route_propagation"] = request.enable_route_propagation + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.vpn_gateway_id is not None: + output["vpn_gateway_id"] = request.vpn_gateway_id + + if request.customer_gateway_id is not None: + output["customer_gateway_id"] = request.customer_gateway_id + + if request.bgp_config_ipv4 is not None: + output["bgp_config_ipv4"] = marshal_CreateConnectionRequestBgpConfig( + request.bgp_config_ipv4, defaults + ) + + if request.bgp_config_ipv6 is not None: + output["bgp_config_ipv6"] = marshal_CreateConnectionRequestBgpConfig( + request.bgp_config_ipv6, defaults + ) + + return output + + +def marshal_CreateCustomerGatewayRequest( + request: CreateCustomerGatewayRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.asn is not None: + output["asn"] = request.asn + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.ipv4_public is not None: + output["ipv4_public"] = request.ipv4_public + + if request.ipv6_public is not None: + output["ipv6_public"] = request.ipv6_public + + 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.is_ipv6 is not None: + output["is_ipv6"] = request.is_ipv6 + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = 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_CreateVpnGatewayRequestPublicConfig( + request: CreateVpnGatewayRequestPublicConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.ipam_ipv4_id is not None: + output["ipam_ipv4_id"] = request.ipam_ipv4_id + + if request.ipam_ipv6_id is not None: + output["ipam_ipv6_id"] = request.ipam_ipv6_id + + return output + + +def marshal_CreateVpnGatewayRequest( + request: CreateVpnGatewayRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="public_config", + value=request.public_config, + marshal_func=marshal_CreateVpnGatewayRequestPublicConfig, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.gateway_type is not None: + output["gateway_type"] = request.gateway_type + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.ipam_private_ipv4_id is not None: + output["ipam_private_ipv4_id"] = request.ipam_private_ipv4_id + + if request.ipam_private_ipv6_id is not None: + output["ipam_private_ipv6_id"] = request.ipam_private_ipv6_id + + if request.zone is not None: + output["zone"] = request.zone + + return output + + +def marshal_DetachRoutingPolicyRequest( + request: DetachRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="routing_policy_v4", + value=request.routing_policy_v4, + marshal_func=None, + ), + OneOfPossibility( + param="routing_policy_v6", + value=request.routing_policy_v6, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_SetRoutingPolicyRequest( + request: SetRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="routing_policy_v4", + value=request.routing_policy_v4, + marshal_func=None, + ), + OneOfPossibility( + param="routing_policy_v6", + value=request.routing_policy_v6, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_UpdateConnectionRequest( + request: UpdateConnectionRequest, + 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.initiation_policy is not None: + output["initiation_policy"] = request.initiation_policy + + if request.ikev2_ciphers is not None: + output["ikev2_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.ikev2_ciphers + ] + + if request.esp_ciphers is not None: + output["esp_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.esp_ciphers + ] + + return output + + +def marshal_UpdateCustomerGatewayRequest( + request: UpdateCustomerGatewayRequest, + 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.ipv4_public is not None: + output["ipv4_public"] = request.ipv4_public + + if request.ipv6_public is not None: + output["ipv6_public"] = request.ipv6_public + + if request.asn is not None: + output["asn"] = request.asn + + 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 + + +def marshal_UpdateVpnGatewayRequest( + request: UpdateVpnGatewayRequest, + 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 diff --git a/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/types.py b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/types.py new file mode 100644 index 00000000..61bdda79 --- /dev/null +++ b/scaleway-async/scaleway_async/s2s_vpn/v1alpha1/types.py @@ -0,0 +1,1337 @@ +# 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, field +from datetime import datetime +from enum import Enum +from typing import Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class BgpSessionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UP = "up" + DOWN = "down" + DISABLED = "disabled" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionDhGroup(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_DHGROUP = "unknown_dhgroup" + MODP2048 = "modp2048" + MODP3072 = "modp3072" + MODP4096 = "modp4096" + ECP256 = "ecp256" + ECP384 = "ecp384" + ECP521 = "ecp521" + CURVE25519 = "curve25519" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionEncryption(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_ENCRYPTION = "unknown_encryption" + AES128 = "aes128" + AES192 = "aes192" + AES256 = "aes256" + AES128GCM = "aes128gcm" + AES192GCM = "aes192gcm" + AES256GCM = "aes256gcm" + AES128CCM = "aes128ccm" + AES256CCM = "aes256ccm" + CHACHA20POLY1305 = "chacha20poly1305" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionInitiationPolicy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INITIATION_POLICY = "unknown_initiation_policy" + VPN_GATEWAY = "vpn_gateway" + CUSTOMER_GATEWAY = "customer_gateway" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionIntegrity(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INTEGRITY = "unknown_integrity" + SHA256 = "sha256" + SHA384 = "sha384" + SHA512 = "sha512" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ACTIVE = "active" + LIMITED_CONNECTIVITY = "limited_connectivity" + DOWN = "down" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class CreateConnectionRequestInitiationPolicy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INITIATION_POLICY = "unknown_initiation_policy" + VPN_GATEWAY = "vpn_gateway" + CUSTOMER_GATEWAY = "customer_gateway" + + def __str__(self) -> str: + return str(self.value) + + +class ListConnectionsRequestOrderBy(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 ListCustomerGatewaysRequestOrderBy(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) + + +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) + + +class ListVpnGatewaysRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + TYPE_ASC = "type_asc" + TYPE_DESC = "type_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class TunnelStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TUNNEL_STATUS = "unknown_tunnel_status" + UP = "up" + DOWN = "down" + + def __str__(self) -> str: + return str(self.value) + + +class VpnGatewayStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CONFIGURING = "configuring" + FAILED = "failed" + PROVISIONING = "provisioning" + ACTIVE = "active" + DEPROVISIONING = "deprovisioning" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class BgpSession: + routing_policy_id: str + private_ip: str + + +@dataclass +class ConnectionCipher: + encryption: ConnectionEncryption + integrity: Optional[ConnectionIntegrity] = None + dh_group: Optional[ConnectionDhGroup] = None + + +@dataclass +class VpnGatewayPrivateConfig: + pass + + +@dataclass +class VpnGatewayPublicConfig: + ipam_ipv4_id: Optional[str] = None + ipam_ipv6_id: Optional[str] = None + + +@dataclass +class CreateConnectionRequestBgpConfig: + routing_policy_id: str + + +@dataclass +class Connection: + id: str + """ + Unique identifier of the connection. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the connection. + """ + + tags: list[str] + """ + List of tags applied to the connection. + """ + + status: ConnectionStatus + """ + Status of the connection. + """ + + is_ipv6: bool + """ + IP version of the IPSec Tunnel. + """ + + initiation_policy: ConnectionInitiationPolicy + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: list[ConnectionCipher] + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: list[ConnectionCipher] + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + route_propagation_enabled: bool + """ + Defines whether route propagation is enabled or not. + """ + + vpn_gateway_id: str + """ + ID of the VPN gateway attached to the connection. + """ + + customer_gateway_id: str + """ + ID of the customer gateway attached to the connection. + """ + + tunnel_status: TunnelStatus + """ + Status of the IPsec tunnel. + """ + + bgp_status_ipv4: BgpSessionStatus + """ + Status of the BGP IPv4 session. + """ + + bgp_status_ipv6: BgpSessionStatus + """ + Status of the BGP IPv6 session. + """ + + region: ScwRegion + """ + Region of the connection. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the connection. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the connection. + """ + + tunnel_status_ipv4: Optional[TunnelStatus] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + """ + Status of the IPv4 IPsec tunnel. + """ + + tunnel_status_ipv6: Optional[TunnelStatus] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + """ + Status of the IPv6 IPsec tunnel. + """ + + bgp_session_ipv4: Optional[BgpSession] = None + """ + BGP IPv4 session, including status, interco private IPv4 subnet and attached routing policy. + """ + + bgp_session_ipv6: Optional[BgpSession] = None + """ + BGP IPv6 session, including status, interco private IPv6 subnet and attached routing policy. + """ + + +@dataclass +class CreateVpnGatewayRequestPublicConfig: + ipam_ipv4_id: Optional[str] = None + ipam_ipv6_id: Optional[str] = None + + +@dataclass +class CustomerGateway: + id: str + """ + Unique identifier of the customer gateway. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the customer gateway. + """ + + tags: list[str] + """ + List of tags applied to the customer gateway. + """ + + asn: int + """ + AS Number of the customer gateway. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the customer gateway. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the customer gateway. + """ + + public_ipv4: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + public_ipv6: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + +@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. + """ + + is_ipv6: bool + """ + IP prefixes version of 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: ScwRegion + """ + Region of the routing policy. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the routing policy. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the routing policy. + """ + + +@dataclass +class GatewayType: + name: str + bandwidth: int + allowed_connections: int + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class VpnGateway: + id: str + """ + Unique identifier of the VPN gateway. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the VPN gateway. + """ + + tags: list[str] + """ + List of tags applied to the VPN gateway. + """ + + status: VpnGatewayStatus + """ + Status of the VPN gateway. + """ + + gateway_type: str + """ + Gateway type of the VPN gateway. + """ + + private_network_id: str + """ + ID of the Private Network attached to the VPN gateway. + """ + + ipam_private_ipv4_id: str + """ + ID of the IPAM private IPv4 address attached to the VPN gateway. + """ + + ipam_private_ipv6_id: str + """ + ID of the IPAM private IPv6 address attached to the VPN gateway. + """ + + asn: int + """ + Autonomous System Number (ASN) of the VPN gateway, used by Border Gateway Protocol (BGP) to exchange routing information with the customer gateway. + """ + + zone: ScwZone + """ + Zone where the VPN gateway resource is currently provisioned. + """ + + region: ScwRegion + """ + Region of the VPN gateway. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the VPN gateway. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the VPN gateway. + """ + + public_config: Optional[VpnGatewayPublicConfig] = None + + private_config: Optional[VpnGatewayPrivateConfig] = None + + +@dataclass +class CreateConnectionRequest: + name: str + """ + Name of the connection. + """ + + is_ipv6: bool + """ + Defines IP version of the IPSec Tunnel. + """ + + initiation_policy: CreateConnectionRequestInitiationPolicy + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: list[ConnectionCipher] + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: list[ConnectionCipher] + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + enable_route_propagation: bool + """ + Defines whether route propagation is enabled or not. + """ + + vpn_gateway_id: str + """ + ID of the VPN gateway to attach to the connection. + """ + + customer_gateway_id: str + """ + ID of the customer gateway to attach to the connection. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the connection in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the connection. + """ + + bgp_config_ipv4: Optional[CreateConnectionRequestBgpConfig] = None + """ + BGP config of IPv4 session, including interco private IPv4 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + """ + + bgp_config_ipv6: Optional[CreateConnectionRequestBgpConfig] = None + """ + BGP config of IPv6 session, including interco private IPv6 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + """ + + +@dataclass +class CreateConnectionResponse: + pre_shared_key: str + """ + New PSK generated for this connection. + """ + + connection: Optional[Connection] = None + """ + This connection. + """ + + +@dataclass +class CreateCustomerGatewayRequest: + name: str + """ + Name of the customer gateway. + """ + + asn: int + """ + AS Number of the customer gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the customer gateway in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the customer gateway. + """ + + ipv4_public: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + ipv6_public: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + +@dataclass +class CreateRoutingPolicyRequest: + name: str + """ + Name of the routing policy. + """ + + is_ipv6: bool + """ + IP prefixes version of the routing policy. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the routing policy in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[list[str]] = field(default_factory=list) + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[list[str]] = field(default_factory=list) + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class CreateVpnGatewayRequest: + name: str + """ + Name of the VPN gateway. + """ + + gateway_type: str + """ + VPN gateway type (commercial offer type). + """ + + private_network_id: str + """ + ID of the Private Network to attach to the VPN gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the VPN gateway in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the VPN gateway. + """ + + ipam_private_ipv4_id: Optional[str] = None + """ + ID of the IPAM private IPv4 address to attach to the VPN gateway. + """ + + ipam_private_ipv6_id: Optional[str] = None + """ + ID of the IPAM private IPv6 address to attach to the VPN gateway. + """ + + zone: Optional[ScwZone] = None + """ + Availability Zone where the VPN gateway should be provisioned. If no zone is specified, the VPN gateway will be automatically placed. + """ + + public_config: Optional[CreateVpnGatewayRequestPublicConfig] = None + + +@dataclass +class DeleteConnectionRequest: + connection_id: str + """ + ID of the connection to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteCustomerGatewayRequest: + gateway_id: str + """ + ID of the customer gateway to delete. + """ + + region: Optional[ScwRegion] = None + """ + 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[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteVpnGatewayRequest: + gateway_id: str + """ + ID of the VPN gateway to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachRoutingPolicyRequest: + connection_id: str + """ + ID of the connection from which routing policy is being detached. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + routing_policy_v4: Optional[str] = None + + routing_policy_v6: Optional[str] = None + + +@dataclass +class DisableRoutePropagationRequest: + connection_id: str + """ + ID of the connection on which to disable route propagation. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class EnableRoutePropagationRequest: + connection_id: str + """ + ID of the connection on which to enable route propagation. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetConnectionRequest: + connection_id: str + """ + ID of the requested connection. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetCustomerGatewayRequest: + gateway_id: str + """ + ID of the requested customer gateway. + """ + + region: Optional[ScwRegion] = None + """ + 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[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetVpnGatewayRequest: + gateway_id: str + """ + ID of the requested VPN gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListConnectionsRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of connections to return per page. + """ + + order_by: Optional[ListConnectionsRequestOrderBy] = ( + ListConnectionsRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Connection name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + statuses: Optional[list[ConnectionStatus]] = field(default_factory=list) + """ + Connection statuses to filter for. + """ + + is_ipv6: Optional[bool] = False + """ + Filter connections with IP version of IPSec tunnel. + """ + + routing_policy_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections using these routing policies. + """ + + route_propagation_enabled: Optional[bool] = False + """ + Filter for connections with route propagation enabled. + """ + + vpn_gateway_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections attached to these VPN gateways. + """ + + customer_gateway_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections attached to these customer gateways. + """ + + +@dataclass +class ListConnectionsResponse: + connections: list[Connection] + """ + List of connections on the current page. + """ + + total_count: int + """ + Total number of connections. + """ + + +@dataclass +class ListCustomerGatewaysRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of customer gateways to return per page. + """ + + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = ( + ListCustomerGatewaysRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Customer gateway name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + +@dataclass +class ListCustomerGatewaysResponse: + gateways: list[CustomerGateway] + """ + List of customer gateways on the current page. + """ + + total_count: int + """ + Total number of customer gateways. + """ + + +@dataclass +class ListRoutingPoliciesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of routing policies to return per page. + """ + + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = ( + ListRoutingPoliciesRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Routing policy name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + ipv6: Optional[bool] = False + """ + Filter for the routing policies based on IP prefixes version. + """ + + +@dataclass +class ListRoutingPoliciesResponse: + routing_policies: list[RoutingPolicy] + total_count: int + + +@dataclass +class ListVpnGatewayTypesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of VPN gateway types to return per page. + """ + + +@dataclass +class ListVpnGatewayTypesResponse: + gateway_types: list[GatewayType] + """ + List of VPN gateway types on the current page. + """ + + total_count: int + """ + Total number of gateway types. + """ + + +@dataclass +class ListVpnGatewaysRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of VPN gateways to return per page. + """ + + order_by: Optional[ListVpnGatewaysRequestOrderBy] = ( + ListVpnGatewaysRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + VPN gateway name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + statuses: Optional[list[VpnGatewayStatus]] = field(default_factory=list) + """ + VPN gateway statuses to filter for. + """ + + gateway_types: Optional[list[str]] = field(default_factory=list) + """ + Filter for VPN gateways of these types. + """ + + private_network_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for VPN gateways attached to these private networks. + """ + + +@dataclass +class ListVpnGatewaysResponse: + gateways: list[VpnGateway] + """ + List of VPN gateways on the current page. + """ + + total_count: int + """ + Total number of VPN gateways. + """ + + +@dataclass +class RenewConnectionPskRequest: + connection_id: str + """ + ID of the connection to renew the PSK. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class RenewConnectionPskResponse: + pre_shared_key: str + """ + New PSK generated for this connection. + """ + + connection: Optional[Connection] = None + """ + This connection. + """ + + +@dataclass +class SetRoutingPolicyRequest: + connection_id: str + """ + ID of the connection whose routing policy is being updated. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + routing_policy_v4: Optional[str] = None + + routing_policy_v6: Optional[str] = None + + +@dataclass +class UpdateConnectionRequest: + connection_id: str + """ + ID of the connection to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the connection. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the connection. + """ + + initiation_policy: Optional[CreateConnectionRequestInitiationPolicy] = ( + CreateConnectionRequestInitiationPolicy.UNKNOWN_INITIATION_POLICY + ) + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: Optional[list[ConnectionCipher]] = field(default_factory=list) + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: Optional[list[ConnectionCipher]] = field(default_factory=list) + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + +@dataclass +class UpdateCustomerGatewayRequest: + gateway_id: str + """ + ID of the customer gateway to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the customer gateway. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the customer gateway. + """ + + ipv4_public: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + ipv6_public: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + asn: Optional[int] = 0 + """ + AS Number of the customer gateway. + """ + + +@dataclass +class UpdateRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the routing policy. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[list[str]] = field(default_factory=list) + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[list[str]] = field(default_factory=list) + """ + IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class UpdateVpnGatewayRequest: + gateway_id: str + """ + ID of the VPN gateway to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the VPN gateway. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the VPN Gateway. + """ diff --git a/scaleway/scaleway/s2s_vpn/__init__.py b/scaleway/scaleway/s2s_vpn/__init__.py new file mode 100644 index 00000000..8b74a5ed --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/__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/s2s_vpn/v1alpha1/__init__.py b/scaleway/scaleway/s2s_vpn/v1alpha1/__init__.py new file mode 100644 index 00000000..6260bc94 --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/v1alpha1/__init__.py @@ -0,0 +1,123 @@ +# 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 BgpSessionStatus +from .types import ConnectionDhGroup +from .types import ConnectionEncryption +from .types import ConnectionInitiationPolicy +from .types import ConnectionIntegrity +from .types import ConnectionStatus +from .types import CreateConnectionRequestInitiationPolicy +from .types import ListConnectionsRequestOrderBy +from .types import ListCustomerGatewaysRequestOrderBy +from .types import ListRoutingPoliciesRequestOrderBy +from .types import ListVpnGatewaysRequestOrderBy +from .types import TunnelStatus +from .types import VpnGatewayStatus +from .content import VPN_GATEWAY_TRANSIENT_STATUSES +from .types import BgpSession +from .types import ConnectionCipher +from .types import VpnGatewayPrivateConfig +from .types import VpnGatewayPublicConfig +from .types import CreateConnectionRequestBgpConfig +from .types import Connection +from .types import CreateVpnGatewayRequestPublicConfig +from .types import CustomerGateway +from .types import RoutingPolicy +from .types import GatewayType +from .types import VpnGateway +from .types import CreateConnectionRequest +from .types import CreateConnectionResponse +from .types import CreateCustomerGatewayRequest +from .types import CreateRoutingPolicyRequest +from .types import CreateVpnGatewayRequest +from .types import DeleteConnectionRequest +from .types import DeleteCustomerGatewayRequest +from .types import DeleteRoutingPolicyRequest +from .types import DeleteVpnGatewayRequest +from .types import DetachRoutingPolicyRequest +from .types import DisableRoutePropagationRequest +from .types import EnableRoutePropagationRequest +from .types import GetConnectionRequest +from .types import GetCustomerGatewayRequest +from .types import GetRoutingPolicyRequest +from .types import GetVpnGatewayRequest +from .types import ListConnectionsRequest +from .types import ListConnectionsResponse +from .types import ListCustomerGatewaysRequest +from .types import ListCustomerGatewaysResponse +from .types import ListRoutingPoliciesRequest +from .types import ListRoutingPoliciesResponse +from .types import ListVpnGatewayTypesRequest +from .types import ListVpnGatewayTypesResponse +from .types import ListVpnGatewaysRequest +from .types import ListVpnGatewaysResponse +from .types import RenewConnectionPskRequest +from .types import RenewConnectionPskResponse +from .types import SetRoutingPolicyRequest +from .types import UpdateConnectionRequest +from .types import UpdateCustomerGatewayRequest +from .types import UpdateRoutingPolicyRequest +from .types import UpdateVpnGatewayRequest +from .api import S2SVpnV1Alpha1API + +__all__ = [ + "BgpSessionStatus", + "ConnectionDhGroup", + "ConnectionEncryption", + "ConnectionInitiationPolicy", + "ConnectionIntegrity", + "ConnectionStatus", + "CreateConnectionRequestInitiationPolicy", + "ListConnectionsRequestOrderBy", + "ListCustomerGatewaysRequestOrderBy", + "ListRoutingPoliciesRequestOrderBy", + "ListVpnGatewaysRequestOrderBy", + "TunnelStatus", + "VpnGatewayStatus", + "VPN_GATEWAY_TRANSIENT_STATUSES", + "BgpSession", + "ConnectionCipher", + "VpnGatewayPrivateConfig", + "VpnGatewayPublicConfig", + "CreateConnectionRequestBgpConfig", + "Connection", + "CreateVpnGatewayRequestPublicConfig", + "CustomerGateway", + "RoutingPolicy", + "GatewayType", + "VpnGateway", + "CreateConnectionRequest", + "CreateConnectionResponse", + "CreateCustomerGatewayRequest", + "CreateRoutingPolicyRequest", + "CreateVpnGatewayRequest", + "DeleteConnectionRequest", + "DeleteCustomerGatewayRequest", + "DeleteRoutingPolicyRequest", + "DeleteVpnGatewayRequest", + "DetachRoutingPolicyRequest", + "DisableRoutePropagationRequest", + "EnableRoutePropagationRequest", + "GetConnectionRequest", + "GetCustomerGatewayRequest", + "GetRoutingPolicyRequest", + "GetVpnGatewayRequest", + "ListConnectionsRequest", + "ListConnectionsResponse", + "ListCustomerGatewaysRequest", + "ListCustomerGatewaysResponse", + "ListRoutingPoliciesRequest", + "ListRoutingPoliciesResponse", + "ListVpnGatewayTypesRequest", + "ListVpnGatewayTypesResponse", + "ListVpnGatewaysRequest", + "ListVpnGatewaysResponse", + "RenewConnectionPskRequest", + "RenewConnectionPskResponse", + "SetRoutingPolicyRequest", + "UpdateConnectionRequest", + "UpdateCustomerGatewayRequest", + "UpdateRoutingPolicyRequest", + "UpdateVpnGatewayRequest", + "S2SVpnV1Alpha1API", +] diff --git a/scaleway/scaleway/s2s_vpn/v1alpha1/api.py b/scaleway/scaleway/s2s_vpn/v1alpha1/api.py new file mode 100644 index 00000000..e951d967 --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/v1alpha1/api.py @@ -0,0 +1,1563 @@ +# 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 Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + WaitForOptions, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + ConnectionStatus, + CreateConnectionRequestInitiationPolicy, + ListConnectionsRequestOrderBy, + ListCustomerGatewaysRequestOrderBy, + ListRoutingPoliciesRequestOrderBy, + ListVpnGatewaysRequestOrderBy, + VpnGatewayStatus, + Connection, + ConnectionCipher, + CreateConnectionRequest, + CreateConnectionRequestBgpConfig, + CreateConnectionResponse, + CreateCustomerGatewayRequest, + CreateRoutingPolicyRequest, + CreateVpnGatewayRequest, + CreateVpnGatewayRequestPublicConfig, + CustomerGateway, + DetachRoutingPolicyRequest, + GatewayType, + ListConnectionsResponse, + ListCustomerGatewaysResponse, + ListRoutingPoliciesResponse, + ListVpnGatewayTypesResponse, + ListVpnGatewaysResponse, + RenewConnectionPskResponse, + RoutingPolicy, + SetRoutingPolicyRequest, + UpdateConnectionRequest, + UpdateCustomerGatewayRequest, + UpdateRoutingPolicyRequest, + UpdateVpnGatewayRequest, + VpnGateway, +) +from .content import ( + VPN_GATEWAY_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_Connection, + unmarshal_CustomerGateway, + unmarshal_RoutingPolicy, + unmarshal_VpnGateway, + unmarshal_CreateConnectionResponse, + unmarshal_ListConnectionsResponse, + unmarshal_ListCustomerGatewaysResponse, + unmarshal_ListRoutingPoliciesResponse, + unmarshal_ListVpnGatewayTypesResponse, + unmarshal_ListVpnGatewaysResponse, + unmarshal_RenewConnectionPskResponse, + marshal_CreateConnectionRequest, + marshal_CreateCustomerGatewayRequest, + marshal_CreateRoutingPolicyRequest, + marshal_CreateVpnGatewayRequest, + marshal_DetachRoutingPolicyRequest, + marshal_SetRoutingPolicyRequest, + marshal_UpdateConnectionRequest, + marshal_UpdateCustomerGatewayRequest, + marshal_UpdateRoutingPolicyRequest, + marshal_UpdateVpnGatewayRequest, +) + + +class S2SVpnV1Alpha1API(API): + """ + This API allows you to manage your Site-to-Site VPN. + """ + + def list_vpn_gateway_types( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> ListVpnGatewayTypesResponse: + """ + List VPN gateway types. + List the different VPN gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available VPN gateway type. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of VPN gateway types to return per page. + :return: :class:`ListVpnGatewayTypesResponse ` + + Usage: + :: + + result = api.list_vpn_gateway_types() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateway-types", + params={ + "page": page, + "page_size": page_size or self.client.default_page_size, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVpnGatewayTypesResponse(res.json()) + + def list_vpn_gateway_types_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + ) -> list[GatewayType]: + """ + List VPN gateway types. + List the different VPN gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available VPN gateway type. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of VPN gateway types to return per page. + :return: :class:`list[GatewayType] ` + + Usage: + :: + + result = api.list_vpn_gateway_types_all() + """ + + return fetch_all_pages( + type=ListVpnGatewayTypesResponse, + key="gateway_types", + fetcher=self.list_vpn_gateway_types, + args={ + "region": region, + "page": page, + "page_size": page_size, + }, + ) + + def list_vpn_gateways( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVpnGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[VpnGatewayStatus]] = None, + gateway_types: Optional[list[str]] = None, + private_network_ids: Optional[list[str]] = None, + ) -> ListVpnGatewaysResponse: + """ + List VPN gateways. + List all your VPN gateways. 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 page: Page number to return. + :param page_size: Maximum number of VPN gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: VPN gateway name to filter for. + :param tags: Tags to filter for. + :param statuses: VPN gateway statuses to filter for. + :param gateway_types: Filter for VPN gateways of these types. + :param private_network_ids: Filter for VPN gateways attached to these private networks. + :return: :class:`ListVpnGatewaysResponse ` + + Usage: + :: + + result = api.list_vpn_gateways() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways", + params={ + "gateway_types": gateway_types, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "project_id": project_id or self.client.default_project_id, + "statuses": statuses, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListVpnGatewaysResponse(res.json()) + + def list_vpn_gateways_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListVpnGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[VpnGatewayStatus]] = None, + gateway_types: Optional[list[str]] = None, + private_network_ids: Optional[list[str]] = None, + ) -> list[VpnGateway]: + """ + List VPN gateways. + List all your VPN gateways. 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 page: Page number to return. + :param page_size: Maximum number of VPN gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: VPN gateway name to filter for. + :param tags: Tags to filter for. + :param statuses: VPN gateway statuses to filter for. + :param gateway_types: Filter for VPN gateways of these types. + :param private_network_ids: Filter for VPN gateways attached to these private networks. + :return: :class:`list[VpnGateway] ` + + Usage: + :: + + result = api.list_vpn_gateways_all() + """ + + return fetch_all_pages( + type=ListVpnGatewaysResponse, + key="gateways", + fetcher=self.list_vpn_gateways, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "statuses": statuses, + "gateway_types": gateway_types, + "private_network_ids": private_network_ids, + }, + ) + + def get_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> VpnGateway: + """ + Get a VPN gateway. + Get a VPN gateway for the given VPN gateway ID. + :param gateway_id: ID of the requested VPN gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = api.get_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + def wait_for_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + options: Optional[WaitForOptions[VpnGateway, bool]] = None, + ) -> VpnGateway: + """ + Get a VPN gateway. + Get a VPN gateway for the given VPN gateway ID. + :param gateway_id: ID of the requested VPN gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = api.get_vpn_gateway( + gateway_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in VPN_GATEWAY_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_vpn_gateway, + options=options, + args={ + "gateway_id": gateway_id, + "region": region, + }, + ) + + def create_vpn_gateway( + self, + *, + name: str, + gateway_type: str, + private_network_id: str, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + public_config: Optional[CreateVpnGatewayRequestPublicConfig] = None, + ipam_private_ipv4_id: Optional[str] = None, + ipam_private_ipv6_id: Optional[str] = None, + zone: Optional[ScwZone] = None, + ) -> VpnGateway: + """ + Create VPN gateway. + :param name: Name of the VPN gateway. + :param gateway_type: VPN gateway type (commercial offer type). + :param private_network_id: ID of the Private Network to attach to the VPN gateway. + :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 VPN gateway in. + :param tags: List of tags to apply to the VPN gateway. + :param public_config: Public endpoint configuration of the VPN gateway. + One-Of ('endpoint'): at most one of 'public_config' could be set. + :param ipam_private_ipv4_id: ID of the IPAM private IPv4 address to attach to the VPN gateway. + :param ipam_private_ipv6_id: ID of the IPAM private IPv6 address to attach to the VPN gateway. + :param zone: Availability Zone where the VPN gateway should be provisioned. If no zone is specified, the VPN gateway will be automatically placed. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = api.create_vpn_gateway( + name="example", + gateway_type="example", + private_network_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways", + body=marshal_CreateVpnGatewayRequest( + CreateVpnGatewayRequest( + name=name, + gateway_type=gateway_type, + private_network_id=private_network_id, + region=region, + project_id=project_id, + tags=tags, + ipam_private_ipv4_id=ipam_private_ipv4_id, + ipam_private_ipv6_id=ipam_private_ipv6_id, + zone=zone, + public_config=public_config, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + def update_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> VpnGateway: + """ + Update a VPN gateway. + Update an existing VPN gateway, specified by its VPN gateway ID. Only its name and tags can be updated. + :param gateway_id: ID of the VPN gateway to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the VPN gateway. + :param tags: List of tags to apply to the VPN Gateway. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = api.update_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + body=marshal_UpdateVpnGatewayRequest( + UpdateVpnGatewayRequest( + gateway_id=gateway_id, + region=region, + name=name, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + def delete_vpn_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> VpnGateway: + """ + Delete a VPN gateway. + Delete an existing VPN gateway, specified by its VPN gateway ID. + :param gateway_id: ID of the VPN gateway to delete. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VpnGateway ` + + Usage: + :: + + result = api.delete_vpn_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/vpn-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_VpnGateway(res.json()) + + def list_connections( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListConnectionsRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[ConnectionStatus]] = None, + is_ipv6: Optional[bool] = None, + routing_policy_ids: Optional[list[str]] = None, + route_propagation_enabled: Optional[bool] = None, + vpn_gateway_ids: Optional[list[str]] = None, + customer_gateway_ids: Optional[list[str]] = None, + ) -> ListConnectionsResponse: + """ + List connections. + List all your 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 page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Connection name to filter for. + :param tags: Tags to filter for. + :param statuses: Connection statuses to filter for. + :param is_ipv6: Filter connections with IP version of IPSec tunnel. + :param routing_policy_ids: Filter for connections using these routing policies. + :param route_propagation_enabled: Filter for connections with route propagation enabled. + :param vpn_gateway_ids: Filter for connections attached to these VPN gateways. + :param customer_gateway_ids: Filter for connections attached to these customer gateways. + :return: :class:`ListConnectionsResponse ` + + Usage: + :: + + result = api.list_connections() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections", + params={ + "customer_gateway_ids": customer_gateway_ids, + "is_ipv6": is_ipv6, + "name": name, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "route_propagation_enabled": route_propagation_enabled, + "routing_policy_ids": routing_policy_ids, + "statuses": statuses, + "tags": tags, + "vpn_gateway_ids": vpn_gateway_ids, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListConnectionsResponse(res.json()) + + def list_connections_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListConnectionsRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + statuses: Optional[list[ConnectionStatus]] = None, + is_ipv6: Optional[bool] = None, + routing_policy_ids: Optional[list[str]] = None, + route_propagation_enabled: Optional[bool] = None, + vpn_gateway_ids: Optional[list[str]] = None, + customer_gateway_ids: Optional[list[str]] = None, + ) -> list[Connection]: + """ + List connections. + List all your 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 page: Page number to return. + :param page_size: Maximum number of connections to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Connection name to filter for. + :param tags: Tags to filter for. + :param statuses: Connection statuses to filter for. + :param is_ipv6: Filter connections with IP version of IPSec tunnel. + :param routing_policy_ids: Filter for connections using these routing policies. + :param route_propagation_enabled: Filter for connections with route propagation enabled. + :param vpn_gateway_ids: Filter for connections attached to these VPN gateways. + :param customer_gateway_ids: Filter for connections attached to these customer gateways. + :return: :class:`list[Connection] ` + + Usage: + :: + + result = api.list_connections_all() + """ + + return fetch_all_pages( + type=ListConnectionsResponse, + key="connections", + fetcher=self.list_connections, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "statuses": statuses, + "is_ipv6": is_ipv6, + "routing_policy_ids": routing_policy_ids, + "route_propagation_enabled": route_propagation_enabled, + "vpn_gateway_ids": vpn_gateway_ids, + "customer_gateway_ids": customer_gateway_ids, + }, + ) + + def get_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + Get a connection. + Get a connection for the given connection ID. The response object includes information about the connection's various configuration details. + :param connection_id: ID of the requested connection. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = api.get_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def create_connection( + self, + *, + name: str, + is_ipv6: bool, + initiation_policy: CreateConnectionRequestInitiationPolicy, + ikev2_ciphers: list[ConnectionCipher], + esp_ciphers: list[ConnectionCipher], + enable_route_propagation: bool, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + vpn_gateway_id: str, + customer_gateway_id: str, + bgp_config_ipv4: Optional[CreateConnectionRequestBgpConfig] = None, + bgp_config_ipv6: Optional[CreateConnectionRequestBgpConfig] = None, + ) -> CreateConnectionResponse: + """ + Create a connection. + :param name: Name of the connection. + :param is_ipv6: Defines IP version of the IPSec Tunnel. + :param initiation_policy: Who initiates the IPsec tunnel. + :param ikev2_ciphers: List of IKE v2 ciphers proposed for the IPsec tunnel. + :param esp_ciphers: List of ESP ciphers proposed for the IPsec tunnel. + :param enable_route_propagation: Defines whether route propagation is enabled or not. + :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 connection in. + :param tags: List of tags to apply to the connection. + :param vpn_gateway_id: ID of the VPN gateway to attach to the connection. + :param customer_gateway_id: ID of the customer gateway to attach to the connection. + :param bgp_config_ipv4: BGP config of IPv4 session, including interco private IPv4 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + :param bgp_config_ipv6: BGP config of IPv6 session, including interco private IPv6 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + :return: :class:`CreateConnectionResponse ` + + Usage: + :: + + result = api.create_connection( + name="example", + is_ipv6=False, + initiation_policy=CreateConnectionRequestInitiationPolicy.unknown_initiation_policy, + ikev2_ciphers=[], + esp_ciphers=[], + enable_route_propagation=False, + vpn_gateway_id="example", + customer_gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections", + body=marshal_CreateConnectionRequest( + CreateConnectionRequest( + name=name, + is_ipv6=is_ipv6, + initiation_policy=initiation_policy, + ikev2_ciphers=ikev2_ciphers, + esp_ciphers=esp_ciphers, + enable_route_propagation=enable_route_propagation, + region=region, + project_id=project_id, + tags=tags, + vpn_gateway_id=vpn_gateway_id, + customer_gateway_id=customer_gateway_id, + bgp_config_ipv4=bgp_config_ipv4, + bgp_config_ipv6=bgp_config_ipv6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CreateConnectionResponse(res.json()) + + def update_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + initiation_policy: Optional[CreateConnectionRequestInitiationPolicy] = None, + ikev2_ciphers: Optional[list[ConnectionCipher]] = None, + esp_ciphers: Optional[list[ConnectionCipher]] = None, + ) -> Connection: + """ + Update a connection. + Update an existing connection, specified by its connection ID. + :param connection_id: ID of the connection to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the connection. + :param tags: List of tags to apply to the connection. + :param initiation_policy: Who initiates the IPsec tunnel. + :param ikev2_ciphers: List of IKE v2 ciphers proposed for the IPsec tunnel. + :param esp_ciphers: List of ESP ciphers proposed for the IPsec tunnel. + :return: :class:`Connection ` + + Usage: + :: + + result = api.update_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + body=marshal_UpdateConnectionRequest( + UpdateConnectionRequest( + connection_id=connection_id, + region=region, + name=name, + tags=tags, + initiation_policy=initiation_policy, + ikev2_ciphers=ikev2_ciphers, + esp_ciphers=esp_ciphers, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def delete_connection( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a connection. + Delete an existing connection, specified by its connection ID. + :param connection_id: ID of the connection to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_connection( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}", + ) + + self._throw_on_error(res) + + def renew_connection_psk( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> RenewConnectionPskResponse: + """ + Renew pre-shared key. + Renew pre-shared key for a given connection. + :param connection_id: ID of the connection to renew the PSK. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`RenewConnectionPskResponse ` + + Usage: + :: + + result = api.renew_connection_psk( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/renew-psk", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_RenewConnectionPskResponse(res.json()) + + def set_routing_policy( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + routing_policy_v4: Optional[str] = None, + routing_policy_v6: Optional[str] = None, + ) -> Connection: + """ + Set a new routing policy. + Set a new routing policy on a connection, overriding the existing one if present, specified by its connection ID. + :param connection_id: ID of the connection whose routing policy is being updated. + :param region: Region to target. If none is passed will use default region from the config. + :param routing_policy_v4: ID of the routing policy to set for the BGP IPv4 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :param routing_policy_v6: ID of the routing policy to set for the BGP IPv6 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :return: :class:`Connection ` + + Usage: + :: + + result = api.set_routing_policy( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/set-routing-policy", + body=marshal_SetRoutingPolicyRequest( + SetRoutingPolicyRequest( + connection_id=connection_id, + region=region, + routing_policy_v4=routing_policy_v4, + routing_policy_v6=routing_policy_v6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def detach_routing_policy( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + routing_policy_v4: Optional[str] = None, + routing_policy_v6: Optional[str] = None, + ) -> Connection: + """ + Detach a routing policy. + Detach an existing routing policy from a connection, specified by its connection ID. + :param connection_id: ID of the connection from which routing policy is being detached. + :param region: Region to target. If none is passed will use default region from the config. + :param routing_policy_v4: ID of the routing policy to detach from the BGP IPv4 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :param routing_policy_v6: ID of the routing policy to detach from the BGP IPv6 session. + One-Of ('routing_policy'): at most one of 'routing_policy_v4', 'routing_policy_v6' could be set. + :return: :class:`Connection ` + + Usage: + :: + + result = api.detach_routing_policy( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/detach-routing-policy", + body=marshal_DetachRoutingPolicyRequest( + DetachRoutingPolicyRequest( + connection_id=connection_id, + region=region, + routing_policy_v4=routing_policy_v4, + routing_policy_v6=routing_policy_v6, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def enable_route_propagation( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + 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 connection_id: ID of the connection on which to enable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = api.enable_route_propagation( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/enable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def disable_route_propagation( + self, + *, + connection_id: str, + region: Optional[ScwRegion] = None, + ) -> Connection: + """ + Disable route propagation. + Prevent any prefixes from being announced in the BGP session. Traffic will not be able to flow over the VPN Gateway until route propagation is re-enabled. + :param connection_id: ID of the connection on which to disable route propagation. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`Connection ` + + Usage: + :: + + result = api.disable_route_propagation( + connection_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_connection_id = validate_path_param("connection_id", connection_id) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/connections/{param_connection_id}/disable-route-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Connection(res.json()) + + def list_customer_gateways( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> ListCustomerGatewaysResponse: + """ + List customer gateways. + List all your customer gateways. A number of filters are available, including Project ID, name, and tags. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of customer gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Customer gateway name to filter for. + :param tags: Tags to filter for. + :return: :class:`ListCustomerGatewaysResponse ` + + Usage: + :: + + result = api.list_customer_gateways() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways", + params={ + "name": name, + "order_by": order_by, + "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_ListCustomerGatewaysResponse(res.json()) + + def list_customer_gateways_all( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ) -> list[CustomerGateway]: + """ + List customer gateways. + List all your customer gateways. A number of filters are available, including Project ID, name, and tags. + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of customer gateways to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Customer gateway name to filter for. + :param tags: Tags to filter for. + :return: :class:`list[CustomerGateway] ` + + Usage: + :: + + result = api.list_customer_gateways_all() + """ + + return fetch_all_pages( + type=ListCustomerGatewaysResponse, + key="gateways", + fetcher=self.list_customer_gateways, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + }, + ) + + def get_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> CustomerGateway: + """ + Get a customer gateway. + Get a customer gateway for the given customer gateway ID. + :param gateway_id: ID of the requested customer gateway. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = api.get_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + def create_customer_gateway( + self, + *, + name: str, + asn: int, + region: Optional[ScwRegion] = None, + project_id: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv4_public: Optional[str] = None, + ipv6_public: Optional[str] = None, + ) -> CustomerGateway: + """ + Create a customer gateway. + :param name: Name of the customer gateway. + :param asn: AS Number of the customer gateway. + :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 customer gateway in. + :param tags: List of tags to apply to the customer gateway. + :param ipv4_public: Public IPv4 address of the customer gateway. + :param ipv6_public: Public IPv6 address of the customer gateway. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = api.create_customer_gateway( + name="example", + asn=1, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways", + body=marshal_CreateCustomerGatewayRequest( + CreateCustomerGatewayRequest( + name=name, + asn=asn, + region=region, + project_id=project_id, + tags=tags, + ipv4_public=ipv4_public, + ipv6_public=ipv6_public, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + def update_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv4_public: Optional[str] = None, + ipv6_public: Optional[str] = None, + asn: Optional[int] = None, + ) -> CustomerGateway: + """ + Update a customer gateway. + Update an existing customer gateway, specified by its customer gateway ID. You can update its name, tags, public IPv4 & IPv6 address and AS Number. + :param gateway_id: ID of the customer gateway to update. + :param region: Region to target. If none is passed will use default region from the config. + :param name: Name of the customer gateway. + :param tags: List of tags to apply to the customer gateway. + :param ipv4_public: Public IPv4 address of the customer gateway. + :param ipv6_public: Public IPv6 address of the customer gateway. + :param asn: AS Number of the customer gateway. + :return: :class:`CustomerGateway ` + + Usage: + :: + + result = api.update_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + body=marshal_UpdateCustomerGatewayRequest( + UpdateCustomerGatewayRequest( + gateway_id=gateway_id, + region=region, + name=name, + tags=tags, + ipv4_public=ipv4_public, + ipv6_public=ipv6_public, + asn=asn, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_CustomerGateway(res.json()) + + def delete_customer_gateway( + self, + *, + gateway_id: str, + region: Optional[ScwRegion] = None, + ) -> None: + """ + Delete a customer gateway. + Delete an existing customer gateway, specified by its customer gateway ID. + :param gateway_id: ID of the customer gateway to delete. + :param region: Region to target. If none is passed will use default region from the config. + + Usage: + :: + + result = api.delete_customer_gateway( + gateway_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/s2s-vpn/v1alpha1/regions/{param_region}/customer-gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + + def list_routing_policies( + self, + *, + region: Optional[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv6: Optional[bool] = None, + ) -> ListRoutingPoliciesResponse: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple connections (S2S VPN connections). + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of routing policies to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :param ipv6: Filter for the routing policies based on IP prefixes version. + :return: :class:`ListRoutingPoliciesResponse ` + + Usage: + :: + + result = api.list_routing_policies() + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "GET", + f"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies", + params={ + "ipv6": ipv6, + "name": name, + "order_by": order_by, + "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[ScwRegion] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[list[str]] = None, + ipv6: Optional[bool] = None, + ) -> list[RoutingPolicy]: + """ + List routing policies. + List all routing policies in a given region. A routing policy can be attached to one or multiple connections (S2S VPN connections). + :param region: Region to target. If none is passed will use default region from the config. + :param page: Page number to return. + :param page_size: Maximum number of routing policies to return per page. + :param order_by: Order in which to return results. + :param project_id: Project ID to filter for. + :param name: Routing policy name to filter for. + :param tags: Tags to filter for. + :param ipv6: Filter for the routing policies based on IP prefixes version. + :return: :class:`list[RoutingPolicy] ` + + Usage: + :: + + result = api.list_routing_policies_all() + """ + + return fetch_all_pages( + type=ListRoutingPoliciesResponse, + key="routing_policies", + fetcher=self.list_routing_policies, + args={ + "region": region, + "page": page, + "page_size": page_size, + "order_by": order_by, + "project_id": project_id, + "name": name, + "tags": tags, + "ipv6": ipv6, + }, + ) + + def get_routing_policy( + self, + *, + routing_policy_id: str, + region: Optional[ScwRegion] = 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"/s2s-vpn/v1alpha1/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, + is_ipv6: bool, + region: Optional[ScwRegion] = 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 customer gateway, and the outgoing routes to announce to the customer gateway. + :param name: Name of the routing policy. + :param is_ipv6: IP prefixes version of the routing policy. + :param region: Region to target. If none is passed will use default region from the config. + :param project_id: ID of the Project to create the routing policy in. + :param tags: List of tags to apply to the routing policy. + :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", + is_ipv6=False, + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + + res = self._request( + "POST", + f"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies", + body=marshal_CreateRoutingPolicyRequest( + CreateRoutingPolicyRequest( + name=name, + is_ipv6=is_ipv6, + 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[ScwRegion] = 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"/s2s-vpn/v1alpha1/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[ScwRegion] = 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"/s2s-vpn/v1alpha1/regions/{param_region}/routing-policies/{param_routing_policy_id}", + ) + + self._throw_on_error(res) diff --git a/scaleway/scaleway/s2s_vpn/v1alpha1/content.py b/scaleway/scaleway/s2s_vpn/v1alpha1/content.py new file mode 100644 index 00000000..d65e22e6 --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/v1alpha1/content.py @@ -0,0 +1,15 @@ +# 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 ( + VpnGatewayStatus, +) + +VPN_GATEWAY_TRANSIENT_STATUSES: list[VpnGatewayStatus] = [ + VpnGatewayStatus.CONFIGURING, + VpnGatewayStatus.PROVISIONING, + VpnGatewayStatus.DEPROVISIONING, +] +""" +Lists transient statutes of the enum :class:`VpnGatewayStatus `. +""" diff --git a/scaleway/scaleway/s2s_vpn/v1alpha1/marshalling.py b/scaleway/scaleway/s2s_vpn/v1alpha1/marshalling.py new file mode 100644 index 00000000..bdb63081 --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/v1alpha1/marshalling.py @@ -0,0 +1,1098 @@ +# 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 +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from scaleway_core.utils import ( + OneOfPossibility, + resolve_one_of, +) +from .types import ( + BgpSessionStatus, + ConnectionInitiationPolicy, + ConnectionStatus, + TunnelStatus, + VpnGatewayStatus, + BgpSession, + ConnectionCipher, + Connection, + CustomerGateway, + RoutingPolicy, + VpnGatewayPrivateConfig, + VpnGatewayPublicConfig, + VpnGateway, + CreateConnectionResponse, + ListConnectionsResponse, + ListCustomerGatewaysResponse, + ListRoutingPoliciesResponse, + GatewayType, + ListVpnGatewayTypesResponse, + ListVpnGatewaysResponse, + RenewConnectionPskResponse, + CreateConnectionRequestBgpConfig, + CreateConnectionRequest, + CreateCustomerGatewayRequest, + CreateRoutingPolicyRequest, + CreateVpnGatewayRequestPublicConfig, + CreateVpnGatewayRequest, + DetachRoutingPolicyRequest, + SetRoutingPolicyRequest, + UpdateConnectionRequest, + UpdateCustomerGatewayRequest, + UpdateRoutingPolicyRequest, + UpdateVpnGatewayRequest, +) + + +def unmarshal_BgpSession(data: Any) -> BgpSession: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'BgpSession' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + 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("private_ip", None) + if field is not None: + args["private_ip"] = field + else: + args["private_ip"] = None + + return BgpSession(**args) + + +def unmarshal_ConnectionCipher(data: Any) -> ConnectionCipher: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ConnectionCipher' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("encryption", None) + if field is not None: + args["encryption"] = field + else: + args["encryption"] = None + + field = data.get("integrity", None) + if field is not None: + args["integrity"] = field + else: + args["integrity"] = None + + field = data.get("dh_group", None) + if field is not None: + args["dh_group"] = field + else: + args["dh_group"] = None + + return ConnectionCipher(**args) + + +def unmarshal_Connection(data: Any) -> Connection: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Connection' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = ConnectionStatus.UNKNOWN_STATUS + + field = data.get("is_ipv6", None) + if field is not None: + args["is_ipv6"] = field + else: + args["is_ipv6"] = False + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("initiation_policy", None) + if field is not None: + args["initiation_policy"] = field + else: + args["initiation_policy"] = ConnectionInitiationPolicy.UNKNOWN_INITIATION_POLICY + + field = data.get("ikev2_ciphers", None) + if field is not None: + args["ikev2_ciphers"] = ( + [unmarshal_ConnectionCipher(v) for v in field] + if field is not None + else None + ) + else: + args["ikev2_ciphers"] = [] + + field = data.get("esp_ciphers", None) + if field is not None: + args["esp_ciphers"] = ( + [unmarshal_ConnectionCipher(v) for v in field] + if field is not None + else None + ) + else: + args["esp_ciphers"] = [] + + field = data.get("route_propagation_enabled", None) + if field is not None: + args["route_propagation_enabled"] = field + else: + args["route_propagation_enabled"] = False + + field = data.get("vpn_gateway_id", None) + if field is not None: + args["vpn_gateway_id"] = field + else: + args["vpn_gateway_id"] = None + + field = data.get("customer_gateway_id", None) + if field is not None: + args["customer_gateway_id"] = field + else: + args["customer_gateway_id"] = None + + field = data.get("tunnel_status", None) + if field is not None: + args["tunnel_status"] = field + else: + args["tunnel_status"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("bgp_status_ipv4", None) + if field is not None: + args["bgp_status_ipv4"] = field + else: + args["bgp_status_ipv4"] = BgpSessionStatus.UNKNOWN_STATUS + + field = data.get("bgp_status_ipv6", None) + if field is not None: + args["bgp_status_ipv6"] = field + else: + args["bgp_status_ipv6"] = BgpSessionStatus.UNKNOWN_STATUS + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("tunnel_status_ipv4", None) + if field is not None: + args["tunnel_status_ipv4"] = field + else: + args["tunnel_status_ipv4"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("tunnel_status_ipv6", None) + if field is not None: + args["tunnel_status_ipv6"] = field + else: + args["tunnel_status_ipv6"] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + + field = data.get("bgp_session_ipv4", None) + if field is not None: + args["bgp_session_ipv4"] = unmarshal_BgpSession(field) + else: + args["bgp_session_ipv4"] = None + + field = data.get("bgp_session_ipv6", None) + if field is not None: + args["bgp_session_ipv6"] = unmarshal_BgpSession(field) + else: + args["bgp_session_ipv6"] = None + + return Connection(**args) + + +def unmarshal_CustomerGateway(data: Any) -> CustomerGateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CustomerGateway' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + else: + args["asn"] = 0 + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("public_ipv4", None) + if field is not None: + args["public_ipv4"] = field + else: + args["public_ipv4"] = None + + field = data.get("public_ipv6", None) + if field is not None: + args["public_ipv6"] = field + else: + args["public_ipv6"] = None + + return CustomerGateway(**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 + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("is_ipv6", None) + if field is not None: + args["is_ipv6"] = field + else: + args["is_ipv6"] = False + + field = data.get("prefix_filter_in", None) + if field is not None: + args["prefix_filter_in"] = field + else: + args["prefix_filter_in"] = [] + + field = data.get("prefix_filter_out", None) + if field is not None: + args["prefix_filter_out"] = field + else: + args["prefix_filter_out"] = [] + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = 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 RoutingPolicy(**args) + + +def unmarshal_VpnGatewayPrivateConfig(data: Any) -> VpnGatewayPrivateConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGatewayPrivateConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + return VpnGatewayPrivateConfig(**args) + + +def unmarshal_VpnGatewayPublicConfig(data: Any) -> VpnGatewayPublicConfig: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGatewayPublicConfig' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("ipam_ipv4_id", None) + if field is not None: + args["ipam_ipv4_id"] = field + else: + args["ipam_ipv4_id"] = None + + field = data.get("ipam_ipv6_id", None) + if field is not None: + args["ipam_ipv6_id"] = field + else: + args["ipam_ipv6_id"] = None + + return VpnGatewayPublicConfig(**args) + + +def unmarshal_VpnGateway(data: Any) -> VpnGateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'VpnGateway' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + else: + args["id"] = None + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + else: + args["project_id"] = None + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + else: + args["organization_id"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + else: + args["tags"] = [] + + field = data.get("status", None) + if field is not None: + args["status"] = field + else: + args["status"] = VpnGatewayStatus.UNKNOWN_STATUS + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("gateway_type", None) + if field is not None: + args["gateway_type"] = field + else: + args["gateway_type"] = None + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + else: + args["private_network_id"] = None + + field = data.get("ipam_private_ipv4_id", None) + if field is not None: + args["ipam_private_ipv4_id"] = field + else: + args["ipam_private_ipv4_id"] = None + + field = data.get("ipam_private_ipv6_id", None) + if field is not None: + args["ipam_private_ipv6_id"] = field + else: + args["ipam_private_ipv6_id"] = None + + field = data.get("asn", None) + if field is not None: + args["asn"] = field + else: + args["asn"] = 0 + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + else: + args["zone"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + field = data.get("public_config", None) + if field is not None: + args["public_config"] = unmarshal_VpnGatewayPublicConfig(field) + else: + args["public_config"] = None + + field = data.get("private_config", None) + if field is not None: + args["private_config"] = unmarshal_VpnGatewayPrivateConfig(field) + else: + args["private_config"] = None + + return VpnGateway(**args) + + +def unmarshal_CreateConnectionResponse(data: Any) -> CreateConnectionResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'CreateConnectionResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("pre_shared_key", None) + if field is not None: + args["pre_shared_key"] = field + else: + args["pre_shared_key"] = None + + field = data.get("connection", None) + if field is not None: + args["connection"] = unmarshal_Connection(field) + else: + args["connection"] = None + + return CreateConnectionResponse(**args) + + +def unmarshal_ListConnectionsResponse(data: Any) -> ListConnectionsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListConnectionsResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("connections", None) + if field is not None: + args["connections"] = ( + [unmarshal_Connection(v) for v in field] if field is not None else None + ) + else: + args["connections"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListConnectionsResponse(**args) + + +def unmarshal_ListCustomerGatewaysResponse(data: Any) -> ListCustomerGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListCustomerGatewaysResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_CustomerGateway(v) for v in field] if field is not None else None + ) + else: + args["gateways"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListCustomerGatewaysResponse(**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 + ) + else: + args["routing_policies"] = None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = None + + return ListRoutingPoliciesResponse(**args) + + +def unmarshal_GatewayType(data: Any) -> GatewayType: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GatewayType' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("name", None) + if field is not None: + args["name"] = field + else: + args["name"] = None + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + else: + args["bandwidth"] = None + + field = data.get("allowed_connections", None) + if field is not None: + args["allowed_connections"] = field + else: + args["allowed_connections"] = None + + field = data.get("region", None) + if field is not None: + args["region"] = field + else: + args["region"] = None + + return GatewayType(**args) + + +def unmarshal_ListVpnGatewayTypesResponse(data: Any) -> ListVpnGatewayTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVpnGatewayTypesResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateway_types", None) + if field is not None: + args["gateway_types"] = ( + [unmarshal_GatewayType(v) for v in field] if field is not None else None + ) + else: + args["gateway_types"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListVpnGatewayTypesResponse(**args) + + +def unmarshal_ListVpnGatewaysResponse(data: Any) -> ListVpnGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListVpnGatewaysResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_VpnGateway(v) for v in field] if field is not None else None + ) + else: + args["gateways"] = [] + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + else: + args["total_count"] = 0 + + return ListVpnGatewaysResponse(**args) + + +def unmarshal_RenewConnectionPskResponse(data: Any) -> RenewConnectionPskResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'RenewConnectionPskResponse' failed as data isn't a dictionary." + ) + + args: dict[str, Any] = {} + + field = data.get("pre_shared_key", None) + if field is not None: + args["pre_shared_key"] = field + else: + args["pre_shared_key"] = None + + field = data.get("connection", None) + if field is not None: + args["connection"] = unmarshal_Connection(field) + else: + args["connection"] = None + + return RenewConnectionPskResponse(**args) + + +def marshal_ConnectionCipher( + request: ConnectionCipher, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.encryption is not None: + output["encryption"] = request.encryption + + if request.integrity is not None: + output["integrity"] = request.integrity + + if request.dh_group is not None: + output["dh_group"] = request.dh_group + + return output + + +def marshal_CreateConnectionRequestBgpConfig( + request: CreateConnectionRequestBgpConfig, + 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_CreateConnectionRequest( + request: CreateConnectionRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.is_ipv6 is not None: + output["is_ipv6"] = request.is_ipv6 + + if request.initiation_policy is not None: + output["initiation_policy"] = request.initiation_policy + + if request.ikev2_ciphers is not None: + output["ikev2_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.ikev2_ciphers + ] + + if request.esp_ciphers is not None: + output["esp_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.esp_ciphers + ] + + if request.enable_route_propagation is not None: + output["enable_route_propagation"] = request.enable_route_propagation + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.vpn_gateway_id is not None: + output["vpn_gateway_id"] = request.vpn_gateway_id + + if request.customer_gateway_id is not None: + output["customer_gateway_id"] = request.customer_gateway_id + + if request.bgp_config_ipv4 is not None: + output["bgp_config_ipv4"] = marshal_CreateConnectionRequestBgpConfig( + request.bgp_config_ipv4, defaults + ) + + if request.bgp_config_ipv6 is not None: + output["bgp_config_ipv6"] = marshal_CreateConnectionRequestBgpConfig( + request.bgp_config_ipv6, defaults + ) + + return output + + +def marshal_CreateCustomerGatewayRequest( + request: CreateCustomerGatewayRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.name is not None: + output["name"] = request.name + + if request.asn is not None: + output["asn"] = request.asn + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.ipv4_public is not None: + output["ipv4_public"] = request.ipv4_public + + if request.ipv6_public is not None: + output["ipv6_public"] = request.ipv6_public + + 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.is_ipv6 is not None: + output["is_ipv6"] = request.is_ipv6 + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = 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_CreateVpnGatewayRequestPublicConfig( + request: CreateVpnGatewayRequestPublicConfig, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + + if request.ipam_ipv4_id is not None: + output["ipam_ipv4_id"] = request.ipam_ipv4_id + + if request.ipam_ipv6_id is not None: + output["ipam_ipv6_id"] = request.ipam_ipv6_id + + return output + + +def marshal_CreateVpnGatewayRequest( + request: CreateVpnGatewayRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="public_config", + value=request.public_config, + marshal_func=marshal_CreateVpnGatewayRequestPublicConfig, + ), + ] + ), + ) + + if request.name is not None: + output["name"] = request.name + + if request.gateway_type is not None: + output["gateway_type"] = request.gateway_type + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.project_id is not None: + output["project_id"] = request.project_id + else: + output["project_id"] = defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + if request.ipam_private_ipv4_id is not None: + output["ipam_private_ipv4_id"] = request.ipam_private_ipv4_id + + if request.ipam_private_ipv6_id is not None: + output["ipam_private_ipv6_id"] = request.ipam_private_ipv6_id + + if request.zone is not None: + output["zone"] = request.zone + + return output + + +def marshal_DetachRoutingPolicyRequest( + request: DetachRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="routing_policy_v4", + value=request.routing_policy_v4, + marshal_func=None, + ), + OneOfPossibility( + param="routing_policy_v6", + value=request.routing_policy_v6, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_SetRoutingPolicyRequest( + request: SetRoutingPolicyRequest, + defaults: ProfileDefaults, +) -> dict[str, Any]: + output: dict[str, Any] = {} + output.update( + resolve_one_of( + [ + OneOfPossibility( + param="routing_policy_v4", + value=request.routing_policy_v4, + marshal_func=None, + ), + OneOfPossibility( + param="routing_policy_v6", + value=request.routing_policy_v6, + marshal_func=None, + ), + ] + ), + ) + + return output + + +def marshal_UpdateConnectionRequest( + request: UpdateConnectionRequest, + 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.initiation_policy is not None: + output["initiation_policy"] = request.initiation_policy + + if request.ikev2_ciphers is not None: + output["ikev2_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.ikev2_ciphers + ] + + if request.esp_ciphers is not None: + output["esp_ciphers"] = [ + marshal_ConnectionCipher(item, defaults) for item in request.esp_ciphers + ] + + return output + + +def marshal_UpdateCustomerGatewayRequest( + request: UpdateCustomerGatewayRequest, + 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.ipv4_public is not None: + output["ipv4_public"] = request.ipv4_public + + if request.ipv6_public is not None: + output["ipv6_public"] = request.ipv6_public + + if request.asn is not None: + output["asn"] = request.asn + + 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 + + +def marshal_UpdateVpnGatewayRequest( + request: UpdateVpnGatewayRequest, + 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 diff --git a/scaleway/scaleway/s2s_vpn/v1alpha1/types.py b/scaleway/scaleway/s2s_vpn/v1alpha1/types.py new file mode 100644 index 00000000..61bdda79 --- /dev/null +++ b/scaleway/scaleway/s2s_vpn/v1alpha1/types.py @@ -0,0 +1,1337 @@ +# 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, field +from datetime import datetime +from enum import Enum +from typing import Optional + +from scaleway_core.bridge import ( + Region as ScwRegion, + Zone as ScwZone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class BgpSessionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + UP = "up" + DOWN = "down" + DISABLED = "disabled" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionDhGroup(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_DHGROUP = "unknown_dhgroup" + MODP2048 = "modp2048" + MODP3072 = "modp3072" + MODP4096 = "modp4096" + ECP256 = "ecp256" + ECP384 = "ecp384" + ECP521 = "ecp521" + CURVE25519 = "curve25519" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionEncryption(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_ENCRYPTION = "unknown_encryption" + AES128 = "aes128" + AES192 = "aes192" + AES256 = "aes256" + AES128GCM = "aes128gcm" + AES192GCM = "aes192gcm" + AES256GCM = "aes256gcm" + AES128CCM = "aes128ccm" + AES256CCM = "aes256ccm" + CHACHA20POLY1305 = "chacha20poly1305" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionInitiationPolicy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INITIATION_POLICY = "unknown_initiation_policy" + VPN_GATEWAY = "vpn_gateway" + CUSTOMER_GATEWAY = "customer_gateway" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionIntegrity(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INTEGRITY = "unknown_integrity" + SHA256 = "sha256" + SHA384 = "sha384" + SHA512 = "sha512" + + def __str__(self) -> str: + return str(self.value) + + +class ConnectionStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + ACTIVE = "active" + LIMITED_CONNECTIVITY = "limited_connectivity" + DOWN = "down" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class CreateConnectionRequestInitiationPolicy(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_INITIATION_POLICY = "unknown_initiation_policy" + VPN_GATEWAY = "vpn_gateway" + CUSTOMER_GATEWAY = "customer_gateway" + + def __str__(self) -> str: + return str(self.value) + + +class ListConnectionsRequestOrderBy(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 ListCustomerGatewaysRequestOrderBy(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) + + +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) + + +class ListVpnGatewaysRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + NAME_ASC = "name_asc" + NAME_DESC = "name_desc" + TYPE_ASC = "type_asc" + TYPE_DESC = "type_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class TunnelStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_TUNNEL_STATUS = "unknown_tunnel_status" + UP = "up" + DOWN = "down" + + def __str__(self) -> str: + return str(self.value) + + +class VpnGatewayStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CONFIGURING = "configuring" + FAILED = "failed" + PROVISIONING = "provisioning" + ACTIVE = "active" + DEPROVISIONING = "deprovisioning" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class BgpSession: + routing_policy_id: str + private_ip: str + + +@dataclass +class ConnectionCipher: + encryption: ConnectionEncryption + integrity: Optional[ConnectionIntegrity] = None + dh_group: Optional[ConnectionDhGroup] = None + + +@dataclass +class VpnGatewayPrivateConfig: + pass + + +@dataclass +class VpnGatewayPublicConfig: + ipam_ipv4_id: Optional[str] = None + ipam_ipv6_id: Optional[str] = None + + +@dataclass +class CreateConnectionRequestBgpConfig: + routing_policy_id: str + + +@dataclass +class Connection: + id: str + """ + Unique identifier of the connection. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the connection. + """ + + tags: list[str] + """ + List of tags applied to the connection. + """ + + status: ConnectionStatus + """ + Status of the connection. + """ + + is_ipv6: bool + """ + IP version of the IPSec Tunnel. + """ + + initiation_policy: ConnectionInitiationPolicy + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: list[ConnectionCipher] + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: list[ConnectionCipher] + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + route_propagation_enabled: bool + """ + Defines whether route propagation is enabled or not. + """ + + vpn_gateway_id: str + """ + ID of the VPN gateway attached to the connection. + """ + + customer_gateway_id: str + """ + ID of the customer gateway attached to the connection. + """ + + tunnel_status: TunnelStatus + """ + Status of the IPsec tunnel. + """ + + bgp_status_ipv4: BgpSessionStatus + """ + Status of the BGP IPv4 session. + """ + + bgp_status_ipv6: BgpSessionStatus + """ + Status of the BGP IPv6 session. + """ + + region: ScwRegion + """ + Region of the connection. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the connection. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the connection. + """ + + tunnel_status_ipv4: Optional[TunnelStatus] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + """ + Status of the IPv4 IPsec tunnel. + """ + + tunnel_status_ipv6: Optional[TunnelStatus] = TunnelStatus.UNKNOWN_TUNNEL_STATUS + """ + Status of the IPv6 IPsec tunnel. + """ + + bgp_session_ipv4: Optional[BgpSession] = None + """ + BGP IPv4 session, including status, interco private IPv4 subnet and attached routing policy. + """ + + bgp_session_ipv6: Optional[BgpSession] = None + """ + BGP IPv6 session, including status, interco private IPv6 subnet and attached routing policy. + """ + + +@dataclass +class CreateVpnGatewayRequestPublicConfig: + ipam_ipv4_id: Optional[str] = None + ipam_ipv6_id: Optional[str] = None + + +@dataclass +class CustomerGateway: + id: str + """ + Unique identifier of the customer gateway. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the customer gateway. + """ + + tags: list[str] + """ + List of tags applied to the customer gateway. + """ + + asn: int + """ + AS Number of the customer gateway. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the customer gateway. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the customer gateway. + """ + + public_ipv4: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + public_ipv6: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + +@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. + """ + + is_ipv6: bool + """ + IP prefixes version of 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: ScwRegion + """ + Region of the routing policy. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the routing policy. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the routing policy. + """ + + +@dataclass +class GatewayType: + name: str + bandwidth: int + allowed_connections: int + region: ScwRegion + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class VpnGateway: + id: str + """ + Unique identifier of the VPN gateway. + """ + + project_id: str + """ + Project ID. + """ + + organization_id: str + """ + Organization ID. + """ + + name: str + """ + Name of the VPN gateway. + """ + + tags: list[str] + """ + List of tags applied to the VPN gateway. + """ + + status: VpnGatewayStatus + """ + Status of the VPN gateway. + """ + + gateway_type: str + """ + Gateway type of the VPN gateway. + """ + + private_network_id: str + """ + ID of the Private Network attached to the VPN gateway. + """ + + ipam_private_ipv4_id: str + """ + ID of the IPAM private IPv4 address attached to the VPN gateway. + """ + + ipam_private_ipv6_id: str + """ + ID of the IPAM private IPv6 address attached to the VPN gateway. + """ + + asn: int + """ + Autonomous System Number (ASN) of the VPN gateway, used by Border Gateway Protocol (BGP) to exchange routing information with the customer gateway. + """ + + zone: ScwZone + """ + Zone where the VPN gateway resource is currently provisioned. + """ + + region: ScwRegion + """ + Region of the VPN gateway. + """ + + created_at: Optional[datetime] = None + """ + Creation date of the VPN gateway. + """ + + updated_at: Optional[datetime] = None + """ + Last modification date of the VPN gateway. + """ + + public_config: Optional[VpnGatewayPublicConfig] = None + + private_config: Optional[VpnGatewayPrivateConfig] = None + + +@dataclass +class CreateConnectionRequest: + name: str + """ + Name of the connection. + """ + + is_ipv6: bool + """ + Defines IP version of the IPSec Tunnel. + """ + + initiation_policy: CreateConnectionRequestInitiationPolicy + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: list[ConnectionCipher] + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: list[ConnectionCipher] + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + enable_route_propagation: bool + """ + Defines whether route propagation is enabled or not. + """ + + vpn_gateway_id: str + """ + ID of the VPN gateway to attach to the connection. + """ + + customer_gateway_id: str + """ + ID of the customer gateway to attach to the connection. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the connection in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the connection. + """ + + bgp_config_ipv4: Optional[CreateConnectionRequestBgpConfig] = None + """ + BGP config of IPv4 session, including interco private IPv4 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + """ + + bgp_config_ipv6: Optional[CreateConnectionRequestBgpConfig] = None + """ + BGP config of IPv6 session, including interco private IPv6 subnet (first IP assigned to the VPN Gateway, second IP to the Customer Gateway) and attached routing policy. + """ + + +@dataclass +class CreateConnectionResponse: + pre_shared_key: str + """ + New PSK generated for this connection. + """ + + connection: Optional[Connection] = None + """ + This connection. + """ + + +@dataclass +class CreateCustomerGatewayRequest: + name: str + """ + Name of the customer gateway. + """ + + asn: int + """ + AS Number of the customer gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the customer gateway in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the customer gateway. + """ + + ipv4_public: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + ipv6_public: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + +@dataclass +class CreateRoutingPolicyRequest: + name: str + """ + Name of the routing policy. + """ + + is_ipv6: bool + """ + IP prefixes version of the routing policy. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the routing policy in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[list[str]] = field(default_factory=list) + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[list[str]] = field(default_factory=list) + """ + IP prefix filters to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class CreateVpnGatewayRequest: + name: str + """ + Name of the VPN gateway. + """ + + gateway_type: str + """ + VPN gateway type (commercial offer type). + """ + + private_network_id: str + """ + ID of the Private Network to attach to the VPN gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + project_id: Optional[str] = None + """ + ID of the Project to create the VPN gateway in. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the VPN gateway. + """ + + ipam_private_ipv4_id: Optional[str] = None + """ + ID of the IPAM private IPv4 address to attach to the VPN gateway. + """ + + ipam_private_ipv6_id: Optional[str] = None + """ + ID of the IPAM private IPv6 address to attach to the VPN gateway. + """ + + zone: Optional[ScwZone] = None + """ + Availability Zone where the VPN gateway should be provisioned. If no zone is specified, the VPN gateway will be automatically placed. + """ + + public_config: Optional[CreateVpnGatewayRequestPublicConfig] = None + + +@dataclass +class DeleteConnectionRequest: + connection_id: str + """ + ID of the connection to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteCustomerGatewayRequest: + gateway_id: str + """ + ID of the customer gateway to delete. + """ + + region: Optional[ScwRegion] = None + """ + 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[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DeleteVpnGatewayRequest: + gateway_id: str + """ + ID of the VPN gateway to delete. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class DetachRoutingPolicyRequest: + connection_id: str + """ + ID of the connection from which routing policy is being detached. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + routing_policy_v4: Optional[str] = None + + routing_policy_v6: Optional[str] = None + + +@dataclass +class DisableRoutePropagationRequest: + connection_id: str + """ + ID of the connection on which to disable route propagation. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class EnableRoutePropagationRequest: + connection_id: str + """ + ID of the connection on which to enable route propagation. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetConnectionRequest: + connection_id: str + """ + ID of the requested connection. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetCustomerGatewayRequest: + gateway_id: str + """ + ID of the requested customer gateway. + """ + + region: Optional[ScwRegion] = None + """ + 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[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class GetVpnGatewayRequest: + gateway_id: str + """ + ID of the requested VPN gateway. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class ListConnectionsRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of connections to return per page. + """ + + order_by: Optional[ListConnectionsRequestOrderBy] = ( + ListConnectionsRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Connection name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + statuses: Optional[list[ConnectionStatus]] = field(default_factory=list) + """ + Connection statuses to filter for. + """ + + is_ipv6: Optional[bool] = False + """ + Filter connections with IP version of IPSec tunnel. + """ + + routing_policy_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections using these routing policies. + """ + + route_propagation_enabled: Optional[bool] = False + """ + Filter for connections with route propagation enabled. + """ + + vpn_gateway_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections attached to these VPN gateways. + """ + + customer_gateway_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for connections attached to these customer gateways. + """ + + +@dataclass +class ListConnectionsResponse: + connections: list[Connection] + """ + List of connections on the current page. + """ + + total_count: int + """ + Total number of connections. + """ + + +@dataclass +class ListCustomerGatewaysRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of customer gateways to return per page. + """ + + order_by: Optional[ListCustomerGatewaysRequestOrderBy] = ( + ListCustomerGatewaysRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Customer gateway name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + +@dataclass +class ListCustomerGatewaysResponse: + gateways: list[CustomerGateway] + """ + List of customer gateways on the current page. + """ + + total_count: int + """ + Total number of customer gateways. + """ + + +@dataclass +class ListRoutingPoliciesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of routing policies to return per page. + """ + + order_by: Optional[ListRoutingPoliciesRequestOrderBy] = ( + ListRoutingPoliciesRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + Routing policy name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + ipv6: Optional[bool] = False + """ + Filter for the routing policies based on IP prefixes version. + """ + + +@dataclass +class ListRoutingPoliciesResponse: + routing_policies: list[RoutingPolicy] + total_count: int + + +@dataclass +class ListVpnGatewayTypesRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of VPN gateway types to return per page. + """ + + +@dataclass +class ListVpnGatewayTypesResponse: + gateway_types: list[GatewayType] + """ + List of VPN gateway types on the current page. + """ + + total_count: int + """ + Total number of gateway types. + """ + + +@dataclass +class ListVpnGatewaysRequest: + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + page: Optional[int] = 0 + """ + Page number to return. + """ + + page_size: Optional[int] = 0 + """ + Maximum number of VPN gateways to return per page. + """ + + order_by: Optional[ListVpnGatewaysRequestOrderBy] = ( + ListVpnGatewaysRequestOrderBy.CREATED_AT_ASC + ) + """ + Order in which to return results. + """ + + project_id: Optional[str] = None + """ + Project ID to filter for. + """ + + name: Optional[str] = None + """ + VPN gateway name to filter for. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + Tags to filter for. + """ + + statuses: Optional[list[VpnGatewayStatus]] = field(default_factory=list) + """ + VPN gateway statuses to filter for. + """ + + gateway_types: Optional[list[str]] = field(default_factory=list) + """ + Filter for VPN gateways of these types. + """ + + private_network_ids: Optional[list[str]] = field(default_factory=list) + """ + Filter for VPN gateways attached to these private networks. + """ + + +@dataclass +class ListVpnGatewaysResponse: + gateways: list[VpnGateway] + """ + List of VPN gateways on the current page. + """ + + total_count: int + """ + Total number of VPN gateways. + """ + + +@dataclass +class RenewConnectionPskRequest: + connection_id: str + """ + ID of the connection to renew the PSK. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + +@dataclass +class RenewConnectionPskResponse: + pre_shared_key: str + """ + New PSK generated for this connection. + """ + + connection: Optional[Connection] = None + """ + This connection. + """ + + +@dataclass +class SetRoutingPolicyRequest: + connection_id: str + """ + ID of the connection whose routing policy is being updated. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + routing_policy_v4: Optional[str] = None + + routing_policy_v6: Optional[str] = None + + +@dataclass +class UpdateConnectionRequest: + connection_id: str + """ + ID of the connection to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the connection. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the connection. + """ + + initiation_policy: Optional[CreateConnectionRequestInitiationPolicy] = ( + CreateConnectionRequestInitiationPolicy.UNKNOWN_INITIATION_POLICY + ) + """ + Who initiates the IPsec tunnel. + """ + + ikev2_ciphers: Optional[list[ConnectionCipher]] = field(default_factory=list) + """ + List of IKE v2 ciphers proposed for the IPsec tunnel. + """ + + esp_ciphers: Optional[list[ConnectionCipher]] = field(default_factory=list) + """ + List of ESP ciphers proposed for the IPsec tunnel. + """ + + +@dataclass +class UpdateCustomerGatewayRequest: + gateway_id: str + """ + ID of the customer gateway to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the customer gateway. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the customer gateway. + """ + + ipv4_public: Optional[str] = None + """ + Public IPv4 address of the customer gateway. + """ + + ipv6_public: Optional[str] = None + """ + Public IPv6 address of the customer gateway. + """ + + asn: Optional[int] = 0 + """ + AS Number of the customer gateway. + """ + + +@dataclass +class UpdateRoutingPolicyRequest: + routing_policy_id: str + """ + ID of the routing policy to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the routing policy. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the routing policy. + """ + + prefix_filter_in: Optional[list[str]] = field(default_factory=list) + """ + IP prefixes to accept from the peer (ranges of route announcements to accept). + """ + + prefix_filter_out: Optional[list[str]] = field(default_factory=list) + """ + IP prefix filters for routes to advertise to the peer (ranges of routes to advertise). + """ + + +@dataclass +class UpdateVpnGatewayRequest: + gateway_id: str + """ + ID of the VPN gateway to update. + """ + + region: Optional[ScwRegion] = None + """ + Region to target. If none is passed will use default region from the config. + """ + + name: Optional[str] = None + """ + Name of the VPN gateway. + """ + + tags: Optional[list[str]] = field(default_factory=list) + """ + List of tags to apply to the VPN Gateway. + """