Skip to content

Commit 4d589d7

Browse files
feat(instance): move EncryptedRdpPassword elements to Server (#534)
Co-authored-by: Mia-Cross <[email protected]>
1 parent b11f03b commit 4d589d7

File tree

10 files changed

+178
-376
lines changed

10 files changed

+178
-376
lines changed

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

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@
9797
from .types import CreateSnapshotResponse
9898
from .types import CreateVolumeRequest
9999
from .types import CreateVolumeResponse
100-
from .types import DeleteEncryptedRdpPasswordRequest
101100
from .types import DeleteImageRequest
102101
from .types import DeleteIpRequest
103102
from .types import DeletePlacementGroupRequest
@@ -116,8 +115,6 @@
116115
from .types import GetBootscriptResponse
117116
from .types import GetDashboardRequest
118117
from .types import GetDashboardResponse
119-
from .types import GetEncryptedRdpPasswordRequest
120-
from .types import GetEncryptedRdpPasswordResponse
121118
from .types import GetImageRequest
122119
from .types import GetImageResponse
123120
from .types import GetIpRequest
@@ -299,7 +296,6 @@
299296
"CreateSnapshotResponse",
300297
"CreateVolumeRequest",
301298
"CreateVolumeResponse",
302-
"DeleteEncryptedRdpPasswordRequest",
303299
"DeleteImageRequest",
304300
"DeleteIpRequest",
305301
"DeletePlacementGroupRequest",
@@ -318,8 +314,6 @@
318314
"GetBootscriptResponse",
319315
"GetDashboardRequest",
320316
"GetDashboardResponse",
321-
"GetEncryptedRdpPasswordRequest",
322-
"GetEncryptedRdpPasswordResponse",
323317
"GetImageRequest",
324318
"GetImageResponse",
325319
"GetIpRequest",

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

Lines changed: 16 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
ExportSnapshotResponse,
7171
GetBootscriptResponse,
7272
GetDashboardResponse,
73-
GetEncryptedRdpPasswordResponse,
7473
GetImageResponse,
7574
GetIpResponse,
7675
GetPlacementGroupResponse,
@@ -166,7 +165,6 @@
166165
unmarshal_ExportSnapshotResponse,
167166
unmarshal_GetBootscriptResponse,
168167
unmarshal_GetDashboardResponse,
169-
unmarshal_GetEncryptedRdpPasswordResponse,
170168
unmarshal_GetImageResponse,
171169
unmarshal_GetIpResponse,
172170
unmarshal_GetPlacementGroupResponse,
@@ -555,7 +553,7 @@ async def _create_server(
555553
:param tags: Instance tags.
556554
:param security_group: Security group ID.
557555
:param placement_group: Placement group ID if Instance must be part of a placement group.
558-
:param admin_password_encryption_ssh_key_id: UUID of the SSH RSA key that will be used to encrypt the initial admin password for OS requiring it. Mandatory for Windows OS.
556+
:param admin_password_encryption_ssh_key_id: The public_key value of this key is used to encrypt the admin password.
559557
:return: :class:`CreateServerResponse <CreateServerResponse>`
560558
561559
Usage:
@@ -669,22 +667,22 @@ async def _set_server(
669667
id: str,
670668
name: str,
671669
commercial_type: str,
670+
organization: Optional[str] = None,
672671
dynamic_ip_required: bool,
673672
hostname: str,
674-
organization: Optional[str] = None,
673+
protected: bool,
674+
state_detail: str,
675675
project: Optional[str] = None,
676676
allowed_actions: Optional[List[ServerAction]] = None,
677677
tags: Optional[List[str]] = None,
678678
creation_date: Optional[datetime] = None,
679679
routed_ip_enabled: Optional[bool] = None,
680680
enable_ipv6: Optional[bool] = None,
681681
image: Optional[Image] = None,
682-
protected: bool,
683682
private_ip: Optional[str] = None,
684683
public_ip: Optional[ServerIp] = None,
685684
public_ips: Optional[List[ServerIp]] = None,
686685
modification_date: Optional[datetime] = None,
687-
state_detail: str,
688686
state: Optional[ServerState] = None,
689687
location: Optional[ServerLocation] = None,
690688
ipv6: Optional[ServerIpv6] = None,
@@ -696,28 +694,29 @@ async def _set_server(
696694
arch: Optional[Arch] = None,
697695
placement_group: Optional[PlacementGroup] = None,
698696
private_nics: Optional[List[PrivateNIC]] = None,
697+
admin_password_encryption_ssh_key_id: Optional[str] = None,
699698
) -> _SetServerResponse:
700699
"""
701700
:param zone: Zone to target. If none is passed will use default zone from the config.
702701
:param id: Instance unique ID.
703702
:param name: Instance name.
704703
:param commercial_type: Instance commercial type (eg. GP1-M).
704+
:param organization: Instance Organization ID.
705705
:param dynamic_ip_required: True if a dynamic IPv4 is required.
706706
:param hostname: Instance host name.
707-
:param organization: Instance Organization ID.
707+
:param protected: Instance protection option is activated.
708+
:param state_detail: Instance state_detail.
708709
:param project: Instance Project ID.
709710
:param allowed_actions: Provide a list of allowed actions on the server.
710711
:param tags: Tags associated with the Instance.
711712
:param creation_date: Instance creation date.
712713
: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).
713714
:param enable_ipv6: True if IPv6 is enabled (deprecated and always `False` when `routed_ip_enabled` is `True`).
714715
:param image: Provide information on the Instance image.
715-
:param protected: Instance protection option is activated.
716716
:param private_ip: Instance private IP address (deprecated and always `null` when `routed_ip_enabled` is `True`).
717717
:param public_ip: Information about the public IP (deprecated in favor of `public_ips`).
718718
:param public_ips: Information about all the public IPs attached to the server.
719719
:param modification_date: Instance modification date.
720-
:param state_detail: Instance state_detail.
721720
:param state: Instance state.
722721
:param location: Instance location.
723722
:param ipv6: Instance IPv6 address (deprecated when `routed_ip_enabled` is `True`).
@@ -729,6 +728,7 @@ async def _set_server(
729728
:param arch: Instance architecture (refers to the CPU architecture used for the Instance, e.g. x86_64, arm64).
730729
:param placement_group: Instance placement group.
731730
:param private_nics: Instance private NICs.
731+
:param admin_password_encryption_ssh_key_id: The public_key value of this key is used to encrypt the admin password. When set to an empty string, reset this value and admin_password_encrypted_value to an empty string so a new password may be generated.
732732
:return: :class:`_SetServerResponse <_SetServerResponse>`
733733
734734
Usage:
@@ -757,22 +757,22 @@ async def _set_server(
757757
id=id,
758758
name=name,
759759
commercial_type=commercial_type,
760+
organization=organization,
760761
dynamic_ip_required=dynamic_ip_required,
761762
hostname=hostname,
762-
organization=organization,
763+
protected=protected,
764+
state_detail=state_detail,
763765
project=project,
764766
allowed_actions=allowed_actions,
765767
tags=tags,
766768
creation_date=creation_date,
767769
routed_ip_enabled=routed_ip_enabled,
768770
enable_ipv6=enable_ipv6,
769771
image=image,
770-
protected=protected,
771772
private_ip=private_ip,
772773
public_ip=public_ip,
773774
public_ips=public_ips,
774775
modification_date=modification_date,
775-
state_detail=state_detail,
776776
state=state,
777777
location=location,
778778
ipv6=ipv6,
@@ -784,6 +784,7 @@ async def _set_server(
784784
arch=arch,
785785
placement_group=placement_group,
786786
private_nics=private_nics,
787+
admin_password_encryption_ssh_key_id=admin_password_encryption_ssh_key_id,
787788
),
788789
self.client,
789790
),
@@ -811,6 +812,7 @@ async def _update_server(
811812
placement_group: Optional[str] = None,
812813
private_nics: Optional[List[str]] = None,
813814
commercial_type: Optional[str] = None,
815+
admin_password_encryption_ssh_key_id: Optional[str] = None,
814816
) -> UpdateServerResponse:
815817
"""
816818
Update an Instance.
@@ -834,6 +836,7 @@ async def _update_server(
834836
- Cannot be changed if the Instance is not in `stopped` state.
835837
- Cannot be changed if the Instance is in a placement group.
836838
- Local storage requirements of the target commercial_types must be fulfilled (i.e. if an Instance has 80GB of local storage, it can be changed into a GP1-XS, which has a maximum of 150GB, but it cannot be changed into a DEV1-S, which has only 20GB).
839+
:param admin_password_encryption_ssh_key_id: The public_key value of this key is used to encrypt the admin password. When set to an empty string, reset this value and admin_password_encrypted_value to an empty string so a new password may be generated.
837840
:return: :class:`UpdateServerResponse <UpdateServerResponse>`
838841
839842
Usage:
@@ -868,6 +871,7 @@ async def _update_server(
868871
placement_group=placement_group,
869872
private_nics=private_nics,
870873
commercial_type=commercial_type,
874+
admin_password_encryption_ssh_key_id=admin_password_encryption_ssh_key_id,
871875
),
872876
self.client,
873877
),
@@ -4174,65 +4178,3 @@ async def apply_block_migration(
41744178
)
41754179

41764180
self._throw_on_error(res)
4177-
4178-
async def get_encrypted_rdp_password(
4179-
self,
4180-
*,
4181-
server_id: str,
4182-
zone: Optional[Zone] = None,
4183-
) -> GetEncryptedRdpPasswordResponse:
4184-
"""
4185-
Get the encrypted RDP password.
4186-
Get the initial administrator password for Windows RDP. This password is encrypted using the SSH RSA key specified at the time of Instance creation.
4187-
:param server_id: UUID of the Instance.
4188-
:param zone: Zone to target. If none is passed will use default zone from the config.
4189-
:return: :class:`GetEncryptedRdpPasswordResponse <GetEncryptedRdpPasswordResponse>`
4190-
4191-
Usage:
4192-
::
4193-
4194-
result = await api.get_encrypted_rdp_password(
4195-
server_id="example",
4196-
)
4197-
"""
4198-
4199-
param_zone = validate_path_param("zone", zone or self.client.default_zone)
4200-
param_server_id = validate_path_param("server_id", server_id)
4201-
4202-
res = self._request(
4203-
"GET",
4204-
f"/instance/v1/zones/{param_zone}/servers/{param_server_id}/encrypted_rdp_password",
4205-
)
4206-
4207-
self._throw_on_error(res)
4208-
return unmarshal_GetEncryptedRdpPasswordResponse(res.json())
4209-
4210-
async def delete_encrypted_rdp_password(
4211-
self,
4212-
*,
4213-
server_id: str,
4214-
zone: Optional[Zone] = None,
4215-
) -> None:
4216-
"""
4217-
Delete the encrypted RDP password.
4218-
Delete the initial administrator password for Windows RDP.
4219-
:param server_id: UUID of the Instance.
4220-
:param zone: Zone to target. If none is passed will use default zone from the config.
4221-
4222-
Usage:
4223-
::
4224-
4225-
result = await api.delete_encrypted_rdp_password(
4226-
server_id="example",
4227-
)
4228-
"""
4229-
4230-
param_zone = validate_path_param("zone", zone or self.client.default_zone)
4231-
param_server_id = validate_path_param("server_id", server_id)
4232-
4233-
res = self._request(
4234-
"DELETE",
4235-
f"/instance/v1/zones/{param_zone}/servers/{param_server_id}/encrypted_rdp_password",
4236-
)
4237-
4238-
self._throw_on_error(res)

0 commit comments

Comments
 (0)