Skip to content

Commit 6dece9c

Browse files
scaleway-botyfodil
andauthored
fix(instance): document protected field on Create Server Request (scaleway#943)
Co-authored-by: Yacine FODIL <[email protected]>
1 parent 1500a91 commit 6dece9c

File tree

7 files changed

+47
-16
lines changed

7 files changed

+47
-16
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,15 @@ async def list_servers_all(
511511
async def _create_server(
512512
self,
513513
*,
514-
commercial_type: str,
515514
zone: Optional[ScwZone] = None,
515+
commercial_type: str,
516516
name: Optional[str] = None,
517517
dynamic_ip_required: Optional[bool] = None,
518518
routed_ip_enabled: Optional[bool] = None,
519519
image: Optional[str] = None,
520520
volumes: Optional[Dict[str, VolumeServerTemplate]] = None,
521521
enable_ipv6: Optional[bool] = None,
522+
protected: bool,
522523
public_ip: Optional[str] = None,
523524
public_ips: Optional[List[str]] = None,
524525
boot_type: Optional[BootType] = None,
@@ -533,14 +534,15 @@ async def _create_server(
533534
Create an Instance.
534535
Create a new Instance of the specified commercial type in the specified zone. Pay attention to the volumes parameter, which takes an object which can be used in different ways to achieve different behaviors.
535536
Get more information in the [Technical Information](#technical-information) section of the introduction.
536-
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
537537
:param zone: Zone to target. If none is passed will use default zone from the config.
538+
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
538539
:param name: Instance name.
539540
:param dynamic_ip_required: Define if a dynamic IPv4 is required for the Instance.
540541
:param routed_ip_enabled: If true, configure the Instance so it uses the new routed IP mode.
541542
:param image: Instance image ID or label.
542543
:param volumes: Volumes attached to the server.
543544
:param enable_ipv6: True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
545+
:param protected: True to activate server protection option.
544546
:param public_ip: ID of the reserved IP to attach to the Instance.
545547
:param public_ips: A list of reserved IP IDs to attach to the Instance.
546548
:param boot_type: Boot type to use.
@@ -559,6 +561,7 @@ async def _create_server(
559561
560562
result = await api._create_server(
561563
commercial_type="example",
564+
protected=False,
562565
)
563566
"""
564567

@@ -569,14 +572,15 @@ async def _create_server(
569572
f"/instance/v1/zones/{param_zone}/servers",
570573
body=marshal_CreateServerRequest(
571574
CreateServerRequest(
572-
commercial_type=commercial_type,
573575
zone=zone,
576+
commercial_type=commercial_type,
574577
name=name or random_name(prefix="srv"),
575578
dynamic_ip_required=dynamic_ip_required,
576579
routed_ip_enabled=routed_ip_enabled,
577580
image=image,
578581
volumes=volumes,
579582
enable_ipv6=enable_ipv6,
583+
protected=protected,
580584
public_ip=public_ip,
581585
public_ips=public_ips,
582586
boot_type=boot_type,
@@ -819,7 +823,7 @@ async def _update_server(
819823
:param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False).
820824
:param public_ips: A list of reserved IP IDs to attach to the Instance.
821825
:param enable_ipv6:
822-
:param protected:
826+
:param protected: True to activate server protection option.
823827
:param security_group:
824828
:param placement_group: Placement group ID if Instance must be part of a placement group.
825829
:param private_nics: Instance private NICs.

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,9 @@ def marshal_CreateServerRequest(
31193119
if request.enable_ipv6 is not None:
31203120
output["enable_ipv6"] = request.enable_ipv6
31213121

3122+
if request.protected is not None:
3123+
output["protected"] = request.protected
3124+
31223125
if request.public_ip is not None:
31233126
output["public_ip"] = request.public_ip
31243127

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,14 +1793,14 @@ class CreateSecurityGroupRuleResponse:
17931793

17941794
@dataclass
17951795
class CreateServerRequest:
1796-
commercial_type: str
1796+
zone: Optional[ScwZone]
17971797
"""
1798-
Define the Instance commercial type (i.e. GP1-S).
1798+
Zone to target. If none is passed will use default zone from the config.
17991799
"""
18001800

1801-
zone: Optional[ScwZone]
1801+
commercial_type: str
18021802
"""
1803-
Zone to target. If none is passed will use default zone from the config.
1803+
Define the Instance commercial type (i.e. GP1-S).
18041804
"""
18051805

18061806
name: Optional[str]
@@ -1833,6 +1833,11 @@ class CreateServerRequest:
18331833
True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
18341834
"""
18351835

1836+
protected: bool
1837+
"""
1838+
True to activate server protection option.
1839+
"""
1840+
18361841
public_ip: Optional[str]
18371842
"""
18381843
ID of the reserved IP to attach to the Instance.
@@ -3488,6 +3493,9 @@ class UpdateServerRequest:
34883493
enable_ipv6: Optional[bool]
34893494

34903495
protected: Optional[bool]
3496+
"""
3497+
True to activate server protection option.
3498+
"""
34913499

34923500
security_group: Optional[SecurityGroupTemplate]
34933501

scaleway/scaleway/instance/v1/api.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -511,14 +511,15 @@ def list_servers_all(
511511
def _create_server(
512512
self,
513513
*,
514-
commercial_type: str,
515514
zone: Optional[ScwZone] = None,
515+
commercial_type: str,
516516
name: Optional[str] = None,
517517
dynamic_ip_required: Optional[bool] = None,
518518
routed_ip_enabled: Optional[bool] = None,
519519
image: Optional[str] = None,
520520
volumes: Optional[Dict[str, VolumeServerTemplate]] = None,
521521
enable_ipv6: Optional[bool] = None,
522+
protected: bool,
522523
public_ip: Optional[str] = None,
523524
public_ips: Optional[List[str]] = None,
524525
boot_type: Optional[BootType] = None,
@@ -533,14 +534,15 @@ def _create_server(
533534
Create an Instance.
534535
Create a new Instance of the specified commercial type in the specified zone. Pay attention to the volumes parameter, which takes an object which can be used in different ways to achieve different behaviors.
535536
Get more information in the [Technical Information](#technical-information) section of the introduction.
536-
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
537537
:param zone: Zone to target. If none is passed will use default zone from the config.
538+
:param commercial_type: Define the Instance commercial type (i.e. GP1-S).
538539
:param name: Instance name.
539540
:param dynamic_ip_required: Define if a dynamic IPv4 is required for the Instance.
540541
:param routed_ip_enabled: If true, configure the Instance so it uses the new routed IP mode.
541542
:param image: Instance image ID or label.
542543
:param volumes: Volumes attached to the server.
543544
:param enable_ipv6: True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
545+
:param protected: True to activate server protection option.
544546
:param public_ip: ID of the reserved IP to attach to the Instance.
545547
:param public_ips: A list of reserved IP IDs to attach to the Instance.
546548
:param boot_type: Boot type to use.
@@ -559,6 +561,7 @@ def _create_server(
559561
560562
result = api._create_server(
561563
commercial_type="example",
564+
protected=False,
562565
)
563566
"""
564567

@@ -569,14 +572,15 @@ def _create_server(
569572
f"/instance/v1/zones/{param_zone}/servers",
570573
body=marshal_CreateServerRequest(
571574
CreateServerRequest(
572-
commercial_type=commercial_type,
573575
zone=zone,
576+
commercial_type=commercial_type,
574577
name=name or random_name(prefix="srv"),
575578
dynamic_ip_required=dynamic_ip_required,
576579
routed_ip_enabled=routed_ip_enabled,
577580
image=image,
578581
volumes=volumes,
579582
enable_ipv6=enable_ipv6,
583+
protected=protected,
580584
public_ip=public_ip,
581585
public_ips=public_ips,
582586
boot_type=boot_type,
@@ -819,7 +823,7 @@ def _update_server(
819823
:param routed_ip_enabled: True to configure the instance so it uses the new routed IP mode (once this is set to True you cannot set it back to False).
820824
:param public_ips: A list of reserved IP IDs to attach to the Instance.
821825
:param enable_ipv6:
822-
:param protected:
826+
:param protected: True to activate server protection option.
823827
:param security_group:
824828
:param placement_group: Placement group ID if Instance must be part of a placement group.
825829
:param private_nics: Instance private NICs.

scaleway/scaleway/instance/v1/marshalling.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3119,6 +3119,9 @@ def marshal_CreateServerRequest(
31193119
if request.enable_ipv6 is not None:
31203120
output["enable_ipv6"] = request.enable_ipv6
31213121

3122+
if request.protected is not None:
3123+
output["protected"] = request.protected
3124+
31223125
if request.public_ip is not None:
31233126
output["public_ip"] = request.public_ip
31243127

scaleway/scaleway/instance/v1/test_user_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ def setUp(self) -> None:
2222
image="ubuntu_jammy",
2323
name="my-server-web",
2424
volumes={},
25+
protected=False,
2526
)
2627

2728
@unittest.skip("API Test is not up")

scaleway/scaleway/instance/v1/types.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1793,14 +1793,14 @@ class CreateSecurityGroupRuleResponse:
17931793

17941794
@dataclass
17951795
class CreateServerRequest:
1796-
commercial_type: str
1796+
zone: Optional[ScwZone]
17971797
"""
1798-
Define the Instance commercial type (i.e. GP1-S).
1798+
Zone to target. If none is passed will use default zone from the config.
17991799
"""
18001800

1801-
zone: Optional[ScwZone]
1801+
commercial_type: str
18021802
"""
1803-
Zone to target. If none is passed will use default zone from the config.
1803+
Define the Instance commercial type (i.e. GP1-S).
18041804
"""
18051805

18061806
name: Optional[str]
@@ -1833,6 +1833,11 @@ class CreateServerRequest:
18331833
True if IPv6 is enabled on the server (deprecated and always `False` when `routed_ip_enabled` is `True`).
18341834
"""
18351835

1836+
protected: bool
1837+
"""
1838+
True to activate server protection option.
1839+
"""
1840+
18361841
public_ip: Optional[str]
18371842
"""
18381843
ID of the reserved IP to attach to the Instance.
@@ -3488,6 +3493,9 @@ class UpdateServerRequest:
34883493
enable_ipv6: Optional[bool]
34893494

34903495
protected: Optional[bool]
3496+
"""
3497+
True to activate server protection option.
3498+
"""
34913499

34923500
security_group: Optional[SecurityGroupTemplate]
34933501

0 commit comments

Comments
 (0)