From cfca0e59a5143051afc86ac31027ff8f5783c8c1 Mon Sep 17 00:00:00 2001 From: wuchen Date: Thu, 31 Dec 2020 19:24:52 +0800 Subject: [PATCH] release python sdk 1.0.28 --- PKG-INFO | 4 ++-- examples/cdn/queryTask.py | 11 ++++++----- openstack/cdn/v1/_proxy.py | 7 ++++--- openstack/cdn/v1/task.py | 10 +++++----- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/PKG-INFO b/PKG-INFO index d12d055..389423d 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,13 +1,13 @@ Metadata-Version: 1.1 Name: huaweicloud-sdk-python -Version: 1.0.27 +Version: 1.0.28 Summary: An SDK for building applications to work with OpenStack Home-page: https://github.com/huaweicloud/huaweicloud-sdk-python Author: "HuaweiCloud SDK" Author-email: "hwcloudsdk@huawei.com" License: Apache LICENSE 2.0 Description: Python SDK for Cloud - + Platform: UNKNOWN Classifier: Environment :: OpenStack Classifier: Intended Audience :: Information Technology diff --git a/examples/cdn/queryTask.py b/examples/cdn/queryTask.py index 4e2f136..83d7d37 100644 --- a/examples/cdn/queryTask.py +++ b/examples/cdn/queryTask.py @@ -57,15 +57,16 @@ def query_task(): now = time.time() end_date = int(now * 1000) start_date = end_date - 3600 * 1000 - tasks = conn.cdn.tasks(page_size=100, page_number=1, start_date=start_date, end_date=end_date) + tasks = conn.cdn.tasks(page_size=100, page_number=1, start_date=start_date, end_date=end_date, + enterprise_project_id='ALL') task_list = list(tasks) print(task_list) # Querying Details About a Cache Refreshing or Preheating Task -def query_task_detail(_task_id): +def query_task_detail(task_id): print("query task detail by id:") - task_detail = conn.cdn.get_task(_task_id) + task_detail = conn.cdn.get_task(task_id, page_size=30, page_number=1, enterprise_project_id='ALL') print(task_detail) @@ -76,5 +77,5 @@ def query_task_detail(_task_id): query_task() # Querying Details About a Cache Refreshing or Preheating Task - task_id = 'xxxxxxx' - query_task_detail(task_id) + history_task_id = 'xxxxxxx' + query_task_detail(history_task_id) diff --git a/openstack/cdn/v1/_proxy.py b/openstack/cdn/v1/_proxy.py index 0804f0d..b28b462 100644 --- a/openstack/cdn/v1/_proxy.py +++ b/openstack/cdn/v1/_proxy.py @@ -712,17 +712,18 @@ def tasks(self, page_size=100, page_number=1, **query): paginated=True) return self._list(_task.Task, **query) - def get_task(self, task): + def get_task(self, task_id, **params): """Get details about a cache refreshing or preheating task - :param task: The value can be the ID of a task or a + :param task_id: The value can be the ID of a task or a :class:`~openstack.cdn.v1.task.Task` instance. :returns: One :class:`~openstack.cdn.v1.task.Task` :raises: :class:`~openstack.exceptions.ResourceNotFound` when no resource can be found. """ - return self._get(_task.Task, task) + res = self._get_resource(_task.Task, task_id) + return res.get(self._session, **params) def create_refresh_task(self, **attrs): """Create a new cache refresh task from attributes diff --git a/openstack/cdn/v1/task.py b/openstack/cdn/v1/task.py index f49eb28..5ac1416 100644 --- a/openstack/cdn/v1/task.py +++ b/openstack/cdn/v1/task.py @@ -32,7 +32,7 @@ class Task(cdn_resource.Resource): _query_mapping = cdn_resource.QueryParameters('status', 'start_date', 'end_date', 'order_field', 'order_type', - 'user_domain_id') + 'user_domain_id', 'enterprise_project_id') #: The type of a task. The value is either 'refresh' or 'preheating'. task_type = resource.Body('task_type') @@ -95,7 +95,7 @@ def list(cls, session, paginated=False, **params): params['order_field'] = mapping[params['order_field']] return super(Task, cls).list(session, paginated=paginated, **params) - def get(self, session, requires_id=True): + def get(self, session, requires_id=True, **params): """Get a remote resource based on this instance. :param session: The session to use for making this request. @@ -107,11 +107,10 @@ def get(self, session, requires_id=True): :rtype: :class:`~openstack.cdn.v1.task.Task` """ request = self._prepare_request(requires_id=requires_id) - # NOTE(samsong8610): The URL for GET is not standard. request.uri = utils.urljoin(request.uri, 'detail') endpoint_override = self.service.get_endpoint_override() response = session.get(request.uri, endpoint_filter=self.service, - endpoint_override=endpoint_override) + endpoint_override=endpoint_override, params=params) self._translate_response(response) return self @@ -165,6 +164,7 @@ def create(self, session, prepend_key=True): self._translate_response(response) return self + class PreheatTask(Task): base_path = '/cdn/preheatingtasks' resource_key = 'preheatingTask' @@ -204,4 +204,4 @@ def create(self, session, prepend_key=True): json=request.body, headers=request.headers, params={"enterprise_project_id": 'ALL'}) self._translate_response(response) - return self \ No newline at end of file + return self