diff --git a/docs/CHANGELOG.rst b/docs/CHANGELOG.rst index 36c03b51..70dd46b6 100644 --- a/docs/CHANGELOG.rst +++ b/docs/CHANGELOG.rst @@ -5,6 +5,15 @@ Change Log All notable changes to this project are documented in this file. +========== +Unreleased +========== + +Added +----- +- Add ``restart`` method to the ``Data`` resource + + =================== 21.1.0 - 2023-02-09 =================== diff --git a/src/resdk/resources/data.py b/src/resdk/resources/data.py index 20b644d7..adabde77 100644 --- a/src/resdk/resources/data.py +++ b/src/resdk/resources/data.py @@ -2,6 +2,7 @@ import json import logging +from typing import Optional from urllib.parse import urljoin from resdk.constants import CHUNK_SIZE @@ -223,6 +224,32 @@ def children(self): return self._children + def restart( + self, + storage: Optional[int] = None, + memory: Optional[int] = None, + cores: Optional[int] = None, + ): + """Restart the data object. + + The units for storage are gigabytes and for memory are megabytes. + + The resources that are not specified (or set no None) are reset to their + default values. + """ + overrides = { + key: value + for key, value in { + "storage": storage, + "memory": memory, + "cores": cores, + }.items() + if value is not None + } + self.resolwe.api.data(self.id).restart.post( + {"resource_overrides": {self.id: overrides}} + ) + def _files_dirs(self, field_type, file_name=None, field_name=None): """Get list of downloadable fields.""" download_list = []