Skip to content

Commit

Permalink
feat(lb): attach flexible ip (#402)
Browse files Browse the repository at this point in the history
  • Loading branch information
scaleway-bot authored Dec 26, 2023
1 parent 6221ce8 commit f2d1d78
Show file tree
Hide file tree
Showing 6 changed files with 180 additions and 4 deletions.
28 changes: 26 additions & 2 deletions scaleway-async/scaleway_async/lb/v1/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,8 @@ async def create_lb(
name: Optional[str] = None,
ip_id: Optional[str] = None,
assign_flexible_ip: Optional[bool] = None,
assign_flexible_ipv6: Optional[bool] = None,
ip_ids: Optional[List[str]] = None,
tags: Optional[List[str]] = None,
) -> Lb:
"""
Expand All @@ -326,6 +328,8 @@ async def create_lb(
:param description: Description for the Load Balancer.
:param ip_id: ID of an existing flexible IP address to attach to the Load Balancer.
:param assign_flexible_ip: Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
:param assign_flexible_ipv6: Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
:param ip_ids: List of IP IDs to attach to the Load Balancer.
:param tags: List of tags for the Load Balancer.
:param type_: Load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types.
:param ssl_compatibility_level: Determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and do not need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort.
Expand Down Expand Up @@ -359,6 +363,8 @@ async def create_lb(
name=name or random_name(prefix="lb"),
ip_id=ip_id,
assign_flexible_ip=assign_flexible_ip,
assign_flexible_ipv6=assign_flexible_ipv6,
ip_ids=ip_ids,
tags=tags,
),
self.client,
Expand Down Expand Up @@ -660,6 +666,7 @@ async def list_i_ps_all(
async def create_ip(
self,
*,
is_ipv6: bool,
region: Optional[Region] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -675,12 +682,13 @@ async def create_ip(
One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set.
:param reverse: Reverse DNS (domain name) for the IP address.
:param is_ipv6: If true, creates a Flexible IP with an ipv6 address.
:return: :class:`Ip <Ip>`
Usage:
::
result = await api.create_ip()
result = await api.create_ip(is_ipv6=True)
"""

param_region = validate_path_param(
Expand All @@ -692,6 +700,7 @@ async def create_ip(
f"/lb/v1/regions/{param_region}/ips",
body=marshal_CreateIpRequest(
CreateIpRequest(
is_ipv6=is_ipv6,
region=region,
organization_id=organization_id,
project_id=project_id,
Expand Down Expand Up @@ -771,12 +780,14 @@ async def update_ip(
ip_id: str,
region: Optional[Region] = None,
reverse: Optional[str] = None,
lb_id: Optional[str] = None,
) -> Ip:
"""
Update an IP.
:param region: Region to target. If none is passed will use default region from the config.
:param ip_id: IP address ID.
:param reverse: Reverse DNS (domain name) for the IP address.
:param lb_id: ID of the server on which to attach the flexible IP.
:return: :class:`Ip <Ip>`
Usage:
Expand All @@ -798,6 +809,7 @@ async def update_ip(
ip_id=ip_id,
region=region,
reverse=reverse,
lb_id=lb_id,
),
self.client,
),
Expand Down Expand Up @@ -3256,6 +3268,8 @@ async def create_lb(
name: Optional[str] = None,
ip_id: Optional[str] = None,
assign_flexible_ip: Optional[bool] = None,
assign_flexible_ipv6: Optional[bool] = None,
ip_ids: Optional[List[str]] = None,
tags: Optional[List[str]] = None,
) -> Lb:
"""
Expand All @@ -3272,6 +3286,8 @@ async def create_lb(
:param description: Description for the Load Balancer.
:param ip_id: ID of an existing flexible IP address to attach to the Load Balancer.
:param assign_flexible_ip: Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
:param assign_flexible_ipv6: Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
:param ip_ids: List of IP IDs to attach to the Load Balancer.
:param tags: List of tags for the Load Balancer.
:param type_: Load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types.
:param ssl_compatibility_level: Determines the minimal SSL version which needs to be supported on the client side, in an SSL/TLS offloading context. Intermediate is suitable for general-purpose servers with a variety of clients, recommended for almost all systems. Modern is suitable for services with clients that support TLS 1.3 and do not need backward compatibility. Old is compatible with a small number of very old clients and should be used only as a last resort.
Expand Down Expand Up @@ -3303,6 +3319,8 @@ async def create_lb(
name=name or random_name(prefix="lb"),
ip_id=ip_id,
assign_flexible_ip=assign_flexible_ip,
assign_flexible_ipv6=assign_flexible_ipv6,
ip_ids=ip_ids,
tags=tags,
),
self.client,
Expand Down Expand Up @@ -3600,6 +3618,7 @@ async def list_i_ps_all(
async def create_ip(
self,
*,
is_ipv6: bool,
zone: Optional[Zone] = None,
organization_id: Optional[str] = None,
project_id: Optional[str] = None,
Expand All @@ -3616,12 +3635,13 @@ async def create_ip(
One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set.
:param reverse: Reverse DNS (domain name) for the IP address.
:param is_ipv6: If true, creates a Flexible IP with an ipv6 address.
:return: :class:`Ip <Ip>`
Usage:
::
result = await api.create_ip()
result = await api.create_ip(is_ipv6=True)
"""

param_zone = validate_path_param("zone", zone or self.client.default_zone)
Expand All @@ -3631,6 +3651,7 @@ async def create_ip(
f"/lb/v1/zones/{param_zone}/ips",
body=marshal_ZonedApiCreateIpRequest(
ZonedApiCreateIpRequest(
is_ipv6=is_ipv6,
zone=zone,
organization_id=organization_id,
project_id=project_id,
Expand Down Expand Up @@ -3708,13 +3729,15 @@ async def update_ip(
ip_id: str,
zone: Optional[Zone] = None,
reverse: Optional[str] = None,
lb_id: Optional[str] = None,
) -> Ip:
"""
Update an IP address.
Update the reverse DNS of a Load Balancer flexible IP address.
:param zone: Zone to target. If none is passed will use default zone from the config.
:param ip_id: IP address ID.
:param reverse: Reverse DNS (domain name) for the IP address.
:param lb_id: ID of the server on which to attach the flexible IP.
:return: :class:`Ip <Ip>`
Usage:
Expand All @@ -3734,6 +3757,7 @@ async def update_ip(
ip_id=ip_id,
zone=zone,
reverse=reverse,
lb_id=lb_id,
),
self.client,
),
Expand Down
24 changes: 24 additions & 0 deletions scaleway-async/scaleway_async/lb/v1/marshalling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,9 @@ def marshal_CreateIpRequest(
),
)

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

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

Expand Down Expand Up @@ -1812,12 +1815,18 @@ def marshal_CreateLbRequest(
if request.assign_flexible_ip is not None:
output["assign_flexible_ip"] = request.assign_flexible_ip

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

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

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

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

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

Expand Down Expand Up @@ -2168,6 +2177,9 @@ def marshal_UpdateIpRequest(
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

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

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

Expand Down Expand Up @@ -2477,6 +2489,9 @@ def marshal_ZonedApiCreateIpRequest(
),
)

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

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

Expand Down Expand Up @@ -2512,12 +2527,18 @@ def marshal_ZonedApiCreateLbRequest(
if request.assign_flexible_ip is not None:
output["assign_flexible_ip"] = request.assign_flexible_ip

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

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

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

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

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

Expand Down Expand Up @@ -2880,6 +2901,9 @@ def marshal_ZonedApiUpdateIpRequest(
) -> Dict[str, Any]:
output: Dict[str, Any] = {}

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

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

Expand Down
40 changes: 40 additions & 0 deletions scaleway-async/scaleway_async/lb/v1/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1692,6 +1692,16 @@ class CreateLbRequest:
Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
"""

assign_flexible_ipv6: Optional[bool]
"""
Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
"""

ip_ids: Optional[List[str]]
"""
List of IP IDs to attach to the Load Balancer.
"""

tags: Optional[List[str]]
"""
List of tags for the Load Balancer.
Expand Down Expand Up @@ -1850,6 +1860,11 @@ class CreateIpRequest:
Reverse DNS (domain name) for the IP address.
"""

is_ipv6: bool
"""
If true, creates a Flexible IP with an ipv6 address.
"""


@dataclass
class GetIpRequest:
Expand Down Expand Up @@ -1894,6 +1909,11 @@ class UpdateIpRequest:
Reverse DNS (domain name) for the IP address.
"""

lb_id: Optional[str]
"""
ID of the server on which to attach the flexible IP.
"""


@dataclass
class ListBackendsRequest:
Expand Down Expand Up @@ -3231,6 +3251,16 @@ class ZonedApiCreateLbRequest:
Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
"""

assign_flexible_ipv6: Optional[bool]
"""
Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
"""

ip_ids: Optional[List[str]]
"""
List of IP IDs to attach to the Load Balancer.
"""

tags: Optional[List[str]]
"""
List of tags for the Load Balancer.
Expand Down Expand Up @@ -3389,6 +3419,11 @@ class ZonedApiCreateIpRequest:
Reverse DNS (domain name) for the IP address.
"""

is_ipv6: bool
"""
If true, creates a Flexible IP with an ipv6 address.
"""


@dataclass
class ZonedApiGetIpRequest:
Expand Down Expand Up @@ -3433,6 +3468,11 @@ class ZonedApiUpdateIpRequest:
Reverse DNS (domain name) for the IP address.
"""

lb_id: Optional[str]
"""
ID of the server on which to attach the flexible IP.
"""


@dataclass
class ZonedApiListBackendsRequest:
Expand Down
Loading

0 comments on commit f2d1d78

Please sign in to comment.