diff --git a/scaleway/scaleway/instance/v1/custom_api.py b/scaleway/scaleway/instance/v1/custom_api.py index 61f0865c8..3a41d68c1 100644 --- a/scaleway/scaleway/instance/v1/custom_api.py +++ b/scaleway/scaleway/instance/v1/custom_api.py @@ -78,15 +78,21 @@ def set_server_user_data( self._throw_on_error(res) return res - def get_all_server_user_data(self, server_id: str, zone: Optional[ScwZone] = None) -> GetAllServerUserDataResponse: + def get_all_server_user_data( + self, server_id: str, zone: Optional[ScwZone] = None + ) -> GetAllServerUserDataResponse: param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - all_user_data_res = InstanceUtilsV1API.list_server_user_data(self, server_id=param_server_id, zone=param_zone) + all_user_data_res = InstanceUtilsV1API.list_server_user_data( + self, server_id=param_server_id, zone=param_zone + ) - user_data: Dict[str,bytes] = {} + user_data: Dict[str, bytes] = {} for key in all_user_data_res.user_data: - value = InstanceUtilsV1API.get_server_user_data(self, server_id=param_server_id, key=key) + value = InstanceUtilsV1API.get_server_user_data( + self, server_id=param_server_id, key=key + ) print("value: ", value) user_data[key] = value.content @@ -94,20 +100,30 @@ def get_all_server_user_data(self, server_id: str, zone: Optional[ScwZone] = Non return res - def set_all_server_user_data(self, server_id: str, user_data: Dict[str, bytes], zone: Optional[ScwZone] = None): + def set_all_server_user_data( + self, + server_id: str, + user_data: Dict[str, bytes], + zone: Optional[ScwZone] = None, + ): param_zone = validate_path_param("zone", zone or self.client.default_zone) param_server_id = validate_path_param("server_id", server_id) - all_user_data_res = InstanceUtilsV1API.list_server_user_data(self, server_id=param_server_id, zone=param_zone) + all_user_data_res = InstanceUtilsV1API.list_server_user_data( + self, server_id=param_server_id, zone=param_zone + ) for key in all_user_data_res.user_data: if user_data.get(key) is not None: continue - InstanceUtilsV1API.delete_server_user_data(self, server_id=param_server_id, key=key) + InstanceUtilsV1API.delete_server_user_data( + self, server_id=param_server_id, key=key + ) for key in user_data: - InstanceUtilsV1API.set_server_user_data(self, server_id=param_server_id, zone=param_zone, key=key, content=user_data[key]) - - - - - + InstanceUtilsV1API.set_server_user_data( + self, + server_id=param_server_id, + zone=param_zone, + key=key, + content=user_data[key], + ) diff --git a/scaleway/scaleway/instance/v1/custom_marshalling.py b/scaleway/scaleway/instance/v1/custom_marshalling.py index b26432890..a4f3c840a 100644 --- a/scaleway/scaleway/instance/v1/custom_marshalling.py +++ b/scaleway/scaleway/instance/v1/custom_marshalling.py @@ -21,7 +21,10 @@ def marshal_GetServerUserDataRequest( return output -def marshal_ListServerUserDataRequest(request: GetAllServerUserDataRequest, defaults: ProfileDefaults) -> Dict[str, Any]: + +def marshal_ListServerUserDataRequest( + request: GetAllServerUserDataRequest, defaults: ProfileDefaults +) -> Dict[str, Any]: output: Dict[str, Any] = {} if request.server_id is not None: @@ -29,4 +32,4 @@ def marshal_ListServerUserDataRequest(request: GetAllServerUserDataRequest, defa if request.zone is not None: output["zone"] = request.zone - return output \ No newline at end of file + return output diff --git a/scaleway/scaleway/instance/v1/custom_types.py b/scaleway/scaleway/instance/v1/custom_types.py index 33015a482..2e765ded2 100644 --- a/scaleway/scaleway/instance/v1/custom_types.py +++ b/scaleway/scaleway/instance/v1/custom_types.py @@ -18,6 +18,7 @@ class GetServerUserDataRequest: Key defines the user data key to get """ + @dataclass class GetAllServerUserDataRequest: zone: Optional[Zone] @@ -27,10 +28,12 @@ class GetAllServerUserDataRequest: server_id: str + @dataclass class GetAllServerUserDataResponse: user_data: Dict[str, bytes] + @dataclass class SetAllServerUserDataRequest: zone: Optional[Zone]