Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(vpc/v2): allow routing activation on existing VPCs #484

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions scaleway-async/scaleway_async/vpc/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .types import DeleteSubnetsResponse
from .types import DeleteVPCRequest
from .types import EnableDHCPRequest
from .types import EnableRoutingRequest
from .types import GetPrivateNetworkRequest
from .types import GetVPCRequest
from .types import ListPrivateNetworksRequest
Expand Down Expand Up @@ -42,6 +43,7 @@
"DeleteSubnetsResponse",
"DeleteVPCRequest",
"EnableDHCPRequest",
"EnableRoutingRequest",
"GetPrivateNetworkRequest",
"GetVPCRequest",
"ListPrivateNetworksRequest",
Expand Down
35 changes: 35 additions & 0 deletions scaleway-async/scaleway_async/vpc/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,41 @@ async def enable_dhcp(
self._throw_on_error(res)
return unmarshal_PrivateNetwork(res.json())

async def enable_routing(
self,
*,
vpc_id: str,
region: Optional[Region] = None,
) -> VPC:
"""
Enable routing on a VPC.
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
:param vpc_id:
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`VPC <VPC>`

Usage:
::

result = await api.enable_routing(
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-routing",
body={},
)

self._throw_on_error(res)
return unmarshal_VPC(res.json())

async def set_subnets(
self,
*,
Expand Down
10 changes: 10 additions & 0 deletions scaleway-async/scaleway_async/vpc/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@ class EnableDHCPRequest:
"""


@dataclass
class EnableRoutingRequest:
vpc_id: str

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class GetPrivateNetworkRequest:
private_network_id: str
Expand Down
2 changes: 2 additions & 0 deletions scaleway/scaleway/vpc/v2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from .types import DeleteSubnetsResponse
from .types import DeleteVPCRequest
from .types import EnableDHCPRequest
from .types import EnableRoutingRequest
from .types import GetPrivateNetworkRequest
from .types import GetVPCRequest
from .types import ListPrivateNetworksRequest
Expand Down Expand Up @@ -42,6 +43,7 @@
"DeleteSubnetsResponse",
"DeleteVPCRequest",
"EnableDHCPRequest",
"EnableRoutingRequest",
"GetPrivateNetworkRequest",
"GetVPCRequest",
"ListPrivateNetworksRequest",
Expand Down
35 changes: 35 additions & 0 deletions scaleway/scaleway/vpc/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,41 @@ def enable_dhcp(
self._throw_on_error(res)
return unmarshal_PrivateNetwork(res.json())

def enable_routing(
self,
*,
vpc_id: str,
region: Optional[Region] = None,
) -> VPC:
"""
Enable routing on a VPC.
Enable routing on an existing VPC. Note that you will not be able to deactivate it afterwards.
:param vpc_id:
:param region: Region to target. If none is passed will use default region from the config.
:return: :class:`VPC <VPC>`

Usage:
::

result = api.enable_routing(
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-routing",
body={},
)

self._throw_on_error(res)
return unmarshal_VPC(res.json())

def set_subnets(
self,
*,
Expand Down
10 changes: 10 additions & 0 deletions scaleway/scaleway/vpc/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@ class EnableDHCPRequest:
"""


@dataclass
class EnableRoutingRequest:
vpc_id: str

region: Optional[Region]
"""
Region to target. If none is passed will use default region from the config.
"""


@dataclass
class GetPrivateNetworkRequest:
private_network_id: str
Expand Down