diff --git a/scaleway-async/scaleway_async/vpcgw/v2/__init__.py b/scaleway-async/scaleway_async/vpcgw/v2/__init__.py new file mode 100644 index 000000000..7c1cd4fe3 --- /dev/null +++ b/scaleway-async/scaleway_async/vpcgw/v2/__init__.py @@ -0,0 +1,97 @@ +# 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 GatewayNetworkStatus +from .content import GATEWAY_NETWORK_TRANSIENT_STATUSES +from .types import GatewayStatus +from .content import GATEWAY_TRANSIENT_STATUSES +from .types import ListGatewayNetworksRequestOrderBy +from .types import ListGatewaysRequestOrderBy +from .types import ListIPsRequestOrderBy +from .types import ListPatRulesRequestOrderBy +from .types import PatRuleProtocol +from .types import GatewayNetwork +from .types import IP +from .types import GatewayType +from .types import Gateway +from .types import PatRule +from .types import SetPatRulesRequestRule +from .types import CreateGatewayNetworkRequest +from .types import CreateGatewayRequest +from .types import CreateIPRequest +from .types import CreatePatRuleRequest +from .types import DeleteGatewayNetworkRequest +from .types import DeleteGatewayRequest +from .types import DeleteIPRequest +from .types import DeletePatRuleRequest +from .types import GetGatewayNetworkRequest +from .types import GetGatewayRequest +from .types import GetIPRequest +from .types import GetPatRuleRequest +from .types import ListGatewayNetworksRequest +from .types import ListGatewayNetworksResponse +from .types import ListGatewayTypesRequest +from .types import ListGatewayTypesResponse +from .types import ListGatewaysRequest +from .types import ListGatewaysResponse +from .types import ListIPsRequest +from .types import ListIPsResponse +from .types import ListPatRulesRequest +from .types import ListPatRulesResponse +from .types import RefreshSSHKeysRequest +from .types import SetPatRulesRequest +from .types import SetPatRulesResponse +from .types import UpdateGatewayNetworkRequest +from .types import UpdateGatewayRequest +from .types import UpdateIPRequest +from .types import UpdatePatRuleRequest +from .types import UpgradeGatewayRequest +from .api import VpcgwV2API + +__all__ = [ + "GatewayNetworkStatus", + "GATEWAY_NETWORK_TRANSIENT_STATUSES", + "GatewayStatus", + "GATEWAY_TRANSIENT_STATUSES", + "ListGatewayNetworksRequestOrderBy", + "ListGatewaysRequestOrderBy", + "ListIPsRequestOrderBy", + "ListPatRulesRequestOrderBy", + "PatRuleProtocol", + "GatewayNetwork", + "IP", + "GatewayType", + "Gateway", + "PatRule", + "SetPatRulesRequestRule", + "CreateGatewayNetworkRequest", + "CreateGatewayRequest", + "CreateIPRequest", + "CreatePatRuleRequest", + "DeleteGatewayNetworkRequest", + "DeleteGatewayRequest", + "DeleteIPRequest", + "DeletePatRuleRequest", + "GetGatewayNetworkRequest", + "GetGatewayRequest", + "GetIPRequest", + "GetPatRuleRequest", + "ListGatewayNetworksRequest", + "ListGatewayNetworksResponse", + "ListGatewayTypesRequest", + "ListGatewayTypesResponse", + "ListGatewaysRequest", + "ListGatewaysResponse", + "ListIPsRequest", + "ListIPsResponse", + "ListPatRulesRequest", + "ListPatRulesResponse", + "RefreshSSHKeysRequest", + "SetPatRulesRequest", + "SetPatRulesResponse", + "UpdateGatewayNetworkRequest", + "UpdateGatewayRequest", + "UpdateIPRequest", + "UpdatePatRuleRequest", + "UpgradeGatewayRequest", + "VpcgwV2API", +] diff --git a/scaleway-async/scaleway_async/vpcgw/v2/api.py b/scaleway-async/scaleway_async/vpcgw/v2/api.py new file mode 100644 index 000000000..a29e79e5f --- /dev/null +++ b/scaleway-async/scaleway_async/vpcgw/v2/api.py @@ -0,0 +1,1385 @@ +# 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, List, Optional, Union + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + WaitForOptions, + random_name, + validate_path_param, + fetch_all_pages_async, + wait_for_resource_async, +) +from .types import ( + GatewayNetworkStatus, + GatewayStatus, + ListGatewayNetworksRequestOrderBy, + ListGatewaysRequestOrderBy, + ListIPsRequestOrderBy, + ListPatRulesRequestOrderBy, + PatRuleProtocol, + CreateGatewayNetworkRequest, + CreateGatewayRequest, + CreateIPRequest, + CreatePatRuleRequest, + Gateway, + GatewayNetwork, + IP, + ListGatewayNetworksResponse, + ListGatewayTypesResponse, + ListGatewaysResponse, + ListIPsResponse, + ListPatRulesResponse, + PatRule, + SetPatRulesRequest, + SetPatRulesRequestRule, + SetPatRulesResponse, + UpdateGatewayNetworkRequest, + UpdateGatewayRequest, + UpdateIPRequest, + UpdatePatRuleRequest, + UpgradeGatewayRequest, +) +from .content import ( + GATEWAY_NETWORK_TRANSIENT_STATUSES, + GATEWAY_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_GatewayNetwork, + unmarshal_IP, + unmarshal_Gateway, + unmarshal_PatRule, + unmarshal_ListGatewayNetworksResponse, + unmarshal_ListGatewayTypesResponse, + unmarshal_ListGatewaysResponse, + unmarshal_ListIPsResponse, + unmarshal_ListPatRulesResponse, + unmarshal_SetPatRulesResponse, + marshal_CreateGatewayNetworkRequest, + marshal_CreateGatewayRequest, + marshal_CreateIPRequest, + marshal_CreatePatRuleRequest, + marshal_SetPatRulesRequest, + marshal_UpdateGatewayNetworkRequest, + marshal_UpdateGatewayRequest, + marshal_UpdateIPRequest, + marshal_UpdatePatRuleRequest, + marshal_UpgradeGatewayRequest, +) + + +class VpcgwV2API(API): + """ + This API allows you to manage your Public Gateways. + """ + + async def list_gateways( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewaysRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + types: Optional[List[str]] = None, + status: Optional[List[GatewayStatus]] = None, + private_network_ids: Optional[List[str]] = None, + include_legacy: Optional[bool] = None, + ) -> ListGatewaysResponse: + """ + List Public Gateways. + List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Gateways per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Include only gateways in this Project. + :param name: Filter for gateways which have this search term in their name. + :param tags: Filter for gateways with these tags. + :param types: Filter for gateways of these types. + :param status: Filter for gateways with these status. Use `unknown` to include all statuses. + :param private_network_ids: Filter for gateways attached to these Private Networks. + :param include_legacy: Include also legacy gateways. + :return: :class:`ListGatewaysResponse ` + + Usage: + :: + + result = await api.list_gateways() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateways", + params={ + "include_legacy": include_legacy, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "project_id": project_id or self.client.default_project_id, + "status": status, + "tags": tags, + "types": types, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGatewaysResponse(res.json()) + + async def list_gateways_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewaysRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + types: Optional[List[str]] = None, + status: Optional[List[GatewayStatus]] = None, + private_network_ids: Optional[List[str]] = None, + include_legacy: Optional[bool] = None, + ) -> List[Gateway]: + """ + List Public Gateways. + List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Gateways per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Include only gateways in this Project. + :param name: Filter for gateways which have this search term in their name. + :param tags: Filter for gateways with these tags. + :param types: Filter for gateways of these types. + :param status: Filter for gateways with these status. Use `unknown` to include all statuses. + :param private_network_ids: Filter for gateways attached to these Private Networks. + :param include_legacy: Include also legacy gateways. + :return: :class:`List[Gateway] ` + + Usage: + :: + + result = await api.list_gateways_all() + """ + + return await fetch_all_pages_async( + type=ListGatewaysResponse, + key="gateways", + fetcher=self.list_gateways, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "name": name, + "tags": tags, + "types": types, + "status": status, + "private_network_ids": private_network_ids, + "include_legacy": include_legacy, + }, + ) + + async def get_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Get a Public Gateway. + Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more. + :param gateway_id: ID of the gateway to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.get_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + async def wait_for_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[Gateway, Union[bool, Awaitable[bool]]]] = None, + ) -> Gateway: + """ + Get a Public Gateway. + Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more. + :param gateway_id: ID of the gateway to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.get_gateway( + gateway_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in GATEWAY_TRANSIENT_STATUSES + + return await wait_for_resource_async( + fetcher=self.get_gateway, + options=options, + args={ + "gateway_id": gateway_id, + "zone": zone, + }, + ) + + async def create_gateway( + self, + *, + type_: str, + enable_smtp: bool, + enable_bastion: bool, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ip_id: Optional[str] = None, + bastion_port: Optional[int] = None, + ) -> Gateway: + """ + Create a Public Gateway. + Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion. + :param type_: Gateway type (commercial offer type). + :param enable_smtp: Defines whether SMTP traffic should be allowed pass through the gateway. + :param enable_bastion: Defines whether SSH bastion should be enabled the gateway. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Scaleway Project to create the gateway in. + :param name: Name for the gateway. + :param tags: Tags for the gateway. + :param ip_id: Existing IP address to attach to the gateway. + :param bastion_port: Port of the SSH bastion. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.create_gateway( + type="example", + enable_smtp=False, + enable_bastion=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways", + body=marshal_CreateGatewayRequest( + CreateGatewayRequest( + type_=type_, + enable_smtp=enable_smtp, + enable_bastion=enable_bastion, + zone=zone, + project_id=project_id, + name=name or random_name(prefix="gw"), + tags=tags, + ip_id=ip_id, + bastion_port=bastion_port, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + async def update_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + enable_bastion: Optional[bool] = None, + bastion_port: Optional[int] = None, + enable_smtp: Optional[bool] = None, + ) -> Gateway: + """ + Update a Public Gateway. + Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**. + :param gateway_id: ID of the gateway to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name for the gateway. + :param tags: Tags for the gateway. + :param enable_bastion: Defines whether SSH bastion should be enabled the gateway. + :param bastion_port: Port of the SSH bastion. + :param enable_smtp: Defines whether SMTP traffic should be allowed to pass through the gateway. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.update_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + body=marshal_UpdateGatewayRequest( + UpdateGatewayRequest( + gateway_id=gateway_id, + zone=zone, + name=name, + tags=tags, + enable_bastion=enable_bastion, + bastion_port=bastion_port, + enable_smtp=enable_smtp, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + async def delete_gateway( + self, + *, + gateway_id: str, + delete_ip: bool, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Delete a Public Gateway. + Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible. + :param gateway_id: ID of the gateway to delete. + :param delete_ip: Defines whether the PGW's IP should be deleted. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.delete_gateway( + gateway_id="example", + delete_ip=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + params={ + "delete_ip": delete_ip, + }, + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + async def upgrade_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + type_: Optional[str] = None, + ) -> Gateway: + """ + Upgrade a Public Gateway to the latest version and/or to a different commercial offer type. + Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update. + :param gateway_id: ID of the gateway to upgrade. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param type_: Gateway type (commercial offer). + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.upgrade_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/upgrade", + body=marshal_UpgradeGatewayRequest( + UpgradeGatewayRequest( + gateway_id=gateway_id, + zone=zone, + type_=type_, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + async def list_gateway_networks( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewayNetworksRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + status: Optional[List[GatewayNetworkStatus]] = None, + gateway_ids: Optional[List[str]] = None, + private_network_ids: Optional[List[str]] = None, + masquerade_enabled: Optional[bool] = None, + ) -> ListGatewayNetworksResponse: + """ + List Public Gateway connections to Private Networks. + List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: GatewayNetworks per page. + :param status: Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + :param gateway_ids: Filter for GatewayNetworks connected to these gateways. + :param private_network_ids: Filter for GatewayNetworks connected to these Private Networks. + :param masquerade_enabled: Filter for GatewayNetworks with this `enable_masquerade` setting. + :return: :class:`ListGatewayNetworksResponse ` + + Usage: + :: + + result = await api.list_gateway_networks() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks", + params={ + "gateway_ids": gateway_ids, + "masquerade_enabled": masquerade_enabled, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "status": status, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGatewayNetworksResponse(res.json()) + + async def list_gateway_networks_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewayNetworksRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + status: Optional[List[GatewayNetworkStatus]] = None, + gateway_ids: Optional[List[str]] = None, + private_network_ids: Optional[List[str]] = None, + masquerade_enabled: Optional[bool] = None, + ) -> List[GatewayNetwork]: + """ + List Public Gateway connections to Private Networks. + List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: GatewayNetworks per page. + :param status: Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + :param gateway_ids: Filter for GatewayNetworks connected to these gateways. + :param private_network_ids: Filter for GatewayNetworks connected to these Private Networks. + :param masquerade_enabled: Filter for GatewayNetworks with this `enable_masquerade` setting. + :return: :class:`List[GatewayNetwork] ` + + Usage: + :: + + result = await api.list_gateway_networks_all() + """ + + return await fetch_all_pages_async( + type=ListGatewayNetworksResponse, + key="gateway_networks", + fetcher=self.list_gateway_networks, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "status": status, + "gateway_ids": gateway_ids, + "private_network_ids": private_network_ids, + "masquerade_enabled": masquerade_enabled, + }, + ) + + async def get_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + ) -> GatewayNetwork: + """ + Get a Public Gateway connection to a Private Network. + Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings. + :param gateway_network_id: ID of the GatewayNetwork to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = await api.get_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + async def wait_for_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + options: Optional[ + WaitForOptions[GatewayNetwork, Union[bool, Awaitable[bool]]] + ] = None, + ) -> GatewayNetwork: + """ + Get a Public Gateway connection to a Private Network. + Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings. + :param gateway_network_id: ID of the GatewayNetwork to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = await api.get_gateway_network( + gateway_network_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in GATEWAY_NETWORK_TRANSIENT_STATUSES + ) + + return await wait_for_resource_async( + fetcher=self.get_gateway_network, + options=options, + args={ + "gateway_network_id": gateway_network_id, + "zone": zone, + }, + ) + + async def create_gateway_network( + self, + *, + gateway_id: str, + private_network_id: str, + enable_masquerade: bool, + push_default_route: bool, + zone: Optional[Zone] = None, + ipam_ip_id: Optional[str] = None, + ) -> GatewayNetwork: + """ + Attach a Public Gateway to a Private Network. + Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including whether to enable masquerade (dynamic NAT), and more. + :param gateway_id: Public Gateway to connect. + :param private_network_id: Private Network to connect. + :param enable_masquerade: Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + :param push_default_route: Enabling the default route also enables masquerading. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param ipam_ip_id: Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = await api.create_gateway_network( + gateway_id="example", + private_network_id="example", + enable_masquerade=False, + push_default_route=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks", + body=marshal_CreateGatewayNetworkRequest( + CreateGatewayNetworkRequest( + gateway_id=gateway_id, + private_network_id=private_network_id, + enable_masquerade=enable_masquerade, + push_default_route=push_default_route, + zone=zone, + ipam_ip_id=ipam_ip_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + async def update_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + enable_masquerade: Optional[bool] = None, + push_default_route: Optional[bool] = None, + ipam_ip_id: Optional[str] = None, + ) -> GatewayNetwork: + """ + Update a Public Gateway's connection to a Private Network. + Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include whether to enable traffic masquerade (dynamic NAT). + :param gateway_network_id: ID of the GatewayNetwork to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param enable_masquerade: Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + :param push_default_route: Enabling the default route also enables masquerading. + :param ipam_ip_id: Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = await api.update_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + body=marshal_UpdateGatewayNetworkRequest( + UpdateGatewayNetworkRequest( + gateway_network_id=gateway_network_id, + zone=zone, + enable_masquerade=enable_masquerade, + push_default_route=push_default_route, + ipam_ip_id=ipam_ip_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + async def delete_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + ) -> GatewayNetwork: + """ + Detach a Public Gateway from a Private Network. + Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id. + :param gateway_network_id: ID of the GatewayNetwork to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = await api.delete_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + async def list_pat_rules( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListPatRulesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + gateway_ids: Optional[List[str]] = None, + private_ips: Optional[List[str]] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> ListPatRulesResponse: + """ + List PAT rules. + List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: PAT rules per page. + :param gateway_ids: Filter for PAT rules on these gateways. + :param private_ips: Filter for PAT rules targeting these private ips. + :param protocol: Filter for PAT rules with this protocol. + :return: :class:`ListPatRulesResponse ` + + Usage: + :: + + result = await api.list_pat_rules() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + params={ + "gateway_ids": gateway_ids, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_ips": private_ips, + "protocol": protocol, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPatRulesResponse(res.json()) + + async def list_pat_rules_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListPatRulesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + gateway_ids: Optional[List[str]] = None, + private_ips: Optional[List[str]] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> List[PatRule]: + """ + List PAT rules. + List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: PAT rules per page. + :param gateway_ids: Filter for PAT rules on these gateways. + :param private_ips: Filter for PAT rules targeting these private ips. + :param protocol: Filter for PAT rules with this protocol. + :return: :class:`List[PatRule] ` + + Usage: + :: + + result = await api.list_pat_rules_all() + """ + + return await fetch_all_pages_async( + type=ListPatRulesResponse, + key="pat_rules", + fetcher=self.list_pat_rules, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "gateway_ids": gateway_ids, + "private_ips": private_ips, + "protocol": protocol, + }, + ) + + async def get_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + ) -> PatRule: + """ + Get a PAT rule. + Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol. + :param pat_rule_id: ID of the PAT rule to get. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`PatRule ` + + Usage: + :: + + result = await api.get_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + async def create_pat_rule( + self, + *, + gateway_id: str, + public_port: int, + private_ip: str, + private_port: int, + zone: Optional[Zone] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> PatRule: + """ + Create a PAT rule. + Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to. + :param gateway_id: ID of the Gateway on which to create the rule. + :param public_port: Public port to listen on. + :param private_ip: Private IP to forward data to. + :param private_port: Private port to translate to. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param protocol: Protocol the rule should apply to. + :return: :class:`PatRule ` + + Usage: + :: + + result = await api.create_pat_rule( + gateway_id="example", + public_port=1, + private_ip="example", + private_port=1, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + body=marshal_CreatePatRuleRequest( + CreatePatRuleRequest( + gateway_id=gateway_id, + public_port=public_port, + private_ip=private_ip, + private_port=private_port, + zone=zone, + protocol=protocol, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + async def update_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + public_port: Optional[int] = None, + private_ip: Optional[str] = None, + private_port: Optional[int] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> PatRule: + """ + Update a PAT rule. + Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated. + :param pat_rule_id: ID of the PAT rule to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param public_port: Public port to listen on. + :param private_ip: Private IP to forward data to. + :param private_port: Private port to translate to. + :param protocol: Protocol the rule should apply to. + :return: :class:`PatRule ` + + Usage: + :: + + result = await api.update_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + body=marshal_UpdatePatRuleRequest( + UpdatePatRuleRequest( + pat_rule_id=pat_rule_id, + zone=zone, + public_port=public_port, + private_ip=private_ip, + private_port=private_port, + protocol=protocol, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + async def set_pat_rules( + self, + *, + gateway_id: str, + pat_rules: List[SetPatRulesRequestRule], + zone: Optional[Zone] = None, + ) -> SetPatRulesResponse: + """ + Set all PAT rules. + Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly. + :param gateway_id: ID of the gateway on which to set the PAT rules. + :param pat_rules: New list of PAT rules. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`SetPatRulesResponse ` + + Usage: + :: + + result = await api.set_pat_rules( + gateway_id="example", + pat_rules=[], + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "PUT", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + body=marshal_SetPatRulesRequest( + SetPatRulesRequest( + gateway_id=gateway_id, + pat_rules=pat_rules, + zone=zone, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetPatRulesResponse(res.json()) + + async def delete_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete a PAT rule. + Delete a PAT rule, identified by its PAT rule ID. This action is irreversible. + :param pat_rule_id: ID of the PAT rule to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = await api.delete_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + ) + + self._throw_on_error(res) + + async def list_gateway_types( + self, + *, + zone: Optional[Zone] = None, + ) -> ListGatewayTypesResponse: + """ + List Public Gateway types. + List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`ListGatewayTypesResponse ` + + Usage: + :: + + result = await api.list_gateway_types() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-types", + ) + + self._throw_on_error(res) + return unmarshal_ListGatewayTypesResponse(res.json()) + + async def list_i_ps( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListIPsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + is_free: Optional[bool] = None, + ) -> ListIPsResponse: + """ + List IPs. + List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: IP addresses per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Filter for IP addresses in this Project. + :param tags: Filter for IP addresses with these tags. + :param reverse: Filter for IP addresses that have a reverse containing this string. + :param is_free: Filter based on whether the IP is attached to a gateway or not. + :return: :class:`ListIPsResponse ` + + Usage: + :: + + result = await api.list_i_ps() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/ips", + params={ + "is_free": is_free, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "reverse": reverse, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListIPsResponse(res.json()) + + async def list_i_ps_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListIPsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + is_free: Optional[bool] = None, + ) -> List[IP]: + """ + List IPs. + List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: IP addresses per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Filter for IP addresses in this Project. + :param tags: Filter for IP addresses with these tags. + :param reverse: Filter for IP addresses that have a reverse containing this string. + :param is_free: Filter based on whether the IP is attached to a gateway or not. + :return: :class:`List[IP] ` + + Usage: + :: + + result = await api.list_i_ps_all() + """ + + return await fetch_all_pages_async( + type=ListIPsResponse, + key="ips", + fetcher=self.list_i_ps, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "tags": tags, + "reverse": reverse, + "is_free": is_free, + }, + ) + + async def get_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + ) -> IP: + """ + Get an IP. + Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata. + :param ip_id: ID of the IP address to get. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`IP ` + + Usage: + :: + + result = await api.get_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + async def create_ip( + self, + *, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> IP: + """ + Reserve an IP. + Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Project to create the IP address in. + :param tags: Tags to give to the IP address. + :return: :class:`IP ` + + Usage: + :: + + result = await api.create_ip() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/ips", + body=marshal_CreateIPRequest( + CreateIPRequest( + zone=zone, + project_id=project_id, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + async def update_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + gateway_id: Optional[str] = None, + ) -> IP: + """ + Update an IP. + Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to. + :param ip_id: ID of the IP address to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param tags: Tags to give to the IP address. + :param reverse: Reverse to set on the address. Empty string to unset. + :param gateway_id: Gateway to attach the IP address to. Empty string to detach. + :return: :class:`IP ` + + Usage: + :: + + result = await api.update_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + body=marshal_UpdateIPRequest( + UpdateIPRequest( + ip_id=ip_id, + zone=zone, + tags=tags, + reverse=reverse, + gateway_id=gateway_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + async def delete_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete an IP. + Delete a flexible IP address from your account. This action is irreversible. + :param ip_id: ID of the IP address to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = await api.delete_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + ) + + self._throw_on_error(res) + + async def refresh_ssh_keys( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Refresh a Public Gateway's SSH keys. + Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself. + :param gateway_id: ID of the gateway to refresh SSH keys on. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = await api.refresh_ssh_keys( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/refresh-ssh-keys", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) diff --git a/scaleway-async/scaleway_async/vpcgw/v2/content.py b/scaleway-async/scaleway_async/vpcgw/v2/content.py new file mode 100644 index 000000000..a5b8a7acf --- /dev/null +++ b/scaleway-async/scaleway_async/vpcgw/v2/content.py @@ -0,0 +1,26 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + GatewayNetworkStatus, + GatewayStatus, +) + +GATEWAY_NETWORK_TRANSIENT_STATUSES: List[GatewayNetworkStatus] = [ + GatewayNetworkStatus.ATTACHING, + GatewayNetworkStatus.CONFIGURING, + GatewayNetworkStatus.DETACHING, +] +""" +Lists transient statutes of the enum :class:`GatewayNetworkStatus `. +""" +GATEWAY_TRANSIENT_STATUSES: List[GatewayStatus] = [ + GatewayStatus.ALLOCATING, + GatewayStatus.CONFIGURING, + GatewayStatus.STOPPING, + GatewayStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`GatewayStatus `. +""" diff --git a/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py b/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py new file mode 100644 index 000000000..ff9cb1e66 --- /dev/null +++ b/scaleway-async/scaleway_async/vpcgw/v2/marshalling.py @@ -0,0 +1,667 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from .types import ( + GatewayNetwork, + IP, + Gateway, + PatRule, + ListGatewayNetworksResponse, + GatewayType, + ListGatewayTypesResponse, + ListGatewaysResponse, + ListIPsResponse, + ListPatRulesResponse, + SetPatRulesResponse, + CreateGatewayNetworkRequest, + CreateGatewayRequest, + CreateIPRequest, + CreatePatRuleRequest, + SetPatRulesRequestRule, + SetPatRulesRequest, + UpdateGatewayNetworkRequest, + UpdateGatewayRequest, + UpdateIPRequest, + UpdatePatRuleRequest, + UpgradeGatewayRequest, +) + + +def unmarshal_GatewayNetwork(data: Any) -> GatewayNetwork: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GatewayNetwork' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + field = data.get("masquerade_enabled", None) + if field is not None: + args["masquerade_enabled"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("push_default_route", None) + if field is not None: + args["push_default_route"] = field + + field = data.get("ipam_ip_id", None) + if field is not None: + args["ipam_ip_id"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("mac_address", None) + if field is not None: + args["mac_address"] = field + else: + args["mac_address"] = None + + return GatewayNetwork(**args) + + +def unmarshal_IP(data: Any) -> IP: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'IP' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("address", None) + if field is not None: + args["address"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("reverse", None) + if field is not None: + args["reverse"] = field + else: + args["reverse"] = None + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + else: + args["gateway_id"] = None + + return IP(**args) + + +def unmarshal_Gateway(data: Any) -> Gateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Gateway' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("gateway_networks", None) + if field is not None: + args["gateway_networks"] = ( + [unmarshal_GatewayNetwork(v) for v in field] if field is not None else None + ) + + field = data.get("bastion_enabled", None) + if field is not None: + args["bastion_enabled"] = field + + field = data.get("bastion_port", None) + if field is not None: + args["bastion_port"] = field + + field = data.get("smtp_enabled", None) + if field is not None: + args["smtp_enabled"] = field + + field = data.get("is_legacy", None) + if field is not None: + args["is_legacy"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = unmarshal_IP(field) + else: + args["ipv4"] = None + + field = data.get("version", None) + if field is not None: + args["version"] = field + else: + args["version"] = None + + field = data.get("can_upgrade_to", None) + if field is not None: + args["can_upgrade_to"] = field + else: + args["can_upgrade_to"] = None + + return Gateway(**args) + + +def unmarshal_PatRule(data: Any) -> PatRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PatRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + + field = data.get("public_port", None) + if field is not None: + args["public_port"] = field + + field = data.get("private_ip", None) + if field is not None: + args["private_ip"] = field + + field = data.get("private_port", None) + if field is not None: + args["private_port"] = field + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return PatRule(**args) + + +def unmarshal_ListGatewayNetworksResponse(data: Any) -> ListGatewayNetworksResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewayNetworksResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("gateway_networks", None) + if field is not None: + args["gateway_networks"] = ( + [unmarshal_GatewayNetwork(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListGatewayNetworksResponse(**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 + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + return GatewayType(**args) + + +def unmarshal_ListGatewayTypesResponse(data: Any) -> ListGatewayTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewayTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("types", None) + if field is not None: + args["types"] = ( + [unmarshal_GatewayType(v) for v in field] if field is not None else None + ) + + return ListGatewayTypesResponse(**args) + + +def unmarshal_ListGatewaysResponse(data: Any) -> ListGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewaysResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_Gateway(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListGatewaysResponse(**args) + + +def unmarshal_ListIPsResponse(data: Any) -> ListIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ips", None) + if field is not None: + args["ips"] = [unmarshal_IP(v) for v in field] if field is not None else None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListIPsResponse(**args) + + +def unmarshal_ListPatRulesResponse(data: Any) -> ListPatRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPatRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pat_rules", None) + if field is not None: + args["pat_rules"] = ( + [unmarshal_PatRule(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPatRulesResponse(**args) + + +def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetPatRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pat_rules", None) + if field is not None: + args["pat_rules"] = ( + [unmarshal_PatRule(v) for v in field] if field is not None else None + ) + + return SetPatRulesResponse(**args) + + +def marshal_CreateGatewayNetworkRequest( + request: CreateGatewayNetworkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.enable_masquerade is not None: + output["enable_masquerade"] = request.enable_masquerade + + if request.push_default_route is not None: + output["push_default_route"] = request.push_default_route + + if request.ipam_ip_id is not None: + output["ipam_ip_id"] = request.ipam_ip_id + + return output + + +def marshal_CreateGatewayRequest( + request: CreateGatewayRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = request.type_ + + if request.enable_smtp is not None: + output["enable_smtp"] = request.enable_smtp + + if request.enable_bastion is not None: + output["enable_bastion"] = request.enable_bastion + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.ip_id is not None: + output["ip_id"] = request.ip_id + + if request.bastion_port is not None: + output["bastion_port"] = request.bastion_port + + return output + + +def marshal_CreateIPRequest( + request: CreateIPRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreatePatRuleRequest( + request: CreatePatRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_SetPatRulesRequestRule( + request: SetPatRulesRequestRule, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_SetPatRulesRequest( + request: SetPatRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.pat_rules is not None: + output["pat_rules"] = [ + marshal_SetPatRulesRequestRule(item, defaults) for item in request.pat_rules + ] + + return output + + +def marshal_UpdateGatewayNetworkRequest( + request: UpdateGatewayNetworkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.enable_masquerade is not None: + output["enable_masquerade"] = request.enable_masquerade + + if request.push_default_route is not None: + output["push_default_route"] = request.push_default_route + + if request.ipam_ip_id is not None: + output["ipam_ip_id"] = request.ipam_ip_id + + return output + + +def marshal_UpdateGatewayRequest( + request: UpdateGatewayRequest, + 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.enable_bastion is not None: + output["enable_bastion"] = request.enable_bastion + + if request.bastion_port is not None: + output["bastion_port"] = request.bastion_port + + if request.enable_smtp is not None: + output["enable_smtp"] = request.enable_smtp + + return output + + +def marshal_UpdateIPRequest( + request: UpdateIPRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.tags is not None: + output["tags"] = request.tags + + if request.reverse is not None: + output["reverse"] = request.reverse + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + return output + + +def marshal_UpdatePatRuleRequest( + request: UpdatePatRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_UpgradeGatewayRequest( + request: UpgradeGatewayRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = request.type_ + + return output diff --git a/scaleway-async/scaleway_async/vpcgw/v2/types.py b/scaleway-async/scaleway_async/vpcgw/v2/types.py new file mode 100644 index 000000000..9bcf99b86 --- /dev/null +++ b/scaleway-async/scaleway_async/vpcgw/v2/types.py @@ -0,0 +1,1081 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class GatewayNetworkStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATED = "created" + ATTACHING = "attaching" + CONFIGURING = "configuring" + READY = "ready" + DETACHING = "detaching" + + def __str__(self) -> str: + return str(self.value) + + +class GatewayStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + STOPPED = "stopped" + ALLOCATING = "allocating" + CONFIGURING = "configuring" + RUNNING = "running" + STOPPING = "stopping" + FAILED = "failed" + DELETING = "deleting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class ListGatewayNetworksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListGatewaysRequestOrderBy(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 ListIPsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + ADDRESS_ASC = "address_asc" + ADDRESS_DESC = "address_desc" + REVERSE_ASC = "reverse_asc" + REVERSE_DESC = "reverse_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPatRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + PUBLIC_PORT_ASC = "public_port_asc" + PUBLIC_PORT_DESC = "public_port_desc" + + def __str__(self) -> str: + return str(self.value) + + +class PatRuleProtocol(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PROTOCOL = "unknown_protocol" + BOTH = "both" + TCP = "tcp" + UDP = "udp" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class GatewayNetwork: + id: str + """ + ID of the Public Gateway-Private Network connection. + """ + + gateway_id: str + """ + ID of the connected Public Gateway. + """ + + private_network_id: str + """ + ID of the connected Private Network. + """ + + masquerade_enabled: bool + """ + Defines whether the gateway masquerades traffic for this Private Network (Dynamic NAT). + """ + + status: GatewayNetworkStatus + """ + Current status of the Public Gateway's connection to the Private Network. + """ + + push_default_route: bool + """ + Enabling the default route also enables masquerading. + """ + + ipam_ip_id: str + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + zone: Zone + """ + Zone of the GatewayNetwork connection. + """ + + created_at: Optional[datetime] + """ + Connection creation date. + """ + + updated_at: Optional[datetime] + """ + Connection last modification date. + """ + + mac_address: Optional[str] + """ + MAC address of the gateway in the Private Network (if the gateway is up and running). + """ + + +@dataclass +class IP: + id: str + """ + IP address ID. + """ + + organization_id: str + """ + Owning Organization. + """ + + project_id: str + """ + Owning Project. + """ + + tags: List[str] + """ + Tags associated with the IP address. + """ + + address: str + """ + The IP address itself. + """ + + zone: Zone + """ + Zone of the IP address. + """ + + created_at: Optional[datetime] + """ + IP address creation date. + """ + + updated_at: Optional[datetime] + """ + IP address last modification date. + """ + + reverse: Optional[str] + """ + Reverse domain name for the IP address. + """ + + gateway_id: Optional[str] + """ + Public Gateway associated with the IP address. + """ + + +@dataclass +class GatewayType: + name: str + """ + Public Gateway type name. + """ + + bandwidth: int + """ + Bandwidth, in bps, of the Public Gateway. This is the public bandwidth to the outer Internet, and the internal bandwidth to each connected Private Networks. + """ + + zone: Zone + """ + Zone the Public Gateway type is available in. + """ + + +@dataclass +class Gateway: + id: str + """ + ID of the gateway. + """ + + organization_id: str + """ + Owning Organization. + """ + + project_id: str + """ + Owning Project. + """ + + type_: str + """ + Gateway type name (commercial offer). + """ + + bandwidth: int + """ + Bandwidth available of the gateway. + """ + + status: GatewayStatus + """ + Current status of the gateway. + """ + + created_at: Optional[datetime] + """ + Gateway creation date. + """ + + updated_at: Optional[datetime] + """ + Gateway last modification date. + """ + + name: str + """ + Name of the gateway. + """ + + tags: List[str] + """ + Tags associated with the gateway. + """ + + gateway_networks: List[GatewayNetwork] + """ + GatewayNetwork objects attached to the gateway (each one represents a connection to a Private Network). + """ + + bastion_enabled: bool + """ + Defines whether SSH bastion is enabled on the gateway. + """ + + bastion_port: int + """ + Port of the SSH bastion. + """ + + smtp_enabled: bool + """ + Defines whether SMTP traffic is allowed to pass through the gateway. + """ + + is_legacy: bool + """ + Defines whether the gateway uses non-IPAM IP configurations. + """ + + zone: Zone + """ + Zone of the gateway. + """ + + ipv4: Optional[IP] + """ + Public IPv4 address of the gateway. + """ + + version: Optional[str] + """ + Version of the running gateway software. + """ + + can_upgrade_to: Optional[str] + """ + Newly available gateway software version that can be updated to. + """ + + +@dataclass +class PatRule: + id: str + """ + PAT rule ID. + """ + + gateway_id: str + """ + Gateway the PAT rule applies to. + """ + + public_port: int + """ + Public port to listen on. + """ + + private_ip: str + """ + Private IP address to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + protocol: PatRuleProtocol + """ + Protocol the rule applies to. + """ + + zone: Zone + """ + Zone of the PAT rule. + """ + + created_at: Optional[datetime] + """ + PAT rule creation date. + """ + + updated_at: Optional[datetime] + """ + PAT rule last modification date. + """ + + +@dataclass +class SetPatRulesRequestRule: + public_port: int + """ + Public port to listen on. Uniquely identifies the rule, and a matching rule will be updated with the new parameters. + """ + + private_ip: str + """ + Private IP to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + protocol: PatRuleProtocol + """ + Protocol the rule should apply to. + """ + + +@dataclass +class CreateGatewayNetworkRequest: + gateway_id: str + """ + Public Gateway to connect. + """ + + private_network_id: str + """ + Private Network to connect. + """ + + enable_masquerade: bool + """ + Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + """ + + push_default_route: bool + """ + Enabling the default route also enables masquerading. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + ipam_ip_id: Optional[str] + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + +@dataclass +class CreateGatewayRequest: + type_: str + """ + Gateway type (commercial offer type). + """ + + enable_smtp: bool + """ + Defines whether SMTP traffic should be allowed pass through the gateway. + """ + + enable_bastion: bool + """ + Defines whether SSH bastion should be enabled the gateway. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Scaleway Project to create the gateway in. + """ + + name: Optional[str] + """ + Name for the gateway. + """ + + tags: Optional[List[str]] + """ + Tags for the gateway. + """ + + ip_id: Optional[str] + """ + Existing IP address to attach to the gateway. + """ + + bastion_port: Optional[int] + """ + Port of the SSH bastion. + """ + + +@dataclass +class CreateIPRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Project to create the IP address in. + """ + + tags: Optional[List[str]] + """ + Tags to give to the IP address. + """ + + +@dataclass +class CreatePatRuleRequest: + gateway_id: str + """ + ID of the Gateway on which to create the rule. + """ + + public_port: int + """ + Public port to listen on. + """ + + private_ip: str + """ + Private IP to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + protocol: Optional[PatRuleProtocol] + """ + Protocol the rule should apply to. + """ + + +@dataclass +class DeleteGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeleteGatewayRequest: + gateway_id: str + """ + ID of the gateway to delete. + """ + + delete_ip: bool + """ + Defines whether the PGW's IP should be deleted. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeleteIPRequest: + ip_id: str + """ + ID of the IP address to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeletePatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to fetch. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetGatewayRequest: + gateway_id: str + """ + ID of the gateway to fetch. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetIPRequest: + ip_id: str + """ + ID of the IP address to get. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetPatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to get. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class ListGatewayNetworksRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListGatewayNetworksRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + GatewayNetworks per page. + """ + + status: Optional[List[GatewayNetworkStatus]] + """ + Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + """ + + gateway_ids: Optional[List[str]] + """ + Filter for GatewayNetworks connected to these gateways. + """ + + private_network_ids: Optional[List[str]] + """ + Filter for GatewayNetworks connected to these Private Networks. + """ + + masquerade_enabled: Optional[bool] + """ + Filter for GatewayNetworks with this `enable_masquerade` setting. + """ + + +@dataclass +class ListGatewayNetworksResponse: + gateway_networks: List[GatewayNetwork] + """ + GatewayNetworks on this page. + """ + + total_count: int + """ + Total GatewayNetworks count matching the filter. + """ + + +@dataclass +class ListGatewayTypesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class ListGatewayTypesResponse: + types: List[GatewayType] + """ + Available types of Public Gateway. + """ + + +@dataclass +class ListGatewaysRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListGatewaysRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Gateways per page. + """ + + organization_id: Optional[str] + """ + Include only gateways in this Organization. + """ + + project_id: Optional[str] + """ + Include only gateways in this Project. + """ + + name: Optional[str] + """ + Filter for gateways which have this search term in their name. + """ + + tags: Optional[List[str]] + """ + Filter for gateways with these tags. + """ + + types: Optional[List[str]] + """ + Filter for gateways of these types. + """ + + status: Optional[List[GatewayStatus]] + """ + Filter for gateways with these status. Use `unknown` to include all statuses. + """ + + private_network_ids: Optional[List[str]] + """ + Filter for gateways attached to these Private Networks. + """ + + include_legacy: Optional[bool] + """ + Include also legacy gateways. + """ + + +@dataclass +class ListGatewaysResponse: + gateways: List[Gateway] + """ + Gateways on this page. + """ + + total_count: int + """ + Total count of gateways matching the filter. + """ + + +@dataclass +class ListIPsRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListIPsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + IP addresses per page. + """ + + organization_id: Optional[str] + """ + Include only gateways in this Organization. + """ + + project_id: Optional[str] + """ + Filter for IP addresses in this Project. + """ + + tags: Optional[List[str]] + """ + Filter for IP addresses with these tags. + """ + + reverse: Optional[str] + """ + Filter for IP addresses that have a reverse containing this string. + """ + + is_free: Optional[bool] + """ + Filter based on whether the IP is attached to a gateway or not. + """ + + +@dataclass +class ListIPsResponse: + ips: List[IP] + """ + IP addresses on this page. + """ + + total_count: int + """ + Total count of IP addresses matching the filter. + """ + + +@dataclass +class ListPatRulesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListPatRulesRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + PAT rules per page. + """ + + gateway_ids: Optional[List[str]] + """ + Filter for PAT rules on these gateways. + """ + + private_ips: Optional[List[str]] + """ + Filter for PAT rules targeting these private ips. + """ + + protocol: Optional[PatRuleProtocol] + """ + Filter for PAT rules with this protocol. + """ + + +@dataclass +class ListPatRulesResponse: + pat_rules: List[PatRule] + """ + Array of PAT rules matching the filter. + """ + + total_count: int + """ + Total count of PAT rules matching the filter. + """ + + +@dataclass +class RefreshSSHKeysRequest: + gateway_id: str + """ + ID of the gateway to refresh SSH keys on. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class SetPatRulesRequest: + gateway_id: str + """ + ID of the gateway on which to set the PAT rules. + """ + + pat_rules: List[SetPatRulesRequestRule] + """ + New list of PAT rules. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class SetPatRulesResponse: + pat_rules: List[PatRule] + """ + List of PAT rules. + """ + + +@dataclass +class UpdateGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + enable_masquerade: Optional[bool] + """ + Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + """ + + push_default_route: Optional[bool] + """ + Enabling the default route also enables masquerading. + """ + + ipam_ip_id: Optional[str] + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + +@dataclass +class UpdateGatewayRequest: + gateway_id: str + """ + ID of the gateway to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + name: Optional[str] + """ + Name for the gateway. + """ + + tags: Optional[List[str]] + """ + Tags for the gateway. + """ + + enable_bastion: Optional[bool] + """ + Defines whether SSH bastion should be enabled the gateway. + """ + + bastion_port: Optional[int] + """ + Port of the SSH bastion. + """ + + enable_smtp: Optional[bool] + """ + Defines whether SMTP traffic should be allowed to pass through the gateway. + """ + + +@dataclass +class UpdateIPRequest: + ip_id: str + """ + ID of the IP address to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + tags: Optional[List[str]] + """ + Tags to give to the IP address. + """ + + reverse: Optional[str] + """ + Reverse to set on the address. Empty string to unset. + """ + + gateway_id: Optional[str] + """ + Gateway to attach the IP address to. Empty string to detach. + """ + + +@dataclass +class UpdatePatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + public_port: Optional[int] + """ + Public port to listen on. + """ + + private_ip: Optional[str] + """ + Private IP to forward data to. + """ + + private_port: Optional[int] + """ + Private port to translate to. + """ + + protocol: Optional[PatRuleProtocol] + """ + Protocol the rule should apply to. + """ + + +@dataclass +class UpgradeGatewayRequest: + gateway_id: str + """ + ID of the gateway to upgrade. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + type_: Optional[str] + """ + Gateway type (commercial offer). + """ diff --git a/scaleway/scaleway/vpcgw/v2/__init__.py b/scaleway/scaleway/vpcgw/v2/__init__.py new file mode 100644 index 000000000..7c1cd4fe3 --- /dev/null +++ b/scaleway/scaleway/vpcgw/v2/__init__.py @@ -0,0 +1,97 @@ +# 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 GatewayNetworkStatus +from .content import GATEWAY_NETWORK_TRANSIENT_STATUSES +from .types import GatewayStatus +from .content import GATEWAY_TRANSIENT_STATUSES +from .types import ListGatewayNetworksRequestOrderBy +from .types import ListGatewaysRequestOrderBy +from .types import ListIPsRequestOrderBy +from .types import ListPatRulesRequestOrderBy +from .types import PatRuleProtocol +from .types import GatewayNetwork +from .types import IP +from .types import GatewayType +from .types import Gateway +from .types import PatRule +from .types import SetPatRulesRequestRule +from .types import CreateGatewayNetworkRequest +from .types import CreateGatewayRequest +from .types import CreateIPRequest +from .types import CreatePatRuleRequest +from .types import DeleteGatewayNetworkRequest +from .types import DeleteGatewayRequest +from .types import DeleteIPRequest +from .types import DeletePatRuleRequest +from .types import GetGatewayNetworkRequest +from .types import GetGatewayRequest +from .types import GetIPRequest +from .types import GetPatRuleRequest +from .types import ListGatewayNetworksRequest +from .types import ListGatewayNetworksResponse +from .types import ListGatewayTypesRequest +from .types import ListGatewayTypesResponse +from .types import ListGatewaysRequest +from .types import ListGatewaysResponse +from .types import ListIPsRequest +from .types import ListIPsResponse +from .types import ListPatRulesRequest +from .types import ListPatRulesResponse +from .types import RefreshSSHKeysRequest +from .types import SetPatRulesRequest +from .types import SetPatRulesResponse +from .types import UpdateGatewayNetworkRequest +from .types import UpdateGatewayRequest +from .types import UpdateIPRequest +from .types import UpdatePatRuleRequest +from .types import UpgradeGatewayRequest +from .api import VpcgwV2API + +__all__ = [ + "GatewayNetworkStatus", + "GATEWAY_NETWORK_TRANSIENT_STATUSES", + "GatewayStatus", + "GATEWAY_TRANSIENT_STATUSES", + "ListGatewayNetworksRequestOrderBy", + "ListGatewaysRequestOrderBy", + "ListIPsRequestOrderBy", + "ListPatRulesRequestOrderBy", + "PatRuleProtocol", + "GatewayNetwork", + "IP", + "GatewayType", + "Gateway", + "PatRule", + "SetPatRulesRequestRule", + "CreateGatewayNetworkRequest", + "CreateGatewayRequest", + "CreateIPRequest", + "CreatePatRuleRequest", + "DeleteGatewayNetworkRequest", + "DeleteGatewayRequest", + "DeleteIPRequest", + "DeletePatRuleRequest", + "GetGatewayNetworkRequest", + "GetGatewayRequest", + "GetIPRequest", + "GetPatRuleRequest", + "ListGatewayNetworksRequest", + "ListGatewayNetworksResponse", + "ListGatewayTypesRequest", + "ListGatewayTypesResponse", + "ListGatewaysRequest", + "ListGatewaysResponse", + "ListIPsRequest", + "ListIPsResponse", + "ListPatRulesRequest", + "ListPatRulesResponse", + "RefreshSSHKeysRequest", + "SetPatRulesRequest", + "SetPatRulesResponse", + "UpdateGatewayNetworkRequest", + "UpdateGatewayRequest", + "UpdateIPRequest", + "UpdatePatRuleRequest", + "UpgradeGatewayRequest", + "VpcgwV2API", +] diff --git a/scaleway/scaleway/vpcgw/v2/api.py b/scaleway/scaleway/vpcgw/v2/api.py new file mode 100644 index 000000000..42d7b57d7 --- /dev/null +++ b/scaleway/scaleway/vpcgw/v2/api.py @@ -0,0 +1,1383 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import List, Optional + +from scaleway_core.api import API +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + WaitForOptions, + random_name, + validate_path_param, + fetch_all_pages, + wait_for_resource, +) +from .types import ( + GatewayNetworkStatus, + GatewayStatus, + ListGatewayNetworksRequestOrderBy, + ListGatewaysRequestOrderBy, + ListIPsRequestOrderBy, + ListPatRulesRequestOrderBy, + PatRuleProtocol, + CreateGatewayNetworkRequest, + CreateGatewayRequest, + CreateIPRequest, + CreatePatRuleRequest, + Gateway, + GatewayNetwork, + IP, + ListGatewayNetworksResponse, + ListGatewayTypesResponse, + ListGatewaysResponse, + ListIPsResponse, + ListPatRulesResponse, + PatRule, + SetPatRulesRequest, + SetPatRulesRequestRule, + SetPatRulesResponse, + UpdateGatewayNetworkRequest, + UpdateGatewayRequest, + UpdateIPRequest, + UpdatePatRuleRequest, + UpgradeGatewayRequest, +) +from .content import ( + GATEWAY_NETWORK_TRANSIENT_STATUSES, + GATEWAY_TRANSIENT_STATUSES, +) +from .marshalling import ( + unmarshal_GatewayNetwork, + unmarshal_IP, + unmarshal_Gateway, + unmarshal_PatRule, + unmarshal_ListGatewayNetworksResponse, + unmarshal_ListGatewayTypesResponse, + unmarshal_ListGatewaysResponse, + unmarshal_ListIPsResponse, + unmarshal_ListPatRulesResponse, + unmarshal_SetPatRulesResponse, + marshal_CreateGatewayNetworkRequest, + marshal_CreateGatewayRequest, + marshal_CreateIPRequest, + marshal_CreatePatRuleRequest, + marshal_SetPatRulesRequest, + marshal_UpdateGatewayNetworkRequest, + marshal_UpdateGatewayRequest, + marshal_UpdateIPRequest, + marshal_UpdatePatRuleRequest, + marshal_UpgradeGatewayRequest, +) + + +class VpcgwV2API(API): + """ + This API allows you to manage your Public Gateways. + """ + + def list_gateways( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewaysRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + types: Optional[List[str]] = None, + status: Optional[List[GatewayStatus]] = None, + private_network_ids: Optional[List[str]] = None, + include_legacy: Optional[bool] = None, + ) -> ListGatewaysResponse: + """ + List Public Gateways. + List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Gateways per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Include only gateways in this Project. + :param name: Filter for gateways which have this search term in their name. + :param tags: Filter for gateways with these tags. + :param types: Filter for gateways of these types. + :param status: Filter for gateways with these status. Use `unknown` to include all statuses. + :param private_network_ids: Filter for gateways attached to these Private Networks. + :param include_legacy: Include also legacy gateways. + :return: :class:`ListGatewaysResponse ` + + Usage: + :: + + result = api.list_gateways() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateways", + params={ + "include_legacy": include_legacy, + "name": name, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "project_id": project_id or self.client.default_project_id, + "status": status, + "tags": tags, + "types": types, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGatewaysResponse(res.json()) + + def list_gateways_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewaysRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + types: Optional[List[str]] = None, + status: Optional[List[GatewayStatus]] = None, + private_network_ids: Optional[List[str]] = None, + include_legacy: Optional[bool] = None, + ) -> List[Gateway]: + """ + List Public Gateways. + List Public Gateways in a given Scaleway Organization or Project. By default, results are displayed in ascending order of creation date. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number to return. + :param page_size: Gateways per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Include only gateways in this Project. + :param name: Filter for gateways which have this search term in their name. + :param tags: Filter for gateways with these tags. + :param types: Filter for gateways of these types. + :param status: Filter for gateways with these status. Use `unknown` to include all statuses. + :param private_network_ids: Filter for gateways attached to these Private Networks. + :param include_legacy: Include also legacy gateways. + :return: :class:`List[Gateway] ` + + Usage: + :: + + result = api.list_gateways_all() + """ + + return fetch_all_pages( + type=ListGatewaysResponse, + key="gateways", + fetcher=self.list_gateways, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "name": name, + "tags": tags, + "types": types, + "status": status, + "private_network_ids": private_network_ids, + "include_legacy": include_legacy, + }, + ) + + def get_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Get a Public Gateway. + Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more. + :param gateway_id: ID of the gateway to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.get_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + def wait_for_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[Gateway, bool]] = None, + ) -> Gateway: + """ + Get a Public Gateway. + Get details of a Public Gateway, specified by its gateway ID. The response object contains full details of the gateway, including its **name**, **type**, **status** and more. + :param gateway_id: ID of the gateway to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.get_gateway( + gateway_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = lambda res: res.status not in GATEWAY_TRANSIENT_STATUSES + + return wait_for_resource( + fetcher=self.get_gateway, + options=options, + args={ + "gateway_id": gateway_id, + "zone": zone, + }, + ) + + def create_gateway( + self, + *, + type_: str, + enable_smtp: bool, + enable_bastion: bool, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + ip_id: Optional[str] = None, + bastion_port: Optional[int] = None, + ) -> Gateway: + """ + Create a Public Gateway. + Create a new Public Gateway in the specified Scaleway Project, defining its **name**, **type** and other configuration details such as whether to enable SSH bastion. + :param type_: Gateway type (commercial offer type). + :param enable_smtp: Defines whether SMTP traffic should be allowed pass through the gateway. + :param enable_bastion: Defines whether SSH bastion should be enabled the gateway. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Scaleway Project to create the gateway in. + :param name: Name for the gateway. + :param tags: Tags for the gateway. + :param ip_id: Existing IP address to attach to the gateway. + :param bastion_port: Port of the SSH bastion. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.create_gateway( + type="example", + enable_smtp=False, + enable_bastion=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways", + body=marshal_CreateGatewayRequest( + CreateGatewayRequest( + type_=type_, + enable_smtp=enable_smtp, + enable_bastion=enable_bastion, + zone=zone, + project_id=project_id, + name=name or random_name(prefix="gw"), + tags=tags, + ip_id=ip_id, + bastion_port=bastion_port, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + def update_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + name: Optional[str] = None, + tags: Optional[List[str]] = None, + enable_bastion: Optional[bool] = None, + bastion_port: Optional[int] = None, + enable_smtp: Optional[bool] = None, + ) -> Gateway: + """ + Update a Public Gateway. + Update the parameters of an existing Public Gateway, for example, its **name**, **tags**, **SSH bastion configuration**, and **DNS servers**. + :param gateway_id: ID of the gateway to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param name: Name for the gateway. + :param tags: Tags for the gateway. + :param enable_bastion: Defines whether SSH bastion should be enabled the gateway. + :param bastion_port: Port of the SSH bastion. + :param enable_smtp: Defines whether SMTP traffic should be allowed to pass through the gateway. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.update_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + body=marshal_UpdateGatewayRequest( + UpdateGatewayRequest( + gateway_id=gateway_id, + zone=zone, + name=name, + tags=tags, + enable_bastion=enable_bastion, + bastion_port=bastion_port, + enable_smtp=enable_smtp, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + def delete_gateway( + self, + *, + gateway_id: str, + delete_ip: bool, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Delete a Public Gateway. + Delete an existing Public Gateway, specified by its gateway ID. This action is irreversible. + :param gateway_id: ID of the gateway to delete. + :param delete_ip: Defines whether the PGW's IP should be deleted. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.delete_gateway( + gateway_id="example", + delete_ip=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}", + params={ + "delete_ip": delete_ip, + }, + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + def upgrade_gateway( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + type_: Optional[str] = None, + ) -> Gateway: + """ + Upgrade a Public Gateway to the latest version and/or to a different commercial offer type. + Upgrade a given Public Gateway to the newest software version or to a different commercial offer type. This applies the latest bugfixes and features to your Public Gateway. Note that gateway service will be interrupted during the update. + :param gateway_id: ID of the gateway to upgrade. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param type_: Gateway type (commercial offer). + :return: :class:`Gateway ` + + Usage: + :: + + result = api.upgrade_gateway( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/upgrade", + body=marshal_UpgradeGatewayRequest( + UpgradeGatewayRequest( + gateway_id=gateway_id, + zone=zone, + type_=type_, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) + + def list_gateway_networks( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewayNetworksRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + status: Optional[List[GatewayNetworkStatus]] = None, + gateway_ids: Optional[List[str]] = None, + private_network_ids: Optional[List[str]] = None, + masquerade_enabled: Optional[bool] = None, + ) -> ListGatewayNetworksResponse: + """ + List Public Gateway connections to Private Networks. + List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: GatewayNetworks per page. + :param status: Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + :param gateway_ids: Filter for GatewayNetworks connected to these gateways. + :param private_network_ids: Filter for GatewayNetworks connected to these Private Networks. + :param masquerade_enabled: Filter for GatewayNetworks with this `enable_masquerade` setting. + :return: :class:`ListGatewayNetworksResponse ` + + Usage: + :: + + result = api.list_gateway_networks() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks", + params={ + "gateway_ids": gateway_ids, + "masquerade_enabled": masquerade_enabled, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_network_ids": private_network_ids, + "status": status, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListGatewayNetworksResponse(res.json()) + + def list_gateway_networks_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListGatewayNetworksRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + status: Optional[List[GatewayNetworkStatus]] = None, + gateway_ids: Optional[List[str]] = None, + private_network_ids: Optional[List[str]] = None, + masquerade_enabled: Optional[bool] = None, + ) -> List[GatewayNetwork]: + """ + List Public Gateway connections to Private Networks. + List the connections between Public Gateways and Private Networks (a connection = a GatewayNetwork). You can choose to filter by `gateway-id` to list all Private Networks attached to the specified Public Gateway, or by `private_network_id` to list all Public Gateways attached to the specified Private Network. Other query parameters are also available. The result is an array of GatewayNetwork objects, each giving details of the connection between a given Public Gateway and a given Private Network. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: GatewayNetworks per page. + :param status: Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + :param gateway_ids: Filter for GatewayNetworks connected to these gateways. + :param private_network_ids: Filter for GatewayNetworks connected to these Private Networks. + :param masquerade_enabled: Filter for GatewayNetworks with this `enable_masquerade` setting. + :return: :class:`List[GatewayNetwork] ` + + Usage: + :: + + result = api.list_gateway_networks_all() + """ + + return fetch_all_pages( + type=ListGatewayNetworksResponse, + key="gateway_networks", + fetcher=self.list_gateway_networks, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "status": status, + "gateway_ids": gateway_ids, + "private_network_ids": private_network_ids, + "masquerade_enabled": masquerade_enabled, + }, + ) + + def get_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + ) -> GatewayNetwork: + """ + Get a Public Gateway connection to a Private Network. + Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings. + :param gateway_network_id: ID of the GatewayNetwork to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = api.get_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + def wait_for_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + options: Optional[WaitForOptions[GatewayNetwork, bool]] = None, + ) -> GatewayNetwork: + """ + Get a Public Gateway connection to a Private Network. + Get details of a given connection between a Public Gateway and a Private Network (this connection = a GatewayNetwork), specified by its `gateway_network_id`. The response object contains details of the connection including the IDs of the Public Gateway and Private Network, the dates the connection was created/updated and its configuration settings. + :param gateway_network_id: ID of the GatewayNetwork to fetch. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = api.get_gateway_network( + gateway_network_id="example", + ) + """ + + if not options: + options = WaitForOptions() + + if not options.stop: + options.stop = ( + lambda res: res.status not in GATEWAY_NETWORK_TRANSIENT_STATUSES + ) + + return wait_for_resource( + fetcher=self.get_gateway_network, + options=options, + args={ + "gateway_network_id": gateway_network_id, + "zone": zone, + }, + ) + + def create_gateway_network( + self, + *, + gateway_id: str, + private_network_id: str, + enable_masquerade: bool, + push_default_route: bool, + zone: Optional[Zone] = None, + ipam_ip_id: Optional[str] = None, + ) -> GatewayNetwork: + """ + Attach a Public Gateway to a Private Network. + Attach a specific Public Gateway to a specific Private Network (create a GatewayNetwork). You can configure parameters for the connection including whether to enable masquerade (dynamic NAT), and more. + :param gateway_id: Public Gateway to connect. + :param private_network_id: Private Network to connect. + :param enable_masquerade: Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + :param push_default_route: Enabling the default route also enables masquerading. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param ipam_ip_id: Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = api.create_gateway_network( + gateway_id="example", + private_network_id="example", + enable_masquerade=False, + push_default_route=False, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks", + body=marshal_CreateGatewayNetworkRequest( + CreateGatewayNetworkRequest( + gateway_id=gateway_id, + private_network_id=private_network_id, + enable_masquerade=enable_masquerade, + push_default_route=push_default_route, + zone=zone, + ipam_ip_id=ipam_ip_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + def update_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + enable_masquerade: Optional[bool] = None, + push_default_route: Optional[bool] = None, + ipam_ip_id: Optional[str] = None, + ) -> GatewayNetwork: + """ + Update a Public Gateway's connection to a Private Network. + Update the configuration parameters of a connection between a given Public Gateway and Private Network (the connection = a GatewayNetwork). Updatable parameters include whether to enable traffic masquerade (dynamic NAT). + :param gateway_network_id: ID of the GatewayNetwork to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param enable_masquerade: Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + :param push_default_route: Enabling the default route also enables masquerading. + :param ipam_ip_id: Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = api.update_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + body=marshal_UpdateGatewayNetworkRequest( + UpdateGatewayNetworkRequest( + gateway_network_id=gateway_network_id, + zone=zone, + enable_masquerade=enable_masquerade, + push_default_route=push_default_route, + ipam_ip_id=ipam_ip_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + def delete_gateway_network( + self, + *, + gateway_network_id: str, + zone: Optional[Zone] = None, + ) -> GatewayNetwork: + """ + Detach a Public Gateway from a Private Network. + Detach a given Public Gateway from a given Private Network, i.e. delete a GatewayNetwork specified by a gateway_network_id. + :param gateway_network_id: ID of the GatewayNetwork to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`GatewayNetwork ` + + Usage: + :: + + result = api.delete_gateway_network( + gateway_network_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_network_id = validate_path_param( + "gateway_network_id", gateway_network_id + ) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/gateway-networks/{param_gateway_network_id}", + ) + + self._throw_on_error(res) + return unmarshal_GatewayNetwork(res.json()) + + def list_pat_rules( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListPatRulesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + gateway_ids: Optional[List[str]] = None, + private_ips: Optional[List[str]] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> ListPatRulesResponse: + """ + List PAT rules. + List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: PAT rules per page. + :param gateway_ids: Filter for PAT rules on these gateways. + :param private_ips: Filter for PAT rules targeting these private ips. + :param protocol: Filter for PAT rules with this protocol. + :return: :class:`ListPatRulesResponse ` + + Usage: + :: + + result = api.list_pat_rules() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + params={ + "gateway_ids": gateway_ids, + "order_by": order_by, + "page": page, + "page_size": page_size or self.client.default_page_size, + "private_ips": private_ips, + "protocol": protocol, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListPatRulesResponse(res.json()) + + def list_pat_rules_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListPatRulesRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + gateway_ids: Optional[List[str]] = None, + private_ips: Optional[List[str]] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> List[PatRule]: + """ + List PAT rules. + List PAT rules. You can filter by gateway ID to list all PAT rules for a particular gateway, or filter for PAT rules targeting a specific IP address or using a specific protocol. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: PAT rules per page. + :param gateway_ids: Filter for PAT rules on these gateways. + :param private_ips: Filter for PAT rules targeting these private ips. + :param protocol: Filter for PAT rules with this protocol. + :return: :class:`List[PatRule] ` + + Usage: + :: + + result = api.list_pat_rules_all() + """ + + return fetch_all_pages( + type=ListPatRulesResponse, + key="pat_rules", + fetcher=self.list_pat_rules, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "gateway_ids": gateway_ids, + "private_ips": private_ips, + "protocol": protocol, + }, + ) + + def get_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + ) -> PatRule: + """ + Get a PAT rule. + Get a PAT rule, specified by its PAT rule ID. The response object gives full details of the PAT rule, including the Public Gateway it belongs to and the configuration settings in terms of public / private ports, private IP and protocol. + :param pat_rule_id: ID of the PAT rule to get. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`PatRule ` + + Usage: + :: + + result = api.get_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + def create_pat_rule( + self, + *, + gateway_id: str, + public_port: int, + private_ip: str, + private_port: int, + zone: Optional[Zone] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> PatRule: + """ + Create a PAT rule. + Create a new PAT rule on a specified Public Gateway, defining the protocol to use, public port to listen on, and private port / IP address to map to. + :param gateway_id: ID of the Gateway on which to create the rule. + :param public_port: Public port to listen on. + :param private_ip: Private IP to forward data to. + :param private_port: Private port to translate to. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param protocol: Protocol the rule should apply to. + :return: :class:`PatRule ` + + Usage: + :: + + result = api.create_pat_rule( + gateway_id="example", + public_port=1, + private_ip="example", + private_port=1, + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + body=marshal_CreatePatRuleRequest( + CreatePatRuleRequest( + gateway_id=gateway_id, + public_port=public_port, + private_ip=private_ip, + private_port=private_port, + zone=zone, + protocol=protocol, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + def update_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + public_port: Optional[int] = None, + private_ip: Optional[str] = None, + private_port: Optional[int] = None, + protocol: Optional[PatRuleProtocol] = None, + ) -> PatRule: + """ + Update a PAT rule. + Update a PAT rule, specified by its PAT rule ID. Configuration settings including private/public port, private IP address and protocol can all be updated. + :param pat_rule_id: ID of the PAT rule to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param public_port: Public port to listen on. + :param private_ip: Private IP to forward data to. + :param private_port: Private port to translate to. + :param protocol: Protocol the rule should apply to. + :return: :class:`PatRule ` + + Usage: + :: + + result = api.update_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + body=marshal_UpdatePatRuleRequest( + UpdatePatRuleRequest( + pat_rule_id=pat_rule_id, + zone=zone, + public_port=public_port, + private_ip=private_ip, + private_port=private_port, + protocol=protocol, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_PatRule(res.json()) + + def set_pat_rules( + self, + *, + gateway_id: str, + pat_rules: List[SetPatRulesRequestRule], + zone: Optional[Zone] = None, + ) -> SetPatRulesResponse: + """ + Set all PAT rules. + Set a definitive list of PAT rules attached to a Public Gateway. Each rule is identified by its public port and protocol. This will sync the current PAT rule list on the gateway with the new list, creating, updating or deleting PAT rules accordingly. + :param gateway_id: ID of the gateway on which to set the PAT rules. + :param pat_rules: New list of PAT rules. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`SetPatRulesResponse ` + + Usage: + :: + + result = api.set_pat_rules( + gateway_id="example", + pat_rules=[], + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "PUT", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules", + body=marshal_SetPatRulesRequest( + SetPatRulesRequest( + gateway_id=gateway_id, + pat_rules=pat_rules, + zone=zone, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_SetPatRulesResponse(res.json()) + + def delete_pat_rule( + self, + *, + pat_rule_id: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete a PAT rule. + Delete a PAT rule, identified by its PAT rule ID. This action is irreversible. + :param pat_rule_id: ID of the PAT rule to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = api.delete_pat_rule( + pat_rule_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_pat_rule_id = validate_path_param("pat_rule_id", pat_rule_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/pat-rules/{param_pat_rule_id}", + ) + + self._throw_on_error(res) + + def list_gateway_types( + self, + *, + zone: Optional[Zone] = None, + ) -> ListGatewayTypesResponse: + """ + List Public Gateway types. + List the different Public Gateway commercial offer types available at Scaleway. The response is an array of objects describing the name and technical details of each available gateway type. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`ListGatewayTypesResponse ` + + Usage: + :: + + result = api.list_gateway_types() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/gateway-types", + ) + + self._throw_on_error(res) + return unmarshal_ListGatewayTypesResponse(res.json()) + + def list_i_ps( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListIPsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + is_free: Optional[bool] = None, + ) -> ListIPsResponse: + """ + List IPs. + List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: IP addresses per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Filter for IP addresses in this Project. + :param tags: Filter for IP addresses with these tags. + :param reverse: Filter for IP addresses that have a reverse containing this string. + :param is_free: Filter based on whether the IP is attached to a gateway or not. + :return: :class:`ListIPsResponse ` + + Usage: + :: + + result = api.list_i_ps() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/ips", + params={ + "is_free": is_free, + "order_by": order_by, + "organization_id": organization_id + or self.client.default_organization_id, + "page": page, + "page_size": page_size or self.client.default_page_size, + "project_id": project_id or self.client.default_project_id, + "reverse": reverse, + "tags": tags, + }, + ) + + self._throw_on_error(res) + return unmarshal_ListIPsResponse(res.json()) + + def list_i_ps_all( + self, + *, + zone: Optional[Zone] = None, + order_by: Optional[ListIPsRequestOrderBy] = None, + page: Optional[int] = None, + page_size: Optional[int] = None, + organization_id: Optional[str] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + is_free: Optional[bool] = None, + ) -> List[IP]: + """ + List IPs. + List Public Gateway flexible IP addresses. A number of filter options are available for limiting results in the response. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param order_by: Order in which to return results. + :param page: Page number. + :param page_size: IP addresses per page. + :param organization_id: Include only gateways in this Organization. + :param project_id: Filter for IP addresses in this Project. + :param tags: Filter for IP addresses with these tags. + :param reverse: Filter for IP addresses that have a reverse containing this string. + :param is_free: Filter based on whether the IP is attached to a gateway or not. + :return: :class:`List[IP] ` + + Usage: + :: + + result = api.list_i_ps_all() + """ + + return fetch_all_pages( + type=ListIPsResponse, + key="ips", + fetcher=self.list_i_ps, + args={ + "zone": zone, + "order_by": order_by, + "page": page, + "page_size": page_size, + "organization_id": organization_id, + "project_id": project_id, + "tags": tags, + "reverse": reverse, + "is_free": is_free, + }, + ) + + def get_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + ) -> IP: + """ + Get an IP. + Get details of a Public Gateway flexible IP address, identified by its IP ID. The response object contains information including which (if any) Public Gateway using this IP address, the reverse and various other metadata. + :param ip_id: ID of the IP address to get. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`IP ` + + Usage: + :: + + result = api.get_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "GET", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + def create_ip( + self, + *, + zone: Optional[Zone] = None, + project_id: Optional[str] = None, + tags: Optional[List[str]] = None, + ) -> IP: + """ + Reserve an IP. + Create (reserve) a new flexible IP address that can be used for a Public Gateway in a specified Scaleway Project. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param project_id: Project to create the IP address in. + :param tags: Tags to give to the IP address. + :return: :class:`IP ` + + Usage: + :: + + result = api.create_ip() + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/ips", + body=marshal_CreateIPRequest( + CreateIPRequest( + zone=zone, + project_id=project_id, + tags=tags, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + def update_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + tags: Optional[List[str]] = None, + reverse: Optional[str] = None, + gateway_id: Optional[str] = None, + ) -> IP: + """ + Update an IP. + Update details of an existing flexible IP address, including its tags, reverse and the Public Gateway it is assigned to. + :param ip_id: ID of the IP address to update. + :param zone: Zone to target. If none is passed will use default zone from the config. + :param tags: Tags to give to the IP address. + :param reverse: Reverse to set on the address. Empty string to unset. + :param gateway_id: Gateway to attach the IP address to. Empty string to detach. + :return: :class:`IP ` + + Usage: + :: + + result = api.update_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "PATCH", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + body=marshal_UpdateIPRequest( + UpdateIPRequest( + ip_id=ip_id, + zone=zone, + tags=tags, + reverse=reverse, + gateway_id=gateway_id, + ), + self.client, + ), + ) + + self._throw_on_error(res) + return unmarshal_IP(res.json()) + + def delete_ip( + self, + *, + ip_id: str, + zone: Optional[Zone] = None, + ) -> None: + """ + Delete an IP. + Delete a flexible IP address from your account. This action is irreversible. + :param ip_id: ID of the IP address to delete. + :param zone: Zone to target. If none is passed will use default zone from the config. + + Usage: + :: + + result = api.delete_ip( + ip_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_ip_id = validate_path_param("ip_id", ip_id) + + res = self._request( + "DELETE", + f"/vpc-gw/v2/zones/{param_zone}/ips/{param_ip_id}", + ) + + self._throw_on_error(res) + + def refresh_ssh_keys( + self, + *, + gateway_id: str, + zone: Optional[Zone] = None, + ) -> Gateway: + """ + Refresh a Public Gateway's SSH keys. + Refresh the SSH keys of a given Public Gateway, specified by its gateway ID. This adds any new SSH keys in the gateway's Scaleway Project to the gateway itself. + :param gateway_id: ID of the gateway to refresh SSH keys on. + :param zone: Zone to target. If none is passed will use default zone from the config. + :return: :class:`Gateway ` + + Usage: + :: + + result = api.refresh_ssh_keys( + gateway_id="example", + ) + """ + + param_zone = validate_path_param("zone", zone or self.client.default_zone) + param_gateway_id = validate_path_param("gateway_id", gateway_id) + + res = self._request( + "POST", + f"/vpc-gw/v2/zones/{param_zone}/gateways/{param_gateway_id}/refresh-ssh-keys", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_Gateway(res.json()) diff --git a/scaleway/scaleway/vpcgw/v2/content.py b/scaleway/scaleway/vpcgw/v2/content.py new file mode 100644 index 000000000..a5b8a7acf --- /dev/null +++ b/scaleway/scaleway/vpcgw/v2/content.py @@ -0,0 +1,26 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from typing import List + +from .types import ( + GatewayNetworkStatus, + GatewayStatus, +) + +GATEWAY_NETWORK_TRANSIENT_STATUSES: List[GatewayNetworkStatus] = [ + GatewayNetworkStatus.ATTACHING, + GatewayNetworkStatus.CONFIGURING, + GatewayNetworkStatus.DETACHING, +] +""" +Lists transient statutes of the enum :class:`GatewayNetworkStatus `. +""" +GATEWAY_TRANSIENT_STATUSES: List[GatewayStatus] = [ + GatewayStatus.ALLOCATING, + GatewayStatus.CONFIGURING, + GatewayStatus.STOPPING, + GatewayStatus.DELETING, +] +""" +Lists transient statutes of the enum :class:`GatewayStatus `. +""" diff --git a/scaleway/scaleway/vpcgw/v2/marshalling.py b/scaleway/scaleway/vpcgw/v2/marshalling.py new file mode 100644 index 000000000..ff9cb1e66 --- /dev/null +++ b/scaleway/scaleway/vpcgw/v2/marshalling.py @@ -0,0 +1,667 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. + +from typing import Any, Dict +from dateutil import parser + +from scaleway_core.profile import ProfileDefaults +from .types import ( + GatewayNetwork, + IP, + Gateway, + PatRule, + ListGatewayNetworksResponse, + GatewayType, + ListGatewayTypesResponse, + ListGatewaysResponse, + ListIPsResponse, + ListPatRulesResponse, + SetPatRulesResponse, + CreateGatewayNetworkRequest, + CreateGatewayRequest, + CreateIPRequest, + CreatePatRuleRequest, + SetPatRulesRequestRule, + SetPatRulesRequest, + UpdateGatewayNetworkRequest, + UpdateGatewayRequest, + UpdateIPRequest, + UpdatePatRuleRequest, + UpgradeGatewayRequest, +) + + +def unmarshal_GatewayNetwork(data: Any) -> GatewayNetwork: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'GatewayNetwork' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + + field = data.get("private_network_id", None) + if field is not None: + args["private_network_id"] = field + + field = data.get("masquerade_enabled", None) + if field is not None: + args["masquerade_enabled"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("push_default_route", None) + if field is not None: + args["push_default_route"] = field + + field = data.get("ipam_ip_id", None) + if field is not None: + args["ipam_ip_id"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("mac_address", None) + if field is not None: + args["mac_address"] = field + else: + args["mac_address"] = None + + return GatewayNetwork(**args) + + +def unmarshal_IP(data: Any) -> IP: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'IP' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("address", None) + if field is not None: + args["address"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("reverse", None) + if field is not None: + args["reverse"] = field + else: + args["reverse"] = None + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + else: + args["gateway_id"] = None + + return IP(**args) + + +def unmarshal_Gateway(data: Any) -> Gateway: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'Gateway' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("organization_id", None) + if field is not None: + args["organization_id"] = field + + field = data.get("project_id", None) + if field is not None: + args["project_id"] = field + + field = data.get("type", None) + if field is not None: + args["type_"] = field + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + + field = data.get("status", None) + if field is not None: + args["status"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + field = data.get("name", None) + if field is not None: + args["name"] = field + + field = data.get("tags", None) + if field is not None: + args["tags"] = field + + field = data.get("gateway_networks", None) + if field is not None: + args["gateway_networks"] = ( + [unmarshal_GatewayNetwork(v) for v in field] if field is not None else None + ) + + field = data.get("bastion_enabled", None) + if field is not None: + args["bastion_enabled"] = field + + field = data.get("bastion_port", None) + if field is not None: + args["bastion_port"] = field + + field = data.get("smtp_enabled", None) + if field is not None: + args["smtp_enabled"] = field + + field = data.get("is_legacy", None) + if field is not None: + args["is_legacy"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("ipv4", None) + if field is not None: + args["ipv4"] = unmarshal_IP(field) + else: + args["ipv4"] = None + + field = data.get("version", None) + if field is not None: + args["version"] = field + else: + args["version"] = None + + field = data.get("can_upgrade_to", None) + if field is not None: + args["can_upgrade_to"] = field + else: + args["can_upgrade_to"] = None + + return Gateway(**args) + + +def unmarshal_PatRule(data: Any) -> PatRule: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'PatRule' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("id", None) + if field is not None: + args["id"] = field + + field = data.get("gateway_id", None) + if field is not None: + args["gateway_id"] = field + + field = data.get("public_port", None) + if field is not None: + args["public_port"] = field + + field = data.get("private_ip", None) + if field is not None: + args["private_ip"] = field + + field = data.get("private_port", None) + if field is not None: + args["private_port"] = field + + field = data.get("protocol", None) + if field is not None: + args["protocol"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + field = data.get("created_at", None) + if field is not None: + args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["created_at"] = None + + field = data.get("updated_at", None) + if field is not None: + args["updated_at"] = parser.isoparse(field) if isinstance(field, str) else field + else: + args["updated_at"] = None + + return PatRule(**args) + + +def unmarshal_ListGatewayNetworksResponse(data: Any) -> ListGatewayNetworksResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewayNetworksResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("gateway_networks", None) + if field is not None: + args["gateway_networks"] = ( + [unmarshal_GatewayNetwork(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListGatewayNetworksResponse(**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 + + field = data.get("bandwidth", None) + if field is not None: + args["bandwidth"] = field + + field = data.get("zone", None) + if field is not None: + args["zone"] = field + + return GatewayType(**args) + + +def unmarshal_ListGatewayTypesResponse(data: Any) -> ListGatewayTypesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewayTypesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("types", None) + if field is not None: + args["types"] = ( + [unmarshal_GatewayType(v) for v in field] if field is not None else None + ) + + return ListGatewayTypesResponse(**args) + + +def unmarshal_ListGatewaysResponse(data: Any) -> ListGatewaysResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListGatewaysResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("gateways", None) + if field is not None: + args["gateways"] = ( + [unmarshal_Gateway(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListGatewaysResponse(**args) + + +def unmarshal_ListIPsResponse(data: Any) -> ListIPsResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListIPsResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("ips", None) + if field is not None: + args["ips"] = [unmarshal_IP(v) for v in field] if field is not None else None + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListIPsResponse(**args) + + +def unmarshal_ListPatRulesResponse(data: Any) -> ListPatRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'ListPatRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pat_rules", None) + if field is not None: + args["pat_rules"] = ( + [unmarshal_PatRule(v) for v in field] if field is not None else None + ) + + field = data.get("total_count", None) + if field is not None: + args["total_count"] = field + + return ListPatRulesResponse(**args) + + +def unmarshal_SetPatRulesResponse(data: Any) -> SetPatRulesResponse: + if not isinstance(data, dict): + raise TypeError( + "Unmarshalling the type 'SetPatRulesResponse' failed as data isn't a dictionary." + ) + + args: Dict[str, Any] = {} + + field = data.get("pat_rules", None) + if field is not None: + args["pat_rules"] = ( + [unmarshal_PatRule(v) for v in field] if field is not None else None + ) + + return SetPatRulesResponse(**args) + + +def marshal_CreateGatewayNetworkRequest( + request: CreateGatewayNetworkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.private_network_id is not None: + output["private_network_id"] = request.private_network_id + + if request.enable_masquerade is not None: + output["enable_masquerade"] = request.enable_masquerade + + if request.push_default_route is not None: + output["push_default_route"] = request.push_default_route + + if request.ipam_ip_id is not None: + output["ipam_ip_id"] = request.ipam_ip_id + + return output + + +def marshal_CreateGatewayRequest( + request: CreateGatewayRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = request.type_ + + if request.enable_smtp is not None: + output["enable_smtp"] = request.enable_smtp + + if request.enable_bastion is not None: + output["enable_bastion"] = request.enable_bastion + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.name is not None: + output["name"] = request.name + + if request.tags is not None: + output["tags"] = request.tags + + if request.ip_id is not None: + output["ip_id"] = request.ip_id + + if request.bastion_port is not None: + output["bastion_port"] = request.bastion_port + + return output + + +def marshal_CreateIPRequest( + request: CreateIPRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.project_id is not None: + output["project_id"] = request.project_id or defaults.default_project_id + + if request.tags is not None: + output["tags"] = request.tags + + return output + + +def marshal_CreatePatRuleRequest( + request: CreatePatRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_SetPatRulesRequestRule( + request: SetPatRulesRequestRule, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_SetPatRulesRequest( + request: SetPatRulesRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + if request.pat_rules is not None: + output["pat_rules"] = [ + marshal_SetPatRulesRequestRule(item, defaults) for item in request.pat_rules + ] + + return output + + +def marshal_UpdateGatewayNetworkRequest( + request: UpdateGatewayNetworkRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.enable_masquerade is not None: + output["enable_masquerade"] = request.enable_masquerade + + if request.push_default_route is not None: + output["push_default_route"] = request.push_default_route + + if request.ipam_ip_id is not None: + output["ipam_ip_id"] = request.ipam_ip_id + + return output + + +def marshal_UpdateGatewayRequest( + request: UpdateGatewayRequest, + 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.enable_bastion is not None: + output["enable_bastion"] = request.enable_bastion + + if request.bastion_port is not None: + output["bastion_port"] = request.bastion_port + + if request.enable_smtp is not None: + output["enable_smtp"] = request.enable_smtp + + return output + + +def marshal_UpdateIPRequest( + request: UpdateIPRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.tags is not None: + output["tags"] = request.tags + + if request.reverse is not None: + output["reverse"] = request.reverse + + if request.gateway_id is not None: + output["gateway_id"] = request.gateway_id + + return output + + +def marshal_UpdatePatRuleRequest( + request: UpdatePatRuleRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.public_port is not None: + output["public_port"] = request.public_port + + if request.private_ip is not None: + output["private_ip"] = request.private_ip + + if request.private_port is not None: + output["private_port"] = request.private_port + + if request.protocol is not None: + output["protocol"] = str(request.protocol) + + return output + + +def marshal_UpgradeGatewayRequest( + request: UpgradeGatewayRequest, + defaults: ProfileDefaults, +) -> Dict[str, Any]: + output: Dict[str, Any] = {} + + if request.type_ is not None: + output["type"] = request.type_ + + return output diff --git a/scaleway/scaleway/vpcgw/v2/types.py b/scaleway/scaleway/vpcgw/v2/types.py new file mode 100644 index 000000000..9bcf99b86 --- /dev/null +++ b/scaleway/scaleway/vpcgw/v2/types.py @@ -0,0 +1,1081 @@ +# This file was automatically generated. DO NOT EDIT. +# If you have any remark or suggestion do not hesitate to open an issue. +from __future__ import annotations + +from dataclasses import dataclass +from datetime import datetime +from enum import Enum +from typing import List, Optional + +from scaleway_core.bridge import ( + Zone, +) +from scaleway_core.utils import ( + StrEnumMeta, +) + + +class GatewayNetworkStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + CREATED = "created" + ATTACHING = "attaching" + CONFIGURING = "configuring" + READY = "ready" + DETACHING = "detaching" + + def __str__(self) -> str: + return str(self.value) + + +class GatewayStatus(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_STATUS = "unknown_status" + STOPPED = "stopped" + ALLOCATING = "allocating" + CONFIGURING = "configuring" + RUNNING = "running" + STOPPING = "stopping" + FAILED = "failed" + DELETING = "deleting" + LOCKED = "locked" + + def __str__(self) -> str: + return str(self.value) + + +class ListGatewayNetworksRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + STATUS_ASC = "status_asc" + STATUS_DESC = "status_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListGatewaysRequestOrderBy(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 ListIPsRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + ADDRESS_ASC = "address_asc" + ADDRESS_DESC = "address_desc" + REVERSE_ASC = "reverse_asc" + REVERSE_DESC = "reverse_desc" + + def __str__(self) -> str: + return str(self.value) + + +class ListPatRulesRequestOrderBy(str, Enum, metaclass=StrEnumMeta): + CREATED_AT_ASC = "created_at_asc" + CREATED_AT_DESC = "created_at_desc" + PUBLIC_PORT_ASC = "public_port_asc" + PUBLIC_PORT_DESC = "public_port_desc" + + def __str__(self) -> str: + return str(self.value) + + +class PatRuleProtocol(str, Enum, metaclass=StrEnumMeta): + UNKNOWN_PROTOCOL = "unknown_protocol" + BOTH = "both" + TCP = "tcp" + UDP = "udp" + + def __str__(self) -> str: + return str(self.value) + + +@dataclass +class GatewayNetwork: + id: str + """ + ID of the Public Gateway-Private Network connection. + """ + + gateway_id: str + """ + ID of the connected Public Gateway. + """ + + private_network_id: str + """ + ID of the connected Private Network. + """ + + masquerade_enabled: bool + """ + Defines whether the gateway masquerades traffic for this Private Network (Dynamic NAT). + """ + + status: GatewayNetworkStatus + """ + Current status of the Public Gateway's connection to the Private Network. + """ + + push_default_route: bool + """ + Enabling the default route also enables masquerading. + """ + + ipam_ip_id: str + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + zone: Zone + """ + Zone of the GatewayNetwork connection. + """ + + created_at: Optional[datetime] + """ + Connection creation date. + """ + + updated_at: Optional[datetime] + """ + Connection last modification date. + """ + + mac_address: Optional[str] + """ + MAC address of the gateway in the Private Network (if the gateway is up and running). + """ + + +@dataclass +class IP: + id: str + """ + IP address ID. + """ + + organization_id: str + """ + Owning Organization. + """ + + project_id: str + """ + Owning Project. + """ + + tags: List[str] + """ + Tags associated with the IP address. + """ + + address: str + """ + The IP address itself. + """ + + zone: Zone + """ + Zone of the IP address. + """ + + created_at: Optional[datetime] + """ + IP address creation date. + """ + + updated_at: Optional[datetime] + """ + IP address last modification date. + """ + + reverse: Optional[str] + """ + Reverse domain name for the IP address. + """ + + gateway_id: Optional[str] + """ + Public Gateway associated with the IP address. + """ + + +@dataclass +class GatewayType: + name: str + """ + Public Gateway type name. + """ + + bandwidth: int + """ + Bandwidth, in bps, of the Public Gateway. This is the public bandwidth to the outer Internet, and the internal bandwidth to each connected Private Networks. + """ + + zone: Zone + """ + Zone the Public Gateway type is available in. + """ + + +@dataclass +class Gateway: + id: str + """ + ID of the gateway. + """ + + organization_id: str + """ + Owning Organization. + """ + + project_id: str + """ + Owning Project. + """ + + type_: str + """ + Gateway type name (commercial offer). + """ + + bandwidth: int + """ + Bandwidth available of the gateway. + """ + + status: GatewayStatus + """ + Current status of the gateway. + """ + + created_at: Optional[datetime] + """ + Gateway creation date. + """ + + updated_at: Optional[datetime] + """ + Gateway last modification date. + """ + + name: str + """ + Name of the gateway. + """ + + tags: List[str] + """ + Tags associated with the gateway. + """ + + gateway_networks: List[GatewayNetwork] + """ + GatewayNetwork objects attached to the gateway (each one represents a connection to a Private Network). + """ + + bastion_enabled: bool + """ + Defines whether SSH bastion is enabled on the gateway. + """ + + bastion_port: int + """ + Port of the SSH bastion. + """ + + smtp_enabled: bool + """ + Defines whether SMTP traffic is allowed to pass through the gateway. + """ + + is_legacy: bool + """ + Defines whether the gateway uses non-IPAM IP configurations. + """ + + zone: Zone + """ + Zone of the gateway. + """ + + ipv4: Optional[IP] + """ + Public IPv4 address of the gateway. + """ + + version: Optional[str] + """ + Version of the running gateway software. + """ + + can_upgrade_to: Optional[str] + """ + Newly available gateway software version that can be updated to. + """ + + +@dataclass +class PatRule: + id: str + """ + PAT rule ID. + """ + + gateway_id: str + """ + Gateway the PAT rule applies to. + """ + + public_port: int + """ + Public port to listen on. + """ + + private_ip: str + """ + Private IP address to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + protocol: PatRuleProtocol + """ + Protocol the rule applies to. + """ + + zone: Zone + """ + Zone of the PAT rule. + """ + + created_at: Optional[datetime] + """ + PAT rule creation date. + """ + + updated_at: Optional[datetime] + """ + PAT rule last modification date. + """ + + +@dataclass +class SetPatRulesRequestRule: + public_port: int + """ + Public port to listen on. Uniquely identifies the rule, and a matching rule will be updated with the new parameters. + """ + + private_ip: str + """ + Private IP to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + protocol: PatRuleProtocol + """ + Protocol the rule should apply to. + """ + + +@dataclass +class CreateGatewayNetworkRequest: + gateway_id: str + """ + Public Gateway to connect. + """ + + private_network_id: str + """ + Private Network to connect. + """ + + enable_masquerade: bool + """ + Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + """ + + push_default_route: bool + """ + Enabling the default route also enables masquerading. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + ipam_ip_id: Optional[str] + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + +@dataclass +class CreateGatewayRequest: + type_: str + """ + Gateway type (commercial offer type). + """ + + enable_smtp: bool + """ + Defines whether SMTP traffic should be allowed pass through the gateway. + """ + + enable_bastion: bool + """ + Defines whether SSH bastion should be enabled the gateway. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Scaleway Project to create the gateway in. + """ + + name: Optional[str] + """ + Name for the gateway. + """ + + tags: Optional[List[str]] + """ + Tags for the gateway. + """ + + ip_id: Optional[str] + """ + Existing IP address to attach to the gateway. + """ + + bastion_port: Optional[int] + """ + Port of the SSH bastion. + """ + + +@dataclass +class CreateIPRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + project_id: Optional[str] + """ + Project to create the IP address in. + """ + + tags: Optional[List[str]] + """ + Tags to give to the IP address. + """ + + +@dataclass +class CreatePatRuleRequest: + gateway_id: str + """ + ID of the Gateway on which to create the rule. + """ + + public_port: int + """ + Public port to listen on. + """ + + private_ip: str + """ + Private IP to forward data to. + """ + + private_port: int + """ + Private port to translate to. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + protocol: Optional[PatRuleProtocol] + """ + Protocol the rule should apply to. + """ + + +@dataclass +class DeleteGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeleteGatewayRequest: + gateway_id: str + """ + ID of the gateway to delete. + """ + + delete_ip: bool + """ + Defines whether the PGW's IP should be deleted. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeleteIPRequest: + ip_id: str + """ + ID of the IP address to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class DeletePatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to delete. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to fetch. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetGatewayRequest: + gateway_id: str + """ + ID of the gateway to fetch. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetIPRequest: + ip_id: str + """ + ID of the IP address to get. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class GetPatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to get. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class ListGatewayNetworksRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListGatewayNetworksRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + GatewayNetworks per page. + """ + + status: Optional[List[GatewayNetworkStatus]] + """ + Filter for GatewayNetworks with these status. Use `unknown` to include all statuses. + """ + + gateway_ids: Optional[List[str]] + """ + Filter for GatewayNetworks connected to these gateways. + """ + + private_network_ids: Optional[List[str]] + """ + Filter for GatewayNetworks connected to these Private Networks. + """ + + masquerade_enabled: Optional[bool] + """ + Filter for GatewayNetworks with this `enable_masquerade` setting. + """ + + +@dataclass +class ListGatewayNetworksResponse: + gateway_networks: List[GatewayNetwork] + """ + GatewayNetworks on this page. + """ + + total_count: int + """ + Total GatewayNetworks count matching the filter. + """ + + +@dataclass +class ListGatewayTypesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class ListGatewayTypesResponse: + types: List[GatewayType] + """ + Available types of Public Gateway. + """ + + +@dataclass +class ListGatewaysRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListGatewaysRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number to return. + """ + + page_size: Optional[int] + """ + Gateways per page. + """ + + organization_id: Optional[str] + """ + Include only gateways in this Organization. + """ + + project_id: Optional[str] + """ + Include only gateways in this Project. + """ + + name: Optional[str] + """ + Filter for gateways which have this search term in their name. + """ + + tags: Optional[List[str]] + """ + Filter for gateways with these tags. + """ + + types: Optional[List[str]] + """ + Filter for gateways of these types. + """ + + status: Optional[List[GatewayStatus]] + """ + Filter for gateways with these status. Use `unknown` to include all statuses. + """ + + private_network_ids: Optional[List[str]] + """ + Filter for gateways attached to these Private Networks. + """ + + include_legacy: Optional[bool] + """ + Include also legacy gateways. + """ + + +@dataclass +class ListGatewaysResponse: + gateways: List[Gateway] + """ + Gateways on this page. + """ + + total_count: int + """ + Total count of gateways matching the filter. + """ + + +@dataclass +class ListIPsRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListIPsRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + IP addresses per page. + """ + + organization_id: Optional[str] + """ + Include only gateways in this Organization. + """ + + project_id: Optional[str] + """ + Filter for IP addresses in this Project. + """ + + tags: Optional[List[str]] + """ + Filter for IP addresses with these tags. + """ + + reverse: Optional[str] + """ + Filter for IP addresses that have a reverse containing this string. + """ + + is_free: Optional[bool] + """ + Filter based on whether the IP is attached to a gateway or not. + """ + + +@dataclass +class ListIPsResponse: + ips: List[IP] + """ + IP addresses on this page. + """ + + total_count: int + """ + Total count of IP addresses matching the filter. + """ + + +@dataclass +class ListPatRulesRequest: + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + order_by: Optional[ListPatRulesRequestOrderBy] + """ + Order in which to return results. + """ + + page: Optional[int] + """ + Page number. + """ + + page_size: Optional[int] + """ + PAT rules per page. + """ + + gateway_ids: Optional[List[str]] + """ + Filter for PAT rules on these gateways. + """ + + private_ips: Optional[List[str]] + """ + Filter for PAT rules targeting these private ips. + """ + + protocol: Optional[PatRuleProtocol] + """ + Filter for PAT rules with this protocol. + """ + + +@dataclass +class ListPatRulesResponse: + pat_rules: List[PatRule] + """ + Array of PAT rules matching the filter. + """ + + total_count: int + """ + Total count of PAT rules matching the filter. + """ + + +@dataclass +class RefreshSSHKeysRequest: + gateway_id: str + """ + ID of the gateway to refresh SSH keys on. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class SetPatRulesRequest: + gateway_id: str + """ + ID of the gateway on which to set the PAT rules. + """ + + pat_rules: List[SetPatRulesRequestRule] + """ + New list of PAT rules. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + +@dataclass +class SetPatRulesResponse: + pat_rules: List[PatRule] + """ + List of PAT rules. + """ + + +@dataclass +class UpdateGatewayNetworkRequest: + gateway_network_id: str + """ + ID of the GatewayNetwork to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + enable_masquerade: Optional[bool] + """ + Defines whether to enable masquerade (dynamic NAT) on the GatewayNetwork. + """ + + push_default_route: Optional[bool] + """ + Enabling the default route also enables masquerading. + """ + + ipam_ip_id: Optional[str] + """ + Use this IPAM-booked IP ID as the Gateway's IP in this Private Network. + """ + + +@dataclass +class UpdateGatewayRequest: + gateway_id: str + """ + ID of the gateway to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + name: Optional[str] + """ + Name for the gateway. + """ + + tags: Optional[List[str]] + """ + Tags for the gateway. + """ + + enable_bastion: Optional[bool] + """ + Defines whether SSH bastion should be enabled the gateway. + """ + + bastion_port: Optional[int] + """ + Port of the SSH bastion. + """ + + enable_smtp: Optional[bool] + """ + Defines whether SMTP traffic should be allowed to pass through the gateway. + """ + + +@dataclass +class UpdateIPRequest: + ip_id: str + """ + ID of the IP address to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + tags: Optional[List[str]] + """ + Tags to give to the IP address. + """ + + reverse: Optional[str] + """ + Reverse to set on the address. Empty string to unset. + """ + + gateway_id: Optional[str] + """ + Gateway to attach the IP address to. Empty string to detach. + """ + + +@dataclass +class UpdatePatRuleRequest: + pat_rule_id: str + """ + ID of the PAT rule to update. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + public_port: Optional[int] + """ + Public port to listen on. + """ + + private_ip: Optional[str] + """ + Private IP to forward data to. + """ + + private_port: Optional[int] + """ + Private port to translate to. + """ + + protocol: Optional[PatRuleProtocol] + """ + Protocol the rule should apply to. + """ + + +@dataclass +class UpgradeGatewayRequest: + gateway_id: str + """ + ID of the gateway to upgrade. + """ + + zone: Optional[Zone] + """ + Zone to target. If none is passed will use default zone from the config. + """ + + type_: Optional[str] + """ + Gateway type (commercial offer). + """