1717import pkg_resources
1818import warnings
1919
20+ from google .oauth2 import service_account
2021import google .api_core .gapic_v1 .client_info
2122import google .api_core .gapic_v1 .config
2223import google .api_core .gapic_v1 .method
@@ -57,6 +58,27 @@ class CloudTasksClient(object):
5758 # find the method configuration in the client_config dictionary.
5859 _INTERFACE_NAME = 'google.cloud.tasks.v2beta2.CloudTasks'
5960
61+ @classmethod
62+ def from_service_account_file (cls , filename , * args , ** kwargs ):
63+ """Creates an instance of this client using the provided credentials
64+ file.
65+
66+ Args:
67+ filename (str): The path to the service account private key json
68+ file.
69+ args: Additional arguments to pass to the constructor.
70+ kwargs: Additional arguments to pass to the constructor.
71+
72+ Returns:
73+ CloudTasksClient: The constructed client.
74+ """
75+ credentials = service_account .Credentials .from_service_account_file (
76+ filename )
77+ kwargs ['credentials' ] = credentials
78+ return cls (* args , ** kwargs )
79+
80+ from_service_account_json = from_service_account_file
81+
6082 @classmethod
6183 def project_path (cls , project ):
6284 """Return a fully-qualified project string."""
@@ -156,11 +178,12 @@ def __init__(self,
156178 'Received both a transport instance and '
157179 'credentials; these are mutually exclusive.' )
158180 self .transport = transport
159- self .transport = cloud_tasks_grpc_transport .CloudTasksGrpcTransport (
160- address = self .SERVICE_ADDRESS ,
161- channel = channel ,
162- credentials = credentials ,
163- )
181+ else :
182+ self .transport = cloud_tasks_grpc_transport .CloudTasksGrpcTransport (
183+ address = self .SERVICE_ADDRESS ,
184+ channel = channel ,
185+ credentials = credentials ,
186+ )
164187
165188 if client_info is None :
166189 client_info = (
@@ -226,7 +249,7 @@ def list_queues(self,
226249 described in
227250 `Stackdriver's Advanced Logs Filters <https://cloud.google.com/logging/docs/view/advanced_filters>`_.
228251
229- Sample filter \" app_engine_http_target: *\" .
252+ Sample filter \" app_engine_http_target: \ *\" .
230253
231254 Note that using filters might cause fewer queues than the
232255 requested_page size to be returned.
@@ -381,7 +404,7 @@ def create_queue(self,
381404 WARNING: Using this method may have unintended side effects if you are
382405 using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your queues.
383406 Read
384- `Overview of Queue Management and queue.yaml <https://cloud.google.com/cloud- tasks/docs/queue-yaml>`_
407+ `Overview of Queue Management and queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`_
385408 before using this method.
386409
387410 Example:
@@ -480,7 +503,7 @@ def update_queue(self,
480503 WARNING: Using this method may have unintended side effects if you are
481504 using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your queues.
482505 Read
483- `Overview of Queue Management and queue.yaml <https://cloud.google.com/cloud- tasks/docs/queue-yaml>`_
506+ `Overview of Queue Management and queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`_
484507 before using this method.
485508
486509 Example:
@@ -575,7 +598,7 @@ def delete_queue(self,
575598 WARNING: Using this method may have unintended side effects if you are
576599 using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your queues.
577600 Read
578- `Overview of Queue Management and queue.yaml <https://cloud.google.com/cloud- tasks/docs/queue-yaml>`_
601+ `Overview of Queue Management and queue.yaml <https://cloud.google.com/tasks/docs/queue-yaml>`_
579602 before using this method.
580603
581604 Example:
@@ -797,7 +820,7 @@ def resume_queue(self,
797820 WARNING: Resuming many high-QPS queues at the same time can
798821 lead to target overloading. If you are resuming high-QPS
799822 queues, follow the 500/50/5 pattern described in
800- `Managing Cloud Tasks Scaling Risks <https://cloud.google.com/cloud- tasks/pdfs/managing -cloud-tasks -scaling-risks-2017-06-05.pdf >`_.
823+ `Managing Cloud Tasks Scaling Risks <https://cloud.google.com/tasks/docs/manage -cloud-task -scaling>`_.
801824
802825 Example:
803826 >>> from google.cloud import tasks_v2beta2
@@ -869,8 +892,9 @@ def get_iam_policy(self,
869892 Returns an empty policy if the resource exists and does not have a policy
870893 set.
871894
872- Authorization requires the following `Google IAM <https://cloud.google.com/iam>`_ permission on the
873- specified resource parent:
895+ Authorization requires the following
896+ `Google IAM <https://cloud.google.com/iam>`__ permission on the specified
897+ resource parent:
874898
875899 * ``cloudtasks.queues.getIamPolicy``
876900
@@ -946,8 +970,9 @@ def set_iam_policy(self,
946970 Note: The Cloud Console does not check queue-level IAM permissions yet.
947971 Project-level permissions are required to use the Cloud Console.
948972
949- Authorization requires the following `Google IAM <https://cloud.google.com/iam>`_ permission on the
950- specified resource parent:
973+ Authorization requires the following
974+ `Google IAM <https://cloud.google.com/iam>`__ permission on the specified
975+ resource parent:
951976
952977 * ``cloudtasks.queues.setIamPolicy``
953978
@@ -1110,7 +1135,6 @@ def test_iam_permissions(self,
11101135 def list_tasks (self ,
11111136 parent ,
11121137 response_view = None ,
1113- order_by = None ,
11141138 page_size = None ,
11151139 retry = google .api_core .gapic_v1 .method .DEFAULT ,
11161140 timeout = google .api_core .gapic_v1 .method .DEFAULT ,
@@ -1123,6 +1147,9 @@ def list_tasks(self,
11231147 ``response_view`` controls the
11241148 subset of information which is returned.
11251149
1150+ The tasks may be returned in any order. The ordering may change at any
1151+ time.
1152+
11261153 Example:
11271154 >>> from google.cloud import tasks_v2beta2
11281155 >>>
@@ -1159,12 +1186,8 @@ def list_tasks(self,
11591186 contains.
11601187
11611188 Authorization for ``FULL`` requires
1162- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1163- ``Task`` resource.
1164- order_by (str): Sort order used for the query. The only fields supported for sorting
1165- are ``schedule_time`` and ``pull_message.tag``. All results will be
1166- returned in approximately ascending order. The default ordering is by
1167- ``schedule_time``.
1189+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1190+ permission on the ``Task`` resource.
11681191 page_size (int): The maximum number of resources contained in the
11691192 underlying API response. If page streaming is performed per-
11701193 resource, this parameter does not affect the return value. If page
@@ -1205,7 +1228,6 @@ def list_tasks(self,
12051228 request = cloudtasks_pb2 .ListTasksRequest (
12061229 parent = parent ,
12071230 response_view = response_view ,
1208- order_by = order_by ,
12091231 page_size = page_size ,
12101232 )
12111233 if metadata is None :
@@ -1267,8 +1289,8 @@ def get_task(self,
12671289 contains.
12681290
12691291 Authorization for ``FULL`` requires
1270- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1271- ``Task`` resource.
1292+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1293+ permission on the ``Task`` resource.
12721294 retry (Optional[google.api_core.retry.Retry]): A retry object used
12731295 to retry requests. If ``None`` is specified, requests will not
12741296 be retried.
@@ -1329,10 +1351,9 @@ def create_task(self,
13291351
13301352 Tasks cannot be updated after creation; there is no UpdateTask command.
13311353
1332- * For `App Engine queues <https://cloud.google.comgoogle.cloud.tasks.v2beta2.AppEngineHttpTarget>`_,
1333- the maximum task size is 100KB.
1334- * For `pull queues <https://cloud.google.comgoogle.cloud.tasks.v2beta2.PullTarget>`_, this
1335- the maximum task size is 1MB.
1354+ * For ``App Engine queues``, the maximum task size is
1355+ 100KB.
1356+ * For ``pull queues``, the maximum task size is 1MB.
13361357
13371358 Example:
13381359 >>> from google.cloud import tasks_v2beta2
@@ -1400,8 +1421,8 @@ def create_task(self,
14001421 contains.
14011422
14021423 Authorization for ``FULL`` requires
1403- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1404- ``Task`` resource.
1424+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1425+ permission on the ``Task`` resource.
14051426 retry (Optional[google.api_core.retry.Retry]): A retry object used
14061427 to retry requests. If ``None`` is specified, requests will not
14071428 be retried.
@@ -1596,8 +1617,8 @@ def lease_tasks(self,
15961617 contains.
15971618
15981619 Authorization for ``FULL`` requires
1599- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1600- ``Task`` resource.
1620+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1621+ permission on the ``Task`` resource.
16011622 filter_ (str): ``filter`` can be used to specify a subset of tasks to lease.
16021623
16031624 When ``filter`` is set to ``tag=<my-tag>`` then the
@@ -1835,8 +1856,8 @@ def renew_lease(self,
18351856 contains.
18361857
18371858 Authorization for ``FULL`` requires
1838- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1839- ``Task`` resource.
1859+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1860+ permission on the ``Task`` resource.
18401861 retry (Optional[google.api_core.retry.Retry]): A retry object used
18411862 to retry requests. If ``None`` is specified, requests will not
18421863 be retried.
@@ -1938,8 +1959,8 @@ def cancel_lease(self,
19381959 contains.
19391960
19401961 Authorization for ``FULL`` requires
1941- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
1942- ``Task`` resource.
1962+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
1963+ permission on the ``Task`` resource.
19431964 retry (Optional[google.api_core.retry.Retry]): A retry object used
19441965 to retry requests. If ``None`` is specified, requests will not
19451966 be retried.
@@ -2049,8 +2070,8 @@ def run_task(self,
20492070 contains.
20502071
20512072 Authorization for ``FULL`` requires
2052- ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_ permission on the
2053- ``Task`` resource.
2073+ ``cloudtasks.tasks.fullView`` `Google IAM <https://cloud.google.com/iam/>`_
2074+ permission on the ``Task`` resource.
20542075 retry (Optional[google.api_core.retry.Retry]): A retry object used
20552076 to retry requests. If ``None`` is specified, requests will not
20562077 be retried.
0 commit comments