Skip to content

Commit 5d82360

Browse files
committed
update type from stringIO to bytes
1 parent 73a49a8 commit 5d82360

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

scaleway/scaleway/instance/v1/custom_api.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
from io import StringIO
21
from typing import Optional
3-
42
from scaleway_core.bridge import Zone
53
from scaleway_core.utils import validate_path_param
64
from .api import InstanceV1API
@@ -39,8 +37,8 @@ def get_server_user_data(self, server_id: str, key: str, zone: Optional[Zone] =
3937
f"/instance/v1/zones/{param_zone}/servers/{param_server_id}/user_data/{key}",
4038
body=marshal_GetServerUserDataRequest(
4139
GetServerUserDataRequest(
42-
zone= zone,
43-
server_id= server_id,
40+
zone=zone,
41+
server_id=server_id,
4442
key=key,
4543
),
4644
self.client,
@@ -49,13 +47,13 @@ def get_server_user_data(self, server_id: str, key: str, zone: Optional[Zone] =
4947
self._throw_on_error(res)
5048
return unmarshal_GetServerUserDataResponse(res.json())
5149

52-
def set_server_user_data(self, server_id: str, key: str, content: StringIO, zone: Optional[Zone] = None):
50+
def set_server_user_data(self, server_id: str, key: str, content: bytes, zone: Optional[Zone] = None):
5351
"""
5452
Sets the content of a user data on a server for the given key.
5553
:param zone: Zone to target. If none is passed, it will use the default zone from the config.
5654
:param server_id: The ID of the server.
5755
:param key: The user data key.
58-
:param content: The content to set as user data.
56+
:param content: The content to set as user data in bytes.
5957
:return: A plain text response confirming the operation.
6058
"""
6159
param_zone = validate_path_param("zone", zone or self.client.default_zone)

scaleway/scaleway/instance/v1/custom_marshalling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ def marshal_SetServerUserDataRequest(request: SetServerUserDataRequest, defaults
5050
if request.zone is not None:
5151
output["zone"] = request.zone
5252
if request.content is not None:
53-
output["content"] = request.content.getvalue()
53+
output["content"] = request.content.decode("utf-8")
5454

5555
return output

scaleway/scaleway/instance/v1/custom_types.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
from dataclasses import dataclass
2-
from io import StringIO
32
from typing import Optional
43

54
from scaleway_core.bridge import Zone
@@ -46,7 +45,7 @@ class SetServerUserDataRequest:
4645
Key defines the user data key to set
4746
"""
4847

49-
content: StringIO
48+
content: bytes
5049
"""
51-
Content defines the data to set
50+
Content defines the data to set as bytes
5251
"""

0 commit comments

Comments
 (0)