Skip to content

Commit a8064cb

Browse files
authored
feat(vpc): enable call to enable vpc custom routes and pn default route propagation as unlisted (#1011)
1 parent 7eca644 commit a8064cb

File tree

8 files changed

+118
-0
lines changed

8 files changed

+118
-0
lines changed

scaleway-async/scaleway_async/vpc/v2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .types import DeleteSubnetsRequest
2121
from .types import DeleteSubnetsResponse
2222
from .types import DeleteVPCRequest
23+
from .types import EnableCustomRoutesPropagationRequest
2324
from .types import EnableDHCPRequest
2425
from .types import EnableRoutingRequest
2526
from .types import GetAclRequest
@@ -61,6 +62,7 @@
6162
"DeleteSubnetsRequest",
6263
"DeleteSubnetsResponse",
6364
"DeleteVPCRequest",
65+
"EnableCustomRoutesPropagationRequest",
6466
"EnableDHCPRequest",
6567
"EnableRoutingRequest",
6668
"GetAclRequest",

scaleway-async/scaleway_async/vpc/v2/api.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,41 @@ async def enable_routing(
708708
self._throw_on_error(res)
709709
return unmarshal_VPC(res.json())
710710

711+
async def enable_custom_routes_propagation(
712+
self,
713+
*,
714+
vpc_id: str,
715+
region: Optional[ScwRegion] = None,
716+
) -> VPC:
717+
"""
718+
Enable custom routes propagation on a VPC.
719+
Enable custom routes propagation on an existing VPC. Note that you will not be able to deactivate it afterwards.
720+
:param vpc_id: VPC ID.
721+
:param region: Region to target. If none is passed will use default region from the config.
722+
:return: :class:`VPC <VPC>`
723+
724+
Usage:
725+
::
726+
727+
result = await api.enable_custom_routes_propagation(
728+
vpc_id="example",
729+
)
730+
"""
731+
732+
param_region = validate_path_param(
733+
"region", region or self.client.default_region
734+
)
735+
param_vpc_id = validate_path_param("vpc_id", vpc_id)
736+
737+
res = self._request(
738+
"POST",
739+
f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-custom-routes-propagation",
740+
body={},
741+
)
742+
743+
self._throw_on_error(res)
744+
return unmarshal_VPC(res.json())
745+
711746
async def list_subnets(
712747
self,
713748
*,

scaleway-async/scaleway_async/vpc/v2/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ def unmarshal_VPC(data: Any) -> VPC:
245245
if field is not None:
246246
args["routing_enabled"] = field
247247

248+
field = data.get("custom_routes_propagation_enabled", None)
249+
if field is not None:
250+
args["custom_routes_propagation_enabled"] = field
251+
248252
field = data.get("created_at", None)
249253
if field is not None:
250254
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field

scaleway-async/scaleway_async/vpc/v2/types.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ class VPC:
316316
Defines whether the VPC routes traffic between its Private Networks.
317317
"""
318318

319+
custom_routes_propagation_enabled: bool
320+
"""
321+
Defines whether the VPC advertises custom routes between its Private Networks.
322+
"""
323+
319324
created_at: Optional[datetime]
320325
"""
321326
Date the VPC was created.
@@ -516,6 +521,19 @@ class DeleteVPCRequest:
516521
"""
517522

518523

524+
@dataclass
525+
class EnableCustomRoutesPropagationRequest:
526+
vpc_id: str
527+
"""
528+
VPC ID.
529+
"""
530+
531+
region: Optional[ScwRegion]
532+
"""
533+
Region to target. If none is passed will use default region from the config.
534+
"""
535+
536+
519537
@dataclass
520538
class EnableDHCPRequest:
521539
private_network_id: str

scaleway/scaleway/vpc/v2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from .types import DeleteSubnetsRequest
2121
from .types import DeleteSubnetsResponse
2222
from .types import DeleteVPCRequest
23+
from .types import EnableCustomRoutesPropagationRequest
2324
from .types import EnableDHCPRequest
2425
from .types import EnableRoutingRequest
2526
from .types import GetAclRequest
@@ -61,6 +62,7 @@
6162
"DeleteSubnetsRequest",
6263
"DeleteSubnetsResponse",
6364
"DeleteVPCRequest",
65+
"EnableCustomRoutesPropagationRequest",
6466
"EnableDHCPRequest",
6567
"EnableRoutingRequest",
6668
"GetAclRequest",

scaleway/scaleway/vpc/v2/api.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,41 @@ def enable_routing(
708708
self._throw_on_error(res)
709709
return unmarshal_VPC(res.json())
710710

711+
def enable_custom_routes_propagation(
712+
self,
713+
*,
714+
vpc_id: str,
715+
region: Optional[ScwRegion] = None,
716+
) -> VPC:
717+
"""
718+
Enable custom routes propagation on a VPC.
719+
Enable custom routes propagation on an existing VPC. Note that you will not be able to deactivate it afterwards.
720+
:param vpc_id: VPC ID.
721+
:param region: Region to target. If none is passed will use default region from the config.
722+
:return: :class:`VPC <VPC>`
723+
724+
Usage:
725+
::
726+
727+
result = api.enable_custom_routes_propagation(
728+
vpc_id="example",
729+
)
730+
"""
731+
732+
param_region = validate_path_param(
733+
"region", region or self.client.default_region
734+
)
735+
param_vpc_id = validate_path_param("vpc_id", vpc_id)
736+
737+
res = self._request(
738+
"POST",
739+
f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-custom-routes-propagation",
740+
body={},
741+
)
742+
743+
self._throw_on_error(res)
744+
return unmarshal_VPC(res.json())
745+
711746
def list_subnets(
712747
self,
713748
*,

scaleway/scaleway/vpc/v2/marshalling.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,10 @@ def unmarshal_VPC(data: Any) -> VPC:
245245
if field is not None:
246246
args["routing_enabled"] = field
247247

248+
field = data.get("custom_routes_propagation_enabled", None)
249+
if field is not None:
250+
args["custom_routes_propagation_enabled"] = field
251+
248252
field = data.get("created_at", None)
249253
if field is not None:
250254
args["created_at"] = parser.isoparse(field) if isinstance(field, str) else field

scaleway/scaleway/vpc/v2/types.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,11 @@ class VPC:
316316
Defines whether the VPC routes traffic between its Private Networks.
317317
"""
318318

319+
custom_routes_propagation_enabled: bool
320+
"""
321+
Defines whether the VPC advertises custom routes between its Private Networks.
322+
"""
323+
319324
created_at: Optional[datetime]
320325
"""
321326
Date the VPC was created.
@@ -516,6 +521,19 @@ class DeleteVPCRequest:
516521
"""
517522

518523

524+
@dataclass
525+
class EnableCustomRoutesPropagationRequest:
526+
vpc_id: str
527+
"""
528+
VPC ID.
529+
"""
530+
531+
region: Optional[ScwRegion]
532+
"""
533+
Region to target. If none is passed will use default region from the config.
534+
"""
535+
536+
519537
@dataclass
520538
class EnableDHCPRequest:
521539
private_network_id: str

0 commit comments

Comments
 (0)