From e131789b7a0bfa13a5ab248ec6cc71b3bcd70476 Mon Sep 17 00:00:00 2001 From: Stephen Rosen Date: Thu, 13 Dec 2018 18:17:34 +0000 Subject: [PATCH] Add SearchClient.get_task The new /v1/task/ API is not yet on production, but by adding it to the client it can be used in preproduction environments (e.g. preview). --- globus_sdk/search/client.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/globus_sdk/search/client.py b/globus_sdk/search/client.py index 0612ad9cb..4fdef4f49 100644 --- a/globus_sdk/search/client.py +++ b/globus_sdk/search/client.py @@ -42,6 +42,7 @@ class SearchClient(BaseClient): * :py:meth:`.delete_entry` * :py:meth:`.get_query_template` * :py:meth:`.get_query_template_list` + * :py:meth:`.get_task` """ # disallow basic auth allowed_authorizer_types = [ @@ -521,3 +522,23 @@ def get_query_template_list(self, index_id): self.logger.info("SearchClient.get_query_template_list({})".format(index_id)) path = self.qjoin_path("v1/index", index_id, "query_template") return self.get(path) + + # + # Task Management + # + + def get_task(self, task_id, **params): + """ + ``GET /v1/index/`` + + **Examples** + + >>> sc = globus_sdk.SearchClient(...) + >>> task = sc.get_task(task_id) + >>> assert task['index_id'] == known_index_id + >>> print(task["task_id"] + " | " + task['state']) + """ + task_id = safe_stringify(task_id) + self.logger.info("SearchClient.get_task({})".format(task_id)) + path = self.qjoin_path("v1/task", task_id) + return self.get(path, params=params)