diff --git a/scaleway-async/scaleway_async/vpc/v2/__init__.py b/scaleway-async/scaleway_async/vpc/v2/__init__.py index 81cbc5da6..991e09457 100644 --- a/scaleway-async/scaleway_async/vpc/v2/__init__.py +++ b/scaleway-async/scaleway_async/vpc/v2/__init__.py @@ -20,6 +20,7 @@ from .types import DeleteSubnetsRequest from .types import DeleteSubnetsResponse from .types import DeleteVPCRequest +from .types import EnableCustomRoutesPropagationRequest from .types import EnableDHCPRequest from .types import EnableRoutingRequest from .types import GetAclRequest @@ -61,6 +62,7 @@ "DeleteSubnetsRequest", "DeleteSubnetsResponse", "DeleteVPCRequest", + "EnableCustomRoutesPropagationRequest", "EnableDHCPRequest", "EnableRoutingRequest", "GetAclRequest", diff --git a/scaleway-async/scaleway_async/vpc/v2/api.py b/scaleway-async/scaleway_async/vpc/v2/api.py index c76c382d4..791b04991 100644 --- a/scaleway-async/scaleway_async/vpc/v2/api.py +++ b/scaleway-async/scaleway_async/vpc/v2/api.py @@ -708,6 +708,41 @@ async def enable_routing( self._throw_on_error(res) return unmarshal_VPC(res.json()) + async def enable_custom_routes_propagation( + self, + *, + vpc_id: str, + region: Optional[ScwRegion] = None, + ) -> VPC: + """ + Enable custom routes propagation on a VPC. + Enable custom routes propagation on an existing VPC. Note that you will not be able to deactivate it afterwards. + :param vpc_id: VPC ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VPC ` + + Usage: + :: + + result = await api.enable_custom_routes_propagation( + vpc_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_vpc_id = validate_path_param("vpc_id", vpc_id) + + res = self._request( + "POST", + f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-custom-routes-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_VPC(res.json()) + async def list_subnets( self, *, diff --git a/scaleway-async/scaleway_async/vpc/v2/marshalling.py b/scaleway-async/scaleway_async/vpc/v2/marshalling.py index 9229bba7c..edbc3275a 100644 --- a/scaleway-async/scaleway_async/vpc/v2/marshalling.py +++ b/scaleway-async/scaleway_async/vpc/v2/marshalling.py @@ -245,6 +245,10 @@ def unmarshal_VPC(data: Any) -> VPC: if field is not None: args["routing_enabled"] = field + field = data.get("custom_routes_propagation_enabled", None) + if field is not None: + args["custom_routes_propagation_enabled"] = field + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field diff --git a/scaleway-async/scaleway_async/vpc/v2/types.py b/scaleway-async/scaleway_async/vpc/v2/types.py index 09a065708..0185930b1 100644 --- a/scaleway-async/scaleway_async/vpc/v2/types.py +++ b/scaleway-async/scaleway_async/vpc/v2/types.py @@ -316,6 +316,11 @@ class VPC: Defines whether the VPC routes traffic between its Private Networks. """ + custom_routes_propagation_enabled: bool + """ + Defines whether the VPC advertises custom routes between its Private Networks. + """ + created_at: Optional[datetime] """ Date the VPC was created. @@ -516,6 +521,19 @@ class DeleteVPCRequest: """ +@dataclass +class EnableCustomRoutesPropagationRequest: + vpc_id: str + """ + VPC ID. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class EnableDHCPRequest: private_network_id: str diff --git a/scaleway/scaleway/vpc/v2/__init__.py b/scaleway/scaleway/vpc/v2/__init__.py index 81cbc5da6..991e09457 100644 --- a/scaleway/scaleway/vpc/v2/__init__.py +++ b/scaleway/scaleway/vpc/v2/__init__.py @@ -20,6 +20,7 @@ from .types import DeleteSubnetsRequest from .types import DeleteSubnetsResponse from .types import DeleteVPCRequest +from .types import EnableCustomRoutesPropagationRequest from .types import EnableDHCPRequest from .types import EnableRoutingRequest from .types import GetAclRequest @@ -61,6 +62,7 @@ "DeleteSubnetsRequest", "DeleteSubnetsResponse", "DeleteVPCRequest", + "EnableCustomRoutesPropagationRequest", "EnableDHCPRequest", "EnableRoutingRequest", "GetAclRequest", diff --git a/scaleway/scaleway/vpc/v2/api.py b/scaleway/scaleway/vpc/v2/api.py index ac1a6e00b..5c819f99b 100644 --- a/scaleway/scaleway/vpc/v2/api.py +++ b/scaleway/scaleway/vpc/v2/api.py @@ -708,6 +708,41 @@ def enable_routing( self._throw_on_error(res) return unmarshal_VPC(res.json()) + def enable_custom_routes_propagation( + self, + *, + vpc_id: str, + region: Optional[ScwRegion] = None, + ) -> VPC: + """ + Enable custom routes propagation on a VPC. + Enable custom routes propagation on an existing VPC. Note that you will not be able to deactivate it afterwards. + :param vpc_id: VPC ID. + :param region: Region to target. If none is passed will use default region from the config. + :return: :class:`VPC ` + + Usage: + :: + + result = api.enable_custom_routes_propagation( + vpc_id="example", + ) + """ + + param_region = validate_path_param( + "region", region or self.client.default_region + ) + param_vpc_id = validate_path_param("vpc_id", vpc_id) + + res = self._request( + "POST", + f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-custom-routes-propagation", + body={}, + ) + + self._throw_on_error(res) + return unmarshal_VPC(res.json()) + def list_subnets( self, *, diff --git a/scaleway/scaleway/vpc/v2/marshalling.py b/scaleway/scaleway/vpc/v2/marshalling.py index 9229bba7c..edbc3275a 100644 --- a/scaleway/scaleway/vpc/v2/marshalling.py +++ b/scaleway/scaleway/vpc/v2/marshalling.py @@ -245,6 +245,10 @@ def unmarshal_VPC(data: Any) -> VPC: if field is not None: args["routing_enabled"] = field + field = data.get("custom_routes_propagation_enabled", None) + if field is not None: + args["custom_routes_propagation_enabled"] = field + field = data.get("created_at", None) if field is not None: args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field diff --git a/scaleway/scaleway/vpc/v2/types.py b/scaleway/scaleway/vpc/v2/types.py index 09a065708..0185930b1 100644 --- a/scaleway/scaleway/vpc/v2/types.py +++ b/scaleway/scaleway/vpc/v2/types.py @@ -316,6 +316,11 @@ class VPC: Defines whether the VPC routes traffic between its Private Networks. """ + custom_routes_propagation_enabled: bool + """ + Defines whether the VPC advertises custom routes between its Private Networks. + """ + created_at: Optional[datetime] """ Date the VPC was created. @@ -516,6 +521,19 @@ class DeleteVPCRequest: """ +@dataclass +class EnableCustomRoutesPropagationRequest: + vpc_id: str + """ + VPC ID. + """ + + region: Optional[ScwRegion] + """ + Region to target. If none is passed will use default region from the config. + """ + + @dataclass class EnableDHCPRequest: private_network_id: str