diff options
Diffstat (limited to 'saharaclient/api/base.py')
-rw-r--r-- | saharaclient/api/base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/saharaclient/api/base.py b/saharaclient/api/base.py index a4fc78b..a5323cd 100644 --- a/saharaclient/api/base.py +++ b/saharaclient/api/base.py @@ -64,6 +64,12 @@ def _check_items(obj, searches): return False +class NotUpdated(object): + """A sentinel class to signal that parameter should not be updated.""" + def __repr__(self): + return 'NotUpdated' + + class ResourceManager(object): resource_class = None @@ -88,6 +94,11 @@ class ResourceManager(object): if var_value is not None: data[var_name] = var_value + def _copy_if_updated(self, data, **kwargs): + for var_name, var_value in six.iteritems(kwargs): + if not isinstance(var_value, NotUpdated): + data[var_name] = var_value + def _create(self, url, data, response_key=None, dump_json=True): if dump_json: kwargs = {'json': data} |