Skip to content

Commit f2d1d78

Browse files
authored
feat(lb): attach flexible ip (#402)
1 parent 6221ce8 commit f2d1d78

File tree

6 files changed

+180
-4
lines changed

6 files changed

+180
-4
lines changed

scaleway-async/scaleway_async/lb/v1/api.py

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,8 @@ async def create_lb(
311311
name: Optional[str] = None,
312312
ip_id: Optional[str] = None,
313313
assign_flexible_ip: Optional[bool] = None,
314+
assign_flexible_ipv6: Optional[bool] = None,
315+
ip_ids: Optional[List[str]] = None,
314316
tags: Optional[List[str]] = None,
315317
) -> Lb:
316318
"""
@@ -326,6 +328,8 @@ async def create_lb(
326328
:param description: Description for the Load Balancer.
327329
:param ip_id: ID of an existing flexible IP address to attach to the Load Balancer.
328330
:param assign_flexible_ip: Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
331+
:param assign_flexible_ipv6: Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
332+
:param ip_ids: List of IP IDs to attach to the Load Balancer.
329333
:param tags: List of tags for the Load Balancer.
330334
:param type_: Load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types.
331335
: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.
@@ -359,6 +363,8 @@ async def create_lb(
359363
name=name or random_name(prefix="lb"),
360364
ip_id=ip_id,
361365
assign_flexible_ip=assign_flexible_ip,
366+
assign_flexible_ipv6=assign_flexible_ipv6,
367+
ip_ids=ip_ids,
362368
tags=tags,
363369
),
364370
self.client,
@@ -660,6 +666,7 @@ async def list_i_ps_all(
660666
async def create_ip(
661667
self,
662668
*,
669+
is_ipv6: bool,
663670
region: Optional[Region] = None,
664671
organization_id: Optional[str] = None,
665672
project_id: Optional[str] = None,
@@ -675,12 +682,13 @@ async def create_ip(
675682
676683
One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set.
677684
:param reverse: Reverse DNS (domain name) for the IP address.
685+
:param is_ipv6: If true, creates a Flexible IP with an ipv6 address.
678686
:return: :class:`Ip <Ip>`
679687
680688
Usage:
681689
::
682690
683-
result = await api.create_ip()
691+
result = await api.create_ip(is_ipv6=True)
684692
"""
685693

686694
param_region = validate_path_param(
@@ -692,6 +700,7 @@ async def create_ip(
692700
f"/lb/v1/regions/{param_region}/ips",
693701
body=marshal_CreateIpRequest(
694702
CreateIpRequest(
703+
is_ipv6=is_ipv6,
695704
region=region,
696705
organization_id=organization_id,
697706
project_id=project_id,
@@ -771,12 +780,14 @@ async def update_ip(
771780
ip_id: str,
772781
region: Optional[Region] = None,
773782
reverse: Optional[str] = None,
783+
lb_id: Optional[str] = None,
774784
) -> Ip:
775785
"""
776786
Update an IP.
777787
:param region: Region to target. If none is passed will use default region from the config.
778788
:param ip_id: IP address ID.
779789
:param reverse: Reverse DNS (domain name) for the IP address.
790+
:param lb_id: ID of the server on which to attach the flexible IP.
780791
:return: :class:`Ip <Ip>`
781792
782793
Usage:
@@ -798,6 +809,7 @@ async def update_ip(
798809
ip_id=ip_id,
799810
region=region,
800811
reverse=reverse,
812+
lb_id=lb_id,
801813
),
802814
self.client,
803815
),
@@ -3256,6 +3268,8 @@ async def create_lb(
32563268
name: Optional[str] = None,
32573269
ip_id: Optional[str] = None,
32583270
assign_flexible_ip: Optional[bool] = None,
3271+
assign_flexible_ipv6: Optional[bool] = None,
3272+
ip_ids: Optional[List[str]] = None,
32593273
tags: Optional[List[str]] = None,
32603274
) -> Lb:
32613275
"""
@@ -3272,6 +3286,8 @@ async def create_lb(
32723286
:param description: Description for the Load Balancer.
32733287
:param ip_id: ID of an existing flexible IP address to attach to the Load Balancer.
32743288
:param assign_flexible_ip: Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
3289+
:param assign_flexible_ipv6: Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
3290+
:param ip_ids: List of IP IDs to attach to the Load Balancer.
32753291
:param tags: List of tags for the Load Balancer.
32763292
:param type_: Load Balancer commercial offer type. Use the Load Balancer types endpoint to retrieve a list of available offer types.
32773293
: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.
@@ -3303,6 +3319,8 @@ async def create_lb(
33033319
name=name or random_name(prefix="lb"),
33043320
ip_id=ip_id,
33053321
assign_flexible_ip=assign_flexible_ip,
3322+
assign_flexible_ipv6=assign_flexible_ipv6,
3323+
ip_ids=ip_ids,
33063324
tags=tags,
33073325
),
33083326
self.client,
@@ -3600,6 +3618,7 @@ async def list_i_ps_all(
36003618
async def create_ip(
36013619
self,
36023620
*,
3621+
is_ipv6: bool,
36033622
zone: Optional[Zone] = None,
36043623
organization_id: Optional[str] = None,
36053624
project_id: Optional[str] = None,
@@ -3616,12 +3635,13 @@ async def create_ip(
36163635
36173636
One-of ('project_identifier'): at most one of 'organization_id', 'project_id' could be set.
36183637
:param reverse: Reverse DNS (domain name) for the IP address.
3638+
:param is_ipv6: If true, creates a Flexible IP with an ipv6 address.
36193639
:return: :class:`Ip <Ip>`
36203640
36213641
Usage:
36223642
::
36233643
3624-
result = await api.create_ip()
3644+
result = await api.create_ip(is_ipv6=True)
36253645
"""
36263646

36273647
param_zone = validate_path_param("zone", zone or self.client.default_zone)
@@ -3631,6 +3651,7 @@ async def create_ip(
36313651
f"/lb/v1/zones/{param_zone}/ips",
36323652
body=marshal_ZonedApiCreateIpRequest(
36333653
ZonedApiCreateIpRequest(
3654+
is_ipv6=is_ipv6,
36343655
zone=zone,
36353656
organization_id=organization_id,
36363657
project_id=project_id,
@@ -3708,13 +3729,15 @@ async def update_ip(
37083729
ip_id: str,
37093730
zone: Optional[Zone] = None,
37103731
reverse: Optional[str] = None,
3732+
lb_id: Optional[str] = None,
37113733
) -> Ip:
37123734
"""
37133735
Update an IP address.
37143736
Update the reverse DNS of a Load Balancer flexible IP address.
37153737
:param zone: Zone to target. If none is passed will use default zone from the config.
37163738
:param ip_id: IP address ID.
37173739
:param reverse: Reverse DNS (domain name) for the IP address.
3740+
:param lb_id: ID of the server on which to attach the flexible IP.
37183741
:return: :class:`Ip <Ip>`
37193742
37203743
Usage:
@@ -3734,6 +3757,7 @@ async def update_ip(
37343757
ip_id=ip_id,
37353758
zone=zone,
37363759
reverse=reverse,
3760+
lb_id=lb_id,
37373761
),
37383762
self.client,
37393763
),

scaleway-async/scaleway_async/lb/v1/marshalling.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,6 +1777,9 @@ def marshal_CreateIpRequest(
17771777
),
17781778
)
17791779

1780+
if request.is_ipv6 is not None:
1781+
output["is_ipv6"] = request.is_ipv6
1782+
17801783
if request.reverse is not None:
17811784
output["reverse"] = request.reverse
17821785

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

1818+
if request.assign_flexible_ipv6 is not None:
1819+
output["assign_flexible_ipv6"] = request.assign_flexible_ipv6
1820+
18151821
if request.description is not None:
18161822
output["description"] = request.description
18171823

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

1827+
if request.ip_ids is not None:
1828+
output["ip_ids"] = request.ip_ids
1829+
18211830
if request.name is not None:
18221831
output["name"] = request.name
18231832

@@ -2168,6 +2177,9 @@ def marshal_UpdateIpRequest(
21682177
) -> Dict[str, Any]:
21692178
output: Dict[str, Any] = {}
21702179

2180+
if request.lb_id is not None:
2181+
output["lb_id"] = request.lb_id
2182+
21712183
if request.reverse is not None:
21722184
output["reverse"] = request.reverse
21732185

@@ -2477,6 +2489,9 @@ def marshal_ZonedApiCreateIpRequest(
24772489
),
24782490
)
24792491

2492+
if request.is_ipv6 is not None:
2493+
output["is_ipv6"] = request.is_ipv6
2494+
24802495
if request.reverse is not None:
24812496
output["reverse"] = request.reverse
24822497

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

2530+
if request.assign_flexible_ipv6 is not None:
2531+
output["assign_flexible_ipv6"] = request.assign_flexible_ipv6
2532+
25152533
if request.description is not None:
25162534
output["description"] = request.description
25172535

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

2539+
if request.ip_ids is not None:
2540+
output["ip_ids"] = request.ip_ids
2541+
25212542
if request.name is not None:
25222543
output["name"] = request.name
25232544

@@ -2880,6 +2901,9 @@ def marshal_ZonedApiUpdateIpRequest(
28802901
) -> Dict[str, Any]:
28812902
output: Dict[str, Any] = {}
28822903

2904+
if request.lb_id is not None:
2905+
output["lb_id"] = request.lb_id
2906+
28832907
if request.reverse is not None:
28842908
output["reverse"] = request.reverse
28852909

scaleway-async/scaleway_async/lb/v1/types.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,16 @@ class CreateLbRequest:
16921692
Defines whether to automatically assign a flexible public IP to lb. Default value is `false` (do not assign).
16931693
"""
16941694

1695+
assign_flexible_ipv6: Optional[bool]
1696+
"""
1697+
Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
1698+
"""
1699+
1700+
ip_ids: Optional[List[str]]
1701+
"""
1702+
List of IP IDs to attach to the Load Balancer.
1703+
"""
1704+
16951705
tags: Optional[List[str]]
16961706
"""
16971707
List of tags for the Load Balancer.
@@ -1850,6 +1860,11 @@ class CreateIpRequest:
18501860
Reverse DNS (domain name) for the IP address.
18511861
"""
18521862

1863+
is_ipv6: bool
1864+
"""
1865+
If true, creates a Flexible IP with an ipv6 address.
1866+
"""
1867+
18531868

18541869
@dataclass
18551870
class GetIpRequest:
@@ -1894,6 +1909,11 @@ class UpdateIpRequest:
18941909
Reverse DNS (domain name) for the IP address.
18951910
"""
18961911

1912+
lb_id: Optional[str]
1913+
"""
1914+
ID of the server on which to attach the flexible IP.
1915+
"""
1916+
18971917

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

3254+
assign_flexible_ipv6: Optional[bool]
3255+
"""
3256+
Defines whether to automatically assign a flexible public IPv6 to the Load Balancer. Default value is `false` (do not assign).
3257+
"""
3258+
3259+
ip_ids: Optional[List[str]]
3260+
"""
3261+
List of IP IDs to attach to the Load Balancer.
3262+
"""
3263+
32343264
tags: Optional[List[str]]
32353265
"""
32363266
List of tags for the Load Balancer.
@@ -3389,6 +3419,11 @@ class ZonedApiCreateIpRequest:
33893419
Reverse DNS (domain name) for the IP address.
33903420
"""
33913421

3422+
is_ipv6: bool
3423+
"""
3424+
If true, creates a Flexible IP with an ipv6 address.
3425+
"""
3426+
33923427

33933428
@dataclass
33943429
class ZonedApiGetIpRequest:
@@ -3433,6 +3468,11 @@ class ZonedApiUpdateIpRequest:
34333468
Reverse DNS (domain name) for the IP address.
34343469
"""
34353470

3471+
lb_id: Optional[str]
3472+
"""
3473+
ID of the server on which to attach the flexible IP.
3474+
"""
3475+
34363476

34373477
@dataclass
34383478
class ZonedApiListBackendsRequest:

0 commit comments

Comments
 (0)