Skip to content

Commit cd40693

Browse files
authored
feat(vpc/v2): allow routing activation on existing VPCs (#484)
1 parent ca1835c commit cd40693

File tree

6 files changed

+94
-0
lines changed

6 files changed

+94
-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
@@ -14,6 +14,7 @@
1414
from .types import DeleteSubnetsResponse
1515
from .types import DeleteVPCRequest
1616
from .types import EnableDHCPRequest
17+
from .types import EnableRoutingRequest
1718
from .types import GetPrivateNetworkRequest
1819
from .types import GetVPCRequest
1920
from .types import ListPrivateNetworksRequest
@@ -42,6 +43,7 @@
4243
"DeleteSubnetsResponse",
4344
"DeleteVPCRequest",
4445
"EnableDHCPRequest",
46+
"EnableRoutingRequest",
4547
"GetPrivateNetworkRequest",
4648
"GetVPCRequest",
4749
"ListPrivateNetworksRequest",

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,41 @@ async def enable_dhcp(
697697
self._throw_on_error(res)
698698
return unmarshal_PrivateNetwork(res.json())
699699

700+
async def enable_routing(
701+
self,
702+
*,
703+
vpc_id: str,
704+
region: Optional[Region] = None,
705+
) -> VPC:
706+
"""
707+
Enable routing on a VPC.
708+
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
709+
:param vpc_id:
710+
:param region: Region to target. If none is passed will use default region from the config.
711+
:return: :class:`VPC <VPC>`
712+
713+
Usage:
714+
::
715+
716+
result = await api.enable_routing(
717+
vpc_id="example",
718+
)
719+
"""
720+
721+
param_region = validate_path_param(
722+
"region", region or self.client.default_region
723+
)
724+
param_vpc_id = validate_path_param("vpc_id", vpc_id)
725+
726+
res = self._request(
727+
"POST",
728+
f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-routing",
729+
body={},
730+
)
731+
732+
self._throw_on_error(res)
733+
return unmarshal_VPC(res.json())
734+
700735
async def set_subnets(
701736
self,
702737
*,

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@ class EnableDHCPRequest:
320320
"""
321321

322322

323+
@dataclass
324+
class EnableRoutingRequest:
325+
vpc_id: str
326+
327+
region: Optional[Region]
328+
"""
329+
Region to target. If none is passed will use default region from the config.
330+
"""
331+
332+
323333
@dataclass
324334
class GetPrivateNetworkRequest:
325335
private_network_id: str

scaleway/scaleway/vpc/v2/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
from .types import DeleteSubnetsResponse
1515
from .types import DeleteVPCRequest
1616
from .types import EnableDHCPRequest
17+
from .types import EnableRoutingRequest
1718
from .types import GetPrivateNetworkRequest
1819
from .types import GetVPCRequest
1920
from .types import ListPrivateNetworksRequest
@@ -42,6 +43,7 @@
4243
"DeleteSubnetsResponse",
4344
"DeleteVPCRequest",
4445
"EnableDHCPRequest",
46+
"EnableRoutingRequest",
4547
"GetPrivateNetworkRequest",
4648
"GetVPCRequest",
4749
"ListPrivateNetworksRequest",

scaleway/scaleway/vpc/v2/api.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,41 @@ def enable_dhcp(
697697
self._throw_on_error(res)
698698
return unmarshal_PrivateNetwork(res.json())
699699

700+
def enable_routing(
701+
self,
702+
*,
703+
vpc_id: str,
704+
region: Optional[Region] = None,
705+
) -> VPC:
706+
"""
707+
Enable routing on a VPC.
708+
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
709+
:param vpc_id:
710+
:param region: Region to target. If none is passed will use default region from the config.
711+
:return: :class:`VPC <VPC>`
712+
713+
Usage:
714+
::
715+
716+
result = api.enable_routing(
717+
vpc_id="example",
718+
)
719+
"""
720+
721+
param_region = validate_path_param(
722+
"region", region or self.client.default_region
723+
)
724+
param_vpc_id = validate_path_param("vpc_id", vpc_id)
725+
726+
res = self._request(
727+
"POST",
728+
f"/vpc/v2/regions/{param_region}/vpcs/{param_vpc_id}/enable-routing",
729+
body={},
730+
)
731+
732+
self._throw_on_error(res)
733+
return unmarshal_VPC(res.json())
734+
700735
def set_subnets(
701736
self,
702737
*,

scaleway/scaleway/vpc/v2/types.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,16 @@ class EnableDHCPRequest:
320320
"""
321321

322322

323+
@dataclass
324+
class EnableRoutingRequest:
325+
vpc_id: str
326+
327+
region: Optional[Region]
328+
"""
329+
Region to target. If none is passed will use default region from the config.
330+
"""
331+
332+
323333
@dataclass
324334
class GetPrivateNetworkRequest:
325335
private_network_id: str

0 commit comments

Comments
 (0)