diff options
-rw-r--r-- | saharaclient/api/base.py | 8 | ||||
-rw-r--r-- | saharaclient/api/cluster_templates.py | 6 | ||||
-rw-r--r-- | saharaclient/api/clusters.py | 6 | ||||
-rw-r--r-- | saharaclient/api/data_sources.py | 6 | ||||
-rw-r--r-- | saharaclient/api/job_binaries.py | 6 | ||||
-rw-r--r-- | saharaclient/api/job_binary_internals.py | 6 | ||||
-rw-r--r-- | saharaclient/api/job_executions.py | 6 | ||||
-rw-r--r-- | saharaclient/api/jobs.py | 6 | ||||
-rw-r--r-- | saharaclient/api/node_group_templates.py | 6 |
9 files changed, 39 insertions, 17 deletions
diff --git a/saharaclient/api/base.py b/saharaclient/api/base.py index aae3211..36c9e45 100644 --- a/saharaclient/api/base.py +++ b/saharaclient/api/base.py @@ -251,12 +251,18 @@ class APIException(Exception): self.error_message = error_message -def get_query_string(search_opts, limit=None, marker=None): +def get_query_string(search_opts, limit=None, marker=None, sort_by=None, + reverse=None): opts = {} if marker is not None: opts['marker'] = marker if limit is not None: opts['limit'] = limit + if sort_by is not None: + if reverse: + opts['sort_by'] = "-%s" % sort_by + else: + opts['sort_by'] = sort_by if search_opts is not None: opts.update(search_opts) if opts: diff --git a/saharaclient/api/cluster_templates.py b/saharaclient/api/cluster_templates.py index 395b3e0..533cb1f 100644 --- a/saharaclient/api/cluster_templates.py +++ b/saharaclient/api/cluster_templates.py @@ -77,9 +77,11 @@ class ClusterTemplateManager(base.ResourceManager): return self._update('/cluster-templates/%s' % cluster_template_id, data, 'cluster_template') - def list(self, search_opts=None, marker=None, limit=None): + def list(self, search_opts=None, marker=None, + limit=None, sort_by=None, reverse=None): """Get list of Cluster Templates.""" - query = base.get_query_string(search_opts, marker=marker, limit=limit) + query = base.get_query_string(search_opts, marker=marker, limit=limit, + sort_by=sort_by, reverse=reverse) url = "/cluster-templates%s" % query return self._page(url, 'cluster_templates', limit) diff --git a/saharaclient/api/clusters.py b/saharaclient/api/clusters.py index 9ceab3f..fde5916 100644 --- a/saharaclient/api/clusters.py +++ b/saharaclient/api/clusters.py @@ -100,9 +100,11 @@ class ClusterManager(base.ResourceManager): """ return self._update('/clusters/%s' % cluster_id, scale_object) - def list(self, search_opts=None, limit=None, marker=None): + def list(self, search_opts=None, limit=None, marker=None, + sort_by=None, reverse=None): """Get a list of Clusters.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/clusters%s" % query return self._page(url, 'clusters', limit) diff --git a/saharaclient/api/data_sources.py b/saharaclient/api/data_sources.py index 22c06c9..112cca5 100644 --- a/saharaclient/api/data_sources.py +++ b/saharaclient/api/data_sources.py @@ -44,9 +44,11 @@ class DataSourceManager(base.ResourceManager): return self._create('/data-sources', data, 'data_source') - def list(self, search_opts=None, limit=None, marker=None): + def list(self, search_opts=None, limit=None, marker=None, + sort_by=None, reverse=None): """Get a list of Data Sources.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/data-sources%s" % query return self._page(url, 'data_sources', limit) diff --git a/saharaclient/api/job_binaries.py b/saharaclient/api/job_binaries.py index 8fc540e..38637e3 100644 --- a/saharaclient/api/job_binaries.py +++ b/saharaclient/api/job_binaries.py @@ -36,9 +36,11 @@ class JobBinariesManager(base.ResourceManager): return self._create('/job-binaries', data, 'job_binary') - def list(self, search_opts=None, limit=None, marker=None): + def list(self, search_opts=None, limit=None, marker=None, + sort_by=None, reverse=None): """Get a list of Job Binaries.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/job-binaries%s" % query return self._page(url, 'binaries', limit) diff --git a/saharaclient/api/job_binary_internals.py b/saharaclient/api/job_binary_internals.py index f19dc15..9c7b139 100644 --- a/saharaclient/api/job_binary_internals.py +++ b/saharaclient/api/job_binary_internals.py @@ -35,9 +35,11 @@ class JobBinaryInternalsManager(base.ResourceManager): urlparse.quote(name.encode('utf-8')), data, 'job_binary_internal', dump_json=False) - def list(self, search_opts=None, limit=None, marker=None): + def list(self, search_opts=None, limit=None, marker=None, + sort_by=None, reverse=None): """Get a list of Job Binary Internals.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/job-binary-internals%s" % query return self._page(url, 'binaries', limit) diff --git a/saharaclient/api/job_executions.py b/saharaclient/api/job_executions.py index e696fa1..a76597a 100644 --- a/saharaclient/api/job_executions.py +++ b/saharaclient/api/job_executions.py @@ -24,9 +24,11 @@ class JobExecutionsManager(base.ResourceManager): resource_class = JobExecution NotUpdated = base.NotUpdated() - def list(self, search_opts=None, marker=None, limit=None): + def list(self, search_opts=None, marker=None, limit=None, + sort_by=None, reverse=None): """Get a list of Job Executions.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/job-executions%s" % query return self._page(url, 'job_executions', limit) diff --git a/saharaclient/api/jobs.py b/saharaclient/api/jobs.py index 7f92aff..8fdde51 100644 --- a/saharaclient/api/jobs.py +++ b/saharaclient/api/jobs.py @@ -38,9 +38,11 @@ class JobsManager(base.ResourceManager): return self._create('/jobs', data, 'job') - def list(self, search_opts=None, limit=None, marker=None): + def list(self, search_opts=None, limit=None, + marker=None, sort_by=None, reverse=None): """Get a list of Jobs.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/jobs%s" % query return self._page(url, 'jobs', limit) diff --git a/saharaclient/api/node_group_templates.py b/saharaclient/api/node_group_templates.py index aca358c..90c1b4d 100644 --- a/saharaclient/api/node_group_templates.py +++ b/saharaclient/api/node_group_templates.py @@ -111,9 +111,11 @@ class NodeGroupTemplateManager(base.ResourceManager): return self._update('/node-group-templates/%s' % ng_template_id, data, 'node_group_template') - def list(self, search_opts=None, marker=None, limit=None): + def list(self, search_opts=None, marker=None, + limit=None, sort_by=None, reverse=None): """Get a list of Node Group Templates.""" - query = base.get_query_string(search_opts, limit=limit, marker=marker) + query = base.get_query_string(search_opts, limit=limit, marker=marker, + sort_by=sort_by, reverse=reverse) url = "/node-group-templates%s" % query return self._page(url, 'node_group_templates', limit) |