Skip to content

Commit 3adb6dc

Browse files
authored
feat(instance): add encrypted rdp password method (#523)
1 parent 309efe4 commit 3adb6dc

File tree

8 files changed

+318
-0
lines changed

8 files changed

+318
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
from .types import CreateSnapshotResponse
9898
from .types import CreateVolumeRequest
9999
from .types import CreateVolumeResponse
100+
from .types import DeleteEncryptedRdpPasswordRequest
100101
from .types import DeleteImageRequest
101102
from .types import DeleteIpRequest
102103
from .types import DeletePlacementGroupRequest
@@ -115,6 +116,8 @@
115116
from .types import GetBootscriptResponse
116117
from .types import GetDashboardRequest
117118
from .types import GetDashboardResponse
119+
from .types import GetEncryptedRdpPasswordRequest
120+
from .types import GetEncryptedRdpPasswordResponse
118121
from .types import GetImageRequest
119122
from .types import GetImageResponse
120123
from .types import GetIpRequest
@@ -296,6 +299,7 @@
296299
"CreateSnapshotResponse",
297300
"CreateVolumeRequest",
298301
"CreateVolumeResponse",
302+
"DeleteEncryptedRdpPasswordRequest",
299303
"DeleteImageRequest",
300304
"DeleteIpRequest",
301305
"DeletePlacementGroupRequest",
@@ -314,6 +318,8 @@
314318
"GetBootscriptResponse",
315319
"GetDashboardRequest",
316320
"GetDashboardResponse",
321+
"GetEncryptedRdpPasswordRequest",
322+
"GetEncryptedRdpPasswordResponse",
317323
"GetImageRequest",
318324
"GetImageResponse",
319325
"GetIpRequest",

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070
ExportSnapshotResponse,
7171
GetBootscriptResponse,
7272
GetDashboardResponse,
73+
GetEncryptedRdpPasswordResponse,
7374
GetImageResponse,
7475
GetIpResponse,
7576
GetPlacementGroupResponse,
@@ -165,6 +166,7 @@
165166
unmarshal_ExportSnapshotResponse,
166167
unmarshal_GetBootscriptResponse,
167168
unmarshal_GetDashboardResponse,
169+
unmarshal_GetEncryptedRdpPasswordResponse,
168170
unmarshal_GetImageResponse,
169171
unmarshal_GetIpResponse,
170172
unmarshal_GetPlacementGroupResponse,
@@ -528,6 +530,7 @@ async def _create_server(
528530
tags: Optional[List[str]] = None,
529531
security_group: Optional[str] = None,
530532
placement_group: Optional[str] = None,
533+
admin_password_encryption_ssh_key_id: Optional[str] = None,
531534
) -> CreateServerResponse:
532535
"""
533536
Create an Instance.
@@ -552,6 +555,7 @@ async def _create_server(
552555
:param tags: Instance tags.
553556
:param security_group: Security group ID.
554557
: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.
555559
:return: :class:`CreateServerResponse <CreateServerResponse>`
556560
557561
Usage:
@@ -585,6 +589,7 @@ async def _create_server(
585589
tags=tags,
586590
security_group=security_group,
587591
placement_group=placement_group,
592+
admin_password_encryption_ssh_key_id=admin_password_encryption_ssh_key_id,
588593
project=project,
589594
organization=organization,
590595
),
@@ -4169,3 +4174,65 @@ async def apply_block_migration(
41694174
)
41704175

41714176
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)

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
GetBootscriptResponse,
5959
Dashboard,
6060
GetDashboardResponse,
61+
GetEncryptedRdpPasswordResponse,
6162
GetImageResponse,
6263
GetIpResponse,
6364
GetPlacementGroupResponse,
@@ -1565,6 +1566,37 @@ def unmarshal_GetDashboardResponse(data: Any) -> GetDashboardResponse:
15651566
return GetDashboardResponse(**args)
15661567

15671568

1569+
def unmarshal_GetEncryptedRdpPasswordResponse(
1570+
data: Any,
1571+
) -> GetEncryptedRdpPasswordResponse:
1572+
if not isinstance(data, dict):
1573+
raise TypeError(
1574+
"Unmarshalling the type 'GetEncryptedRdpPasswordResponse' failed as data isn't a dictionary."
1575+
)
1576+
1577+
args: Dict[str, Any] = {}
1578+
1579+
field = data.get("value", None)
1580+
if field is not None:
1581+
args["value"] = field
1582+
else:
1583+
args["value"] = None
1584+
1585+
field = data.get("admin_password_encryption_ssh_key_description", None)
1586+
if field is not None:
1587+
args["admin_password_encryption_ssh_key_description"] = field
1588+
else:
1589+
args["admin_password_encryption_ssh_key_description"] = None
1590+
1591+
field = data.get("admin_password_encryption_ssh_key_id", None)
1592+
if field is not None:
1593+
args["admin_password_encryption_ssh_key_id"] = field
1594+
else:
1595+
args["admin_password_encryption_ssh_key_id"] = None
1596+
1597+
return GetEncryptedRdpPasswordResponse(**args)
1598+
1599+
15681600
def unmarshal_GetImageResponse(data: Any) -> GetImageResponse:
15691601
if not isinstance(data, dict):
15701602
raise TypeError(
@@ -3089,6 +3121,11 @@ def marshal_CreateServerRequest(
30893121
if request.placement_group is not None:
30903122
output["placement_group"] = request.placement_group
30913123

3124+
if request.admin_password_encryption_ssh_key_id is not None:
3125+
output["admin_password_encryption_ssh_key_id"] = (
3126+
request.admin_password_encryption_ssh_key_id
3127+
)
3128+
30923129
return output
30933130

30943131

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

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,11 @@ class CreateServerRequest:
18581858
Placement group ID if Instance must be part of a placement group.
18591859
"""
18601860

1861+
admin_password_encryption_ssh_key_id: Optional[str]
1862+
"""
1863+
UUID of the SSH RSA key that will be used to encrypt the initial admin password for OS requiring it. Mandatory for Windows OS.
1864+
"""
1865+
18611866
project: Optional[str]
18621867

18631868
organization: Optional[str]
@@ -1959,6 +1964,19 @@ class CreateVolumeResponse:
19591964
volume: Optional[Volume]
19601965

19611966

1967+
@dataclass
1968+
class DeleteEncryptedRdpPasswordRequest:
1969+
server_id: str
1970+
"""
1971+
UUID of the Instance.
1972+
"""
1973+
1974+
zone: Optional[Zone]
1975+
"""
1976+
Zone to target. If none is passed will use default zone from the config.
1977+
"""
1978+
1979+
19621980
@dataclass
19631981
class DeleteImageRequest:
19641982
image_id: str
@@ -2172,6 +2190,37 @@ class GetDashboardResponse:
21722190
dashboard: Optional[Dashboard]
21732191

21742192

2193+
@dataclass
2194+
class GetEncryptedRdpPasswordRequest:
2195+
server_id: str
2196+
"""
2197+
UUID of the Instance.
2198+
"""
2199+
2200+
zone: Optional[Zone]
2201+
"""
2202+
Zone to target. If none is passed will use default zone from the config.
2203+
"""
2204+
2205+
2206+
@dataclass
2207+
class GetEncryptedRdpPasswordResponse:
2208+
value: Optional[str]
2209+
"""
2210+
The encrypted RDP password.
2211+
"""
2212+
2213+
admin_password_encryption_ssh_key_description: Optional[str]
2214+
"""
2215+
The description of the SSH key used for ciphering.
2216+
"""
2217+
2218+
admin_password_encryption_ssh_key_id: Optional[str]
2219+
"""
2220+
The UUID of the SSH key used for ciphering.
2221+
"""
2222+
2223+
21752224
@dataclass
21762225
class GetImageRequest:
21772226
image_id: str

scaleway/scaleway/instance/v1/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@
9797
from .types import CreateSnapshotResponse
9898
from .types import CreateVolumeRequest
9999
from .types import CreateVolumeResponse
100+
from .types import DeleteEncryptedRdpPasswordRequest
100101
from .types import DeleteImageRequest
101102
from .types import DeleteIpRequest
102103
from .types import DeletePlacementGroupRequest
@@ -115,6 +116,8 @@
115116
from .types import GetBootscriptResponse
116117
from .types import GetDashboardRequest
117118
from .types import GetDashboardResponse
119+
from .types import GetEncryptedRdpPasswordRequest
120+
from .types import GetEncryptedRdpPasswordResponse
118121
from .types import GetImageRequest
119122
from .types import GetImageResponse
120123
from .types import GetIpRequest
@@ -296,6 +299,7 @@
296299
"CreateSnapshotResponse",
297300
"CreateVolumeRequest",
298301
"CreateVolumeResponse",
302+
"DeleteEncryptedRdpPasswordRequest",
299303
"DeleteImageRequest",
300304
"DeleteIpRequest",
301305
"DeletePlacementGroupRequest",
@@ -314,6 +318,8 @@
314318
"GetBootscriptResponse",
315319
"GetDashboardRequest",
316320
"GetDashboardResponse",
321+
"GetEncryptedRdpPasswordRequest",
322+
"GetEncryptedRdpPasswordResponse",
317323
"GetImageRequest",
318324
"GetImageResponse",
319325
"GetIpRequest",

0 commit comments

Comments
 (0)