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): add property to enable or disable routing in a VPC #448

Merged
merged 1 commit into from
Feb 29, 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
11 changes: 10 additions & 1 deletion scaleway-async/scaleway_async/vpc/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ async def list_vp_cs(
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
is_default: Optional[bool] = None,
routing_enabled: Optional[bool] = None,
) -> ListVPCsResponse:
"""
List VPCs.
Expand All @@ -82,6 +83,7 @@ async def list_vp_cs(
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
:return: :class:`ListVPCsResponse <ListVPCsResponse>`

Usage:
Expand All @@ -106,6 +108,7 @@ async def list_vp_cs(
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
"routing_enabled": routing_enabled,
"tags": tags,
},
)
Expand All @@ -125,6 +128,7 @@ async def list_vp_cs_all(
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
is_default: Optional[bool] = None,
routing_enabled: Optional[bool] = None,
) -> List[VPC]:
"""
List VPCs.
Expand All @@ -138,6 +142,7 @@ async def list_vp_cs_all(
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
:return: :class:`List[ListVPCsResponse] <List[ListVPCsResponse]>`

Usage:
Expand All @@ -160,12 +165,14 @@ async def list_vp_cs_all(
"organization_id": organization_id,
"project_id": project_id,
"is_default": is_default,
"routing_enabled": routing_enabled,
},
)

async def create_vpc(
self,
*,
enable_routing: bool,
region: Optional[Region] = None,
name: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -178,12 +185,13 @@ async def create_vpc(
:param name: Name for the VPC.
:param project_id: Scaleway Project in which to create the VPC.
:param tags: Tags for the VPC.
:param enable_routing: Enable routing between Private Networks in the VPC.
:return: :class:`VPC <VPC>`

Usage:
::

result = await api.create_vpc()
result = await api.create_vpc(enable_routing=True)
"""

param_region = validate_path_param(
Expand All @@ -195,6 +203,7 @@ async def create_vpc(
f"/vpc/v2/regions/{param_region}/vpcs",
body=marshal_CreateVPCRequest(
CreateVPCRequest(
enable_routing=enable_routing,
region=region,
name=name or random_name(prefix="vpc"),
project_id=project_id,
Expand Down
22 changes: 16 additions & 6 deletions scaleway-async/scaleway_async/vpc/v2/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def unmarshal_VPC(data: Any) -> VPC:
field = data.get("region", None)
args["region"] = field

field = data.get("routing_enabled", None)
args["routing_enabled"] = field

field = data.get("tags", None)
args["tags"] = field

Expand Down Expand Up @@ -259,6 +262,9 @@ def marshal_CreateVPCRequest(
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.enable_routing is not None:
output["enable_routing"] = request.enable_routing

if request.name is not None:
output["name"] = request.name

Expand Down Expand Up @@ -293,16 +299,20 @@ def marshal_MigrateZonalPrivateNetworksRequest(
[
OneOfPossibility(
"project_id",
request.project_id or defaults.default_project_id
if request.project_id is not None
else None,
(
request.project_id or defaults.default_project_id
if request.project_id is not None
else None
),
defaults.default_project_id,
),
OneOfPossibility(
"organization_id",
request.organization_id or defaults.default_organization_id
if request.organization_id is not None
else None,
(
request.organization_id or defaults.default_organization_id
if request.organization_id is not None
else None
),
defaults.default_organization_id,
),
]
Expand Down
15 changes: 15 additions & 0 deletions scaleway-async/scaleway_async/vpc/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ class VPC:
Number of Private Networks within this VPC.
"""

routing_enabled: bool
"""
Defines whether the VPC routes traffic between its Private Networks.
"""


@dataclass
class ListVPCsRequest:
Expand Down Expand Up @@ -257,6 +262,11 @@ class ListVPCsRequest:
Defines whether to filter only for VPCs which are the default one for their Project.
"""

routing_enabled: Optional[bool]
"""
Defines whether to filter only for VPCs which route traffic between their Private Networks.
"""


@dataclass
class CreateVPCRequest:
Expand All @@ -280,6 +290,11 @@ class CreateVPCRequest:
Tags for the VPC.
"""

enable_routing: bool
"""
Enable routing between Private Networks in the VPC.
"""


@dataclass
class GetVPCRequest:
Expand Down
11 changes: 10 additions & 1 deletion scaleway/scaleway/vpc/v2/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def list_vp_cs(
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
is_default: Optional[bool] = None,
routing_enabled: Optional[bool] = None,
) -> ListVPCsResponse:
"""
List VPCs.
Expand All @@ -82,6 +83,7 @@ def list_vp_cs(
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
:return: :class:`ListVPCsResponse <ListVPCsResponse>`

Usage:
Expand All @@ -106,6 +108,7 @@ def list_vp_cs(
"page": page,
"page_size": page_size or self.client.default_page_size,
"project_id": project_id or self.client.default_project_id,
"routing_enabled": routing_enabled,
"tags": tags,
},
)
Expand All @@ -125,6 +128,7 @@ def list_vp_cs_all(
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
is_default: Optional[bool] = None,
routing_enabled: Optional[bool] = None,
) -> List[VPC]:
"""
List VPCs.
Expand All @@ -138,6 +142,7 @@ def list_vp_cs_all(
:param organization_id: Organization ID to filter for. Only VPCs belonging to this Organization will be returned.
:param project_id: Project ID to filter for. Only VPCs belonging to this Project will be returned.
:param is_default: Defines whether to filter only for VPCs which are the default one for their Project.
:param routing_enabled: Defines whether to filter only for VPCs which route traffic between their Private Networks.
:return: :class:`List[ListVPCsResponse] <List[ListVPCsResponse]>`

Usage:
Expand All @@ -160,12 +165,14 @@ def list_vp_cs_all(
"organization_id": organization_id,
"project_id": project_id,
"is_default": is_default,
"routing_enabled": routing_enabled,
},
)

def create_vpc(
self,
*,
enable_routing: bool,
region: Optional[Region] = None,
name: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -178,12 +185,13 @@ def create_vpc(
:param name: Name for the VPC.
:param project_id: Scaleway Project in which to create the VPC.
:param tags: Tags for the VPC.
:param enable_routing: Enable routing between Private Networks in the VPC.
:return: :class:`VPC <VPC>`

Usage:
::

result = api.create_vpc()
result = api.create_vpc(enable_routing=True)
"""

param_region = validate_path_param(
Expand All @@ -195,6 +203,7 @@ def create_vpc(
f"/vpc/v2/regions/{param_region}/vpcs",
body=marshal_CreateVPCRequest(
CreateVPCRequest(
enable_routing=enable_routing,
region=region,
name=name or random_name(prefix="vpc"),
project_id=project_id,
Expand Down
22 changes: 16 additions & 6 deletions scaleway/scaleway/vpc/v2/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ def unmarshal_VPC(data: Any) -> VPC:
field = data.get("region", None)
args["region"] = field

field = data.get("routing_enabled", None)
args["routing_enabled"] = field

field = data.get("tags", None)
args["tags"] = field

Expand Down Expand Up @@ -259,6 +262,9 @@ def marshal_CreateVPCRequest(
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

if request.enable_routing is not None:
output["enable_routing"] = request.enable_routing

if request.name is not None:
output["name"] = request.name

Expand Down Expand Up @@ -293,16 +299,20 @@ def marshal_MigrateZonalPrivateNetworksRequest(
[
OneOfPossibility(
"project_id",
request.project_id or defaults.default_project_id
if request.project_id is not None
else None,
(
request.project_id or defaults.default_project_id
if request.project_id is not None
else None
),
defaults.default_project_id,
),
OneOfPossibility(
"organization_id",
request.organization_id or defaults.default_organization_id
if request.organization_id is not None
else None,
(
request.organization_id or defaults.default_organization_id
if request.organization_id is not None
else None
),
defaults.default_organization_id,
),
]
Expand Down
15 changes: 15 additions & 0 deletions scaleway/scaleway/vpc/v2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,11 @@ class VPC:
Number of Private Networks within this VPC.
"""

routing_enabled: bool
"""
Defines whether the VPC routes traffic between its Private Networks.
"""


@dataclass
class ListVPCsRequest:
Expand Down Expand Up @@ -257,6 +262,11 @@ class ListVPCsRequest:
Defines whether to filter only for VPCs which are the default one for their Project.
"""

routing_enabled: Optional[bool]
"""
Defines whether to filter only for VPCs which route traffic between their Private Networks.
"""


@dataclass
class CreateVPCRequest:
Expand All @@ -280,6 +290,11 @@ class CreateVPCRequest:
Tags for the VPC.
"""

enable_routing: bool
"""
Enable routing between Private Networks in the VPC.
"""


@dataclass
class GetVPCRequest:
Expand Down
Loading