From 5e7ce4483d2d114c7d2cb6ee25cc5b49ad5d433e Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 22 Mar 2019 14:27:05 -0700 Subject: [PATCH 1/4] Initial generation of v2 --- tasks/docs/gapic/v2/api.rst | 6 + tasks/docs/gapic/v2/types.rst | 5 + tasks/google/cloud/tasks.py | 6 +- tasks/google/cloud/tasks_v2/__init__.py | 29 + tasks/google/cloud/tasks_v2/gapic/__init__.py | 0 .../tasks_v2/gapic/cloud_tasks_client.py | 1693 +++++++++++++++++ .../gapic/cloud_tasks_client_config.py | 103 + tasks/google/cloud/tasks_v2/gapic/enums.py | 112 ++ .../tasks_v2/gapic/transports/__init__.py | 0 .../transports/cloud_tasks_grpc_transport.py | 414 ++++ tasks/google/cloud/tasks_v2/proto/__init__.py | 0 .../cloud/tasks_v2/proto/cloudtasks.proto | 601 ++++++ .../cloud/tasks_v2/proto/cloudtasks_pb2.py | 1585 +++++++++++++++ .../tasks_v2/proto/cloudtasks_pb2_grpc.py | 437 +++++ tasks/google/cloud/tasks_v2/proto/queue.proto | 342 ++++ .../google/cloud/tasks_v2/proto/queue_pb2.py | 687 +++++++ .../cloud/tasks_v2/proto/queue_pb2_grpc.py | 2 + .../google/cloud/tasks_v2/proto/target.proto | 274 +++ .../google/cloud/tasks_v2/proto/target_pb2.py | 600 ++++++ .../cloud/tasks_v2/proto/target_pb2_grpc.py | 2 + tasks/google/cloud/tasks_v2/proto/task.proto | 182 ++ tasks/google/cloud/tasks_v2/proto/task_pb2.py | 549 ++++++ .../cloud/tasks_v2/proto/task_pb2_grpc.py | 2 + tasks/google/cloud/tasks_v2/types.py | 60 + tasks/synth.metadata | 20 +- tasks/synth.py | 2 +- .../gapic/v2/test_cloud_tasks_client_v2.py | 702 +++++++ 27 files changed, 8406 insertions(+), 9 deletions(-) create mode 100644 tasks/docs/gapic/v2/api.rst create mode 100644 tasks/docs/gapic/v2/types.rst create mode 100644 tasks/google/cloud/tasks_v2/__init__.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/__init__.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/enums.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/transports/__init__.py create mode 100644 tasks/google/cloud/tasks_v2/gapic/transports/cloud_tasks_grpc_transport.py create mode 100644 tasks/google/cloud/tasks_v2/proto/__init__.py create mode 100644 tasks/google/cloud/tasks_v2/proto/cloudtasks.proto create mode 100644 tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2.py create mode 100644 tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2_grpc.py create mode 100644 tasks/google/cloud/tasks_v2/proto/queue.proto create mode 100644 tasks/google/cloud/tasks_v2/proto/queue_pb2.py create mode 100644 tasks/google/cloud/tasks_v2/proto/queue_pb2_grpc.py create mode 100644 tasks/google/cloud/tasks_v2/proto/target.proto create mode 100644 tasks/google/cloud/tasks_v2/proto/target_pb2.py create mode 100644 tasks/google/cloud/tasks_v2/proto/target_pb2_grpc.py create mode 100644 tasks/google/cloud/tasks_v2/proto/task.proto create mode 100644 tasks/google/cloud/tasks_v2/proto/task_pb2.py create mode 100644 tasks/google/cloud/tasks_v2/proto/task_pb2_grpc.py create mode 100644 tasks/google/cloud/tasks_v2/types.py create mode 100644 tasks/tests/unit/gapic/v2/test_cloud_tasks_client_v2.py diff --git a/tasks/docs/gapic/v2/api.rst b/tasks/docs/gapic/v2/api.rst new file mode 100644 index 0000000000000..229856fbde37a --- /dev/null +++ b/tasks/docs/gapic/v2/api.rst @@ -0,0 +1,6 @@ +Client for Cloud Tasks API +========================== + +.. automodule:: google.cloud.tasks_v2 + :members: + :inherited-members: \ No newline at end of file diff --git a/tasks/docs/gapic/v2/types.rst b/tasks/docs/gapic/v2/types.rst new file mode 100644 index 0000000000000..8e518bb887ddd --- /dev/null +++ b/tasks/docs/gapic/v2/types.rst @@ -0,0 +1,5 @@ +Types for Cloud Tasks API Client +================================ + +.. automodule:: google.cloud.tasks_v2.types + :members: \ No newline at end of file diff --git a/tasks/google/cloud/tasks.py b/tasks/google/cloud/tasks.py index 7039fe5f91e3c..eaa1321118c76 100644 --- a/tasks/google/cloud/tasks.py +++ b/tasks/google/cloud/tasks.py @@ -16,8 +16,8 @@ from __future__ import absolute_import -from google.cloud.tasks_v2beta3 import CloudTasksClient -from google.cloud.tasks_v2beta3 import enums -from google.cloud.tasks_v2beta3 import types +from google.cloud.tasks_v2 import CloudTasksClient +from google.cloud.tasks_v2 import enums +from google.cloud.tasks_v2 import types __all__ = ("enums", "types", "CloudTasksClient") diff --git a/tasks/google/cloud/tasks_v2/__init__.py b/tasks/google/cloud/tasks_v2/__init__.py new file mode 100644 index 0000000000000..0361a52b3c78c --- /dev/null +++ b/tasks/google/cloud/tasks_v2/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import + +from google.cloud.tasks_v2 import types +from google.cloud.tasks_v2.gapic import cloud_tasks_client +from google.cloud.tasks_v2.gapic import enums + + +class CloudTasksClient(cloud_tasks_client.CloudTasksClient): + __doc__ = cloud_tasks_client.CloudTasksClient.__doc__ + enums = enums + + +__all__ = ("enums", "types", "CloudTasksClient") diff --git a/tasks/google/cloud/tasks_v2/gapic/__init__.py b/tasks/google/cloud/tasks_v2/gapic/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client.py b/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client.py new file mode 100644 index 0000000000000..70fad4917b47b --- /dev/null +++ b/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client.py @@ -0,0 +1,1693 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Accesses the google.cloud.tasks.v2 CloudTasks API.""" + +import functools +import pkg_resources +import warnings + +from google.oauth2 import service_account +import google.api_core.gapic_v1.client_info +import google.api_core.gapic_v1.config +import google.api_core.gapic_v1.method +import google.api_core.gapic_v1.routing_header +import google.api_core.grpc_helpers +import google.api_core.page_iterator +import google.api_core.path_template +import grpc + +from google.cloud.tasks_v2.gapic import cloud_tasks_client_config +from google.cloud.tasks_v2.gapic import enums +from google.cloud.tasks_v2.gapic.transports import cloud_tasks_grpc_transport +from google.cloud.tasks_v2.proto import cloudtasks_pb2 +from google.cloud.tasks_v2.proto import cloudtasks_pb2_grpc +from google.cloud.tasks_v2.proto import queue_pb2 +from google.cloud.tasks_v2.proto import task_pb2 +from google.iam.v1 import iam_policy_pb2 +from google.iam.v1 import policy_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-tasks").version + + +class CloudTasksClient(object): + """ + Cloud Tasks allows developers to manage the execution of background + work in their applications. + """ + + SERVICE_ADDRESS = "cloudtasks.googleapis.com:443" + """The default address of the service.""" + + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. + _INTERFACE_NAME = "google.cloud.tasks.v2.CloudTasks" + + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + CloudTasksClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + @classmethod + def project_path(cls, project): + """Return a fully-qualified project string.""" + return google.api_core.path_template.expand( + "projects/{project}", project=project + ) + + @classmethod + def location_path(cls, project, location): + """Return a fully-qualified location string.""" + return google.api_core.path_template.expand( + "projects/{project}/locations/{location}", + project=project, + location=location, + ) + + @classmethod + def queue_path(cls, project, location, queue): + """Return a fully-qualified queue string.""" + return google.api_core.path_template.expand( + "projects/{project}/locations/{location}/queues/{queue}", + project=project, + location=location, + queue=queue, + ) + + @classmethod + def task_path(cls, project, location, queue, task): + """Return a fully-qualified task string.""" + return google.api_core.path_template.expand( + "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}", + project=project, + location=location, + queue=queue, + task=task, + ) + + def __init__( + self, + transport=None, + channel=None, + credentials=None, + client_config=None, + client_info=None, + ): + """Constructor. + + Args: + transport (Union[~.CloudTasksGrpcTransport, + Callable[[~.Credentials, type], ~.CloudTasksGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + """ + # Raise deprecation warnings for things we want to go away. + if client_config is not None: + warnings.warn( + "The `client_config` argument is deprecated.", + PendingDeprecationWarning, + stacklevel=2, + ) + else: + client_config = cloud_tasks_client_config.config + + if channel: + warnings.warn( + "The `channel` argument is deprecated; use " "`transport` instead.", + PendingDeprecationWarning, + stacklevel=2, + ) + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=cloud_tasks_grpc_transport.CloudTasksGrpcTransport, + ) + else: + if credentials: + raise ValueError( + "Received both a transport instance and " + "credentials; these are mutually exclusive." + ) + self.transport = transport + else: + self.transport = cloud_tasks_grpc_transport.CloudTasksGrpcTransport( + address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials + ) + + if client_info is None: + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + gapic_version=_GAPIC_LIBRARY_VERSION + ) + else: + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info + + # Parse out the default settings for retry and timeout for each RPC + # from the client configuration. + # (Ordinarily, these are the defaults specified in the `*_config.py` + # file next to this one.) + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config["interfaces"][self._INTERFACE_NAME] + ) + + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} + + # Service calls + def list_queues( + self, + parent, + filter_=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists queues. + + Queues are returned in lexicographical order. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> parent = client.location_path('[PROJECT]', '[LOCATION]') + >>> + >>> # Iterate over all results + >>> for element in client.list_queues(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_queues(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. + + The location name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID`` + filter_ (str): ``filter`` can be used to specify a subset of queues. Any ``Queue`` + field can be used as a filter and several operators as supported. For + example: ``<=, <, >=, >, !=, =, :``. The filter syntax is the same as + described in `Stackdriver's Advanced Logs + Filters `__. + + Sample filter "state: PAUSED". + + Note that using filters might cause fewer queues than the requested + page\_size to be returned. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.tasks_v2.types.Queue` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_queues" not in self._inner_api_calls: + self._inner_api_calls[ + "list_queues" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_queues, + default_retry=self._method_configs["ListQueues"].retry, + default_timeout=self._method_configs["ListQueues"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.ListQueuesRequest( + parent=parent, filter=filter_, page_size=page_size + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_queues"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="queues", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def get_queue( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Gets a queue. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> response = client.get_queue(name) + + Args: + name (str): Required. + + The resource name of the queue. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "get_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "get_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_queue, + default_retry=self._method_configs["GetQueue"].retry, + default_timeout=self._method_configs["GetQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.GetQueueRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["get_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def create_queue( + self, + parent, + queue, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Creates a queue. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless + of whether it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> parent = client.location_path('[PROJECT]', '[LOCATION]') + >>> + >>> # TODO: Initialize `queue`: + >>> queue = {} + >>> + >>> response = client.create_queue(parent, queue) + + Args: + parent (str): Required. + + The location name in which the queue will be created. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID`` + + The list of allowed locations can be obtained by calling Cloud Tasks' + implementation of ``ListLocations``. + queue (Union[dict, ~google.cloud.tasks_v2.types.Queue]): Required. + + The queue to create. + + ``Queue's name`` cannot be the same as an existing queue. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.tasks_v2.types.Queue` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "create_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "create_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_queue, + default_retry=self._method_configs["CreateQueue"].retry, + default_timeout=self._method_configs["CreateQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.CreateQueueRequest(parent=parent, queue=queue) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["create_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def update_queue( + self, + queue, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Updates a queue. + + This method creates the queue if it does not exist and updates the queue + if it does exist. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless + of whether it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> # TODO: Initialize `queue`: + >>> queue = {} + >>> + >>> response = client.update_queue(queue) + + Args: + queue (Union[dict, ~google.cloud.tasks_v2.types.Queue]): Required. + + The queue to create or update. + + The queue's ``name`` must be specified. + + Output only fields cannot be modified using UpdateQueue. Any value + specified for an output only field will be ignored. The queue's ``name`` + cannot be changed. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.tasks_v2.types.Queue` + update_mask (Union[dict, ~google.cloud.tasks_v2.types.FieldMask]): A mask used to specify which fields of the queue are being updated. + + If empty, then all fields will be updated. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.tasks_v2.types.FieldMask` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "update_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "update_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_queue, + default_retry=self._method_configs["UpdateQueue"].retry, + default_timeout=self._method_configs["UpdateQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.UpdateQueueRequest( + queue=queue, update_mask=update_mask + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("queue.name", queue.name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["update_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def delete_queue( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Deletes a queue. + + This command will delete the queue even if it has tasks in it. + + Note: If you delete a queue, a queue with the same name can't be created + for 7 days. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> client.delete_queue(name) + + Args: + name (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "delete_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "delete_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_queue, + default_retry=self._method_configs["DeleteQueue"].retry, + default_timeout=self._method_configs["DeleteQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.DeleteQueueRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + self._inner_api_calls["delete_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def purge_queue( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Purges a queue by deleting all of its tasks. + + All tasks created before this method is called are permanently deleted. + + Purge operations can take up to one minute to take effect. Tasks + might be dispatched before the purge takes effect. A purge is irreversible. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> response = client.purge_queue(name) + + Args: + name (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "purge_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "purge_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.purge_queue, + default_retry=self._method_configs["PurgeQueue"].retry, + default_timeout=self._method_configs["PurgeQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.PurgeQueueRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["purge_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def pause_queue( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Pauses the queue. + + If a queue is paused then the system will stop dispatching tasks until + the queue is resumed via ``ResumeQueue``. Tasks can still be added when + the queue is paused. A queue is paused if its ``state`` is ``PAUSED``. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> response = client.pause_queue(name) + + Args: + name (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "pause_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "pause_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.pause_queue, + default_retry=self._method_configs["PauseQueue"].retry, + default_timeout=self._method_configs["PauseQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.PauseQueueRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["pause_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def resume_queue( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Resume a queue. + + This method resumes a queue after it has been ``PAUSED`` or + ``DISABLED``. The state of a queue is stored in the queue's ``state``; + after calling this method it will be set to ``RUNNING``. + + WARNING: Resuming many high-QPS queues at the same time can lead to + target overloading. If you are resuming high-QPS queues, follow the + 500/50/5 pattern described in `Managing Cloud Tasks Scaling + Risks `__. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> response = client.resume_queue(name) + + Args: + name (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Queue` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "resume_queue" not in self._inner_api_calls: + self._inner_api_calls[ + "resume_queue" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.resume_queue, + default_retry=self._method_configs["ResumeQueue"].retry, + default_timeout=self._method_configs["ResumeQueue"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.ResumeQueueRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["resume_queue"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def get_iam_policy( + self, + resource, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Gets the access control policy for a ``Queue``. Returns an empty policy + if the resource exists and does not have a policy set. + + Authorization requires the following `Google + IAM `__ permission on the specified + resource parent: + + - ``cloudtasks.queues.getIamPolicy`` + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> response = client.get_iam_policy(resource) + + Args: + resource (str): REQUIRED: The resource for which the policy is being requested. + ``resource`` is usually specified as a path. For example, a Project + resource is specified as ``projects/{project}``. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Policy` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "get_iam_policy" not in self._inner_api_calls: + self._inner_api_calls[ + "get_iam_policy" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_iam_policy, + default_retry=self._method_configs["GetIamPolicy"].retry, + default_timeout=self._method_configs["GetIamPolicy"].timeout, + client_info=self._client_info, + ) + + request = iam_policy_pb2.GetIamPolicyRequest(resource=resource) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("resource", resource)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["get_iam_policy"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def set_iam_policy( + self, + resource, + policy, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Sets the access control policy for a ``Queue``. Replaces any existing + policy. + + Note: The Cloud Console does not check queue-level IAM permissions yet. + Project-level permissions are required to use the Cloud Console. + + Authorization requires the following `Google + IAM `__ permission on the specified + resource parent: + + - ``cloudtasks.queues.setIamPolicy`` + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> # TODO: Initialize `policy`: + >>> policy = {} + >>> + >>> response = client.set_iam_policy(resource, policy) + + Args: + resource (str): REQUIRED: The resource for which the policy is being specified. + ``resource`` is usually specified as a path. For example, a Project + resource is specified as ``projects/{project}``. + policy (Union[dict, ~google.cloud.tasks_v2.types.Policy]): REQUIRED: The complete policy to be applied to the ``resource``. The + size of the policy is limited to a few 10s of KB. An empty policy is a + valid policy but certain Cloud Platform services (such as Projects) + might reject them. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.tasks_v2.types.Policy` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Policy` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "set_iam_policy" not in self._inner_api_calls: + self._inner_api_calls[ + "set_iam_policy" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.set_iam_policy, + default_retry=self._method_configs["SetIamPolicy"].retry, + default_timeout=self._method_configs["SetIamPolicy"].timeout, + client_info=self._client_info, + ) + + request = iam_policy_pb2.SetIamPolicyRequest(resource=resource, policy=policy) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("resource", resource)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["set_iam_policy"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def test_iam_permissions( + self, + resource, + permissions, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Returns permissions that a caller has on a ``Queue``. If the resource + does not exist, this will return an empty set of permissions, not a + ``NOT_FOUND`` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> resource = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> # TODO: Initialize `permissions`: + >>> permissions = [] + >>> + >>> response = client.test_iam_permissions(resource, permissions) + + Args: + resource (str): REQUIRED: The resource for which the policy detail is being requested. + ``resource`` is usually specified as a path. For example, a Project + resource is specified as ``projects/{project}``. + permissions (list[str]): The set of permissions to check for the ``resource``. Permissions with + wildcards (such as '*' or 'storage.*') are not allowed. For more + information see `IAM + Overview `__. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.TestIamPermissionsResponse` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "test_iam_permissions" not in self._inner_api_calls: + self._inner_api_calls[ + "test_iam_permissions" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.test_iam_permissions, + default_retry=self._method_configs["TestIamPermissions"].retry, + default_timeout=self._method_configs["TestIamPermissions"].timeout, + client_info=self._client_info, + ) + + request = iam_policy_pb2.TestIamPermissionsRequest( + resource=resource, permissions=permissions + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("resource", resource)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["test_iam_permissions"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def list_tasks( + self, + parent, + response_view=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists the tasks in a queue. + + By default, only the ``BASIC`` view is retrieved due to performance + considerations; ``response_view`` controls the subset of information + which is returned. + + The tasks may be returned in any order. The ordering may change at any + time. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> # Iterate over all results + >>> for element in client.list_tasks(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_tasks(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + response_view (~google.cloud.tasks_v2.types.View): The response\_view specifies which subset of the ``Task`` will be + returned. + + By default response\_view is ``BASIC``; not all information is retrieved + by default because some data, such as payloads, might be desirable to + return only when needed because of its large size or because of the + sensitivity of data that it contains. + + Authorization for ``FULL`` requires ``cloudtasks.tasks.fullView`` + `Google IAM `___ permission on the + ``Task`` resource. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.gax.PageIterator` instance. By default, this + is an iterable of :class:`~google.cloud.tasks_v2.types.Task` instances. + This object can also be configured to iterate over the pages + of the response through the `options` parameter. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_tasks" not in self._inner_api_calls: + self._inner_api_calls[ + "list_tasks" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_tasks, + default_retry=self._method_configs["ListTasks"].retry, + default_timeout=self._method_configs["ListTasks"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.ListTasksRequest( + parent=parent, response_view=response_view, page_size=page_size + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_tasks"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="tasks", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator + + def get_task( + self, + name, + response_view=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Gets a task. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') + >>> + >>> response = client.get_task(name) + + Args: + name (str): Required. + + The task name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + response_view (~google.cloud.tasks_v2.types.View): The response\_view specifies which subset of the ``Task`` will be + returned. + + By default response\_view is ``BASIC``; not all information is retrieved + by default because some data, such as payloads, might be desirable to + return only when needed because of its large size or because of the + sensitivity of data that it contains. + + Authorization for ``FULL`` requires ``cloudtasks.tasks.fullView`` + `Google IAM `___ permission on the + ``Task`` resource. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Task` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "get_task" not in self._inner_api_calls: + self._inner_api_calls[ + "get_task" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_task, + default_retry=self._method_configs["GetTask"].retry, + default_timeout=self._method_configs["GetTask"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.GetTaskRequest(name=name, response_view=response_view) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["get_task"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def create_task( + self, + parent, + task, + response_view=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Creates a task and adds it to a queue. + + Tasks cannot be updated after creation; there is no UpdateTask command. + + - For ``App Engine queues``, the maximum task size is 100KB. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> parent = client.queue_path('[PROJECT]', '[LOCATION]', '[QUEUE]') + >>> + >>> # TODO: Initialize `task`: + >>> task = {} + >>> + >>> response = client.create_task(parent, task) + + Args: + parent (str): Required. + + The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + + The queue must already exist. + task (Union[dict, ~google.cloud.tasks_v2.types.Task]): Required. + + The task to add. + + Task names have the following format: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID``. + The user can optionally specify a task ``name``. If a name is not + specified then the system will generate a random unique task id, which + will be set in the task returned in the ``response``. + + If ``schedule_time`` is not set or is in the past then Cloud Tasks will + set it to the current time. + + Task De-duplication: + + Explicitly specifying a task ID enables task de-duplication. If a task's + ID is identical to that of an existing task or a task that was deleted + or executed recently then the call will fail with ``ALREADY_EXISTS``. If + the task's queue was created using Cloud Tasks, then another task with + the same name can't be created for ~1hour after the original task was + deleted or executed. If the task's queue was created using queue.yaml or + queue.xml, then another task with the same name can't be created for + ~9days after the original task was deleted or executed. + + Because there is an extra lookup cost to identify duplicate task names, + these ``CreateTask`` calls have significantly increased latency. Using + hashed strings for the task id or for the prefix of the task id is + recommended. Choosing task ids that are sequential or have sequential + prefixes, for example using a timestamp, causes an increase in latency + and error rates in all task commands. The infrastructure relies on an + approximately uniform distribution of task ids to store and serve tasks + efficiently. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.tasks_v2.types.Task` + response_view (~google.cloud.tasks_v2.types.View): The response\_view specifies which subset of the ``Task`` will be + returned. + + By default response\_view is ``BASIC``; not all information is retrieved + by default because some data, such as payloads, might be desirable to + return only when needed because of its large size or because of the + sensitivity of data that it contains. + + Authorization for ``FULL`` requires ``cloudtasks.tasks.fullView`` + `Google IAM `___ permission on the + ``Task`` resource. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Task` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "create_task" not in self._inner_api_calls: + self._inner_api_calls[ + "create_task" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.create_task, + default_retry=self._method_configs["CreateTask"].retry, + default_timeout=self._method_configs["CreateTask"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.CreateTaskRequest( + parent=parent, task=task, response_view=response_view + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["create_task"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def delete_task( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Deletes a task. + + A task can be deleted if it is scheduled or dispatched. A task + cannot be deleted if it has executed successfully or permanently + failed. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') + >>> + >>> client.delete_task(name) + + Args: + name (str): Required. + + The task name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "delete_task" not in self._inner_api_calls: + self._inner_api_calls[ + "delete_task" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_task, + default_retry=self._method_configs["DeleteTask"].retry, + default_timeout=self._method_configs["DeleteTask"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.DeleteTaskRequest(name=name) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + self._inner_api_calls["delete_task"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def run_task( + self, + name, + response_view=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Forces a task to run now. + + When this method is called, Cloud Tasks will dispatch the task, even if + the task is already running, the queue has reached its ``RateLimits`` or + is ``PAUSED``. + + This command is meant to be used for manual debugging. For example, + ``RunTask`` can be used to retry a failed task after a fix has been made + or to manually force a task to be dispatched now. + + The dispatched task is returned. That is, the task that is returned + contains the ``status`` after the task is dispatched but before the task + is received by its target. + + If Cloud Tasks receives a successful response from the task's target, + then the task will be deleted; otherwise the task's ``schedule_time`` + will be reset to the time that ``RunTask`` was called plus the retry + delay specified in the queue's ``RetryConfig``. + + ``RunTask`` returns ``NOT_FOUND`` when it is called on a task that has + already succeeded or permanently failed. + + Example: + >>> from google.cloud import tasks_v2 + >>> + >>> client = tasks_v2.CloudTasksClient() + >>> + >>> name = client.task_path('[PROJECT]', '[LOCATION]', '[QUEUE]', '[TASK]') + >>> + >>> response = client.run_task(name) + + Args: + name (str): Required. + + The task name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + response_view (~google.cloud.tasks_v2.types.View): The response\_view specifies which subset of the ``Task`` will be + returned. + + By default response\_view is ``BASIC``; not all information is retrieved + by default because some data, such as payloads, might be desirable to + return only when needed because of its large size or because of the + sensitivity of data that it contains. + + Authorization for ``FULL`` requires ``cloudtasks.tasks.fullView`` + `Google IAM `___ permission on the + ``Task`` resource. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will not + be retried. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.cloud.tasks_v2.types.Task` instance. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "run_task" not in self._inner_api_calls: + self._inner_api_calls[ + "run_task" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.run_task, + default_retry=self._method_configs["RunTask"].retry, + default_timeout=self._method_configs["RunTask"].timeout, + client_info=self._client_info, + ) + + request = cloudtasks_pb2.RunTaskRequest(name=name, response_view=response_view) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("name", name)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + return self._inner_api_calls["run_task"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) diff --git a/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py b/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py new file mode 100644 index 0000000000000..5c059c9429b0a --- /dev/null +++ b/tasks/google/cloud/tasks_v2/gapic/cloud_tasks_client_config.py @@ -0,0 +1,103 @@ +config = { + "interfaces": { + "google.cloud.tasks.v2.CloudTasks": { + "retry_codes": { + "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], + "non_idempotent": [], + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000, + } + }, + "methods": { + "ListQueues": { + "timeout_millis": 15000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "GetQueue": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "CreateQueue": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "UpdateQueue": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "DeleteQueue": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "PurgeQueue": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "PauseQueue": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "ResumeQueue": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "GetIamPolicy": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "SetIamPolicy": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "TestIamPermissions": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "ListTasks": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "GetTask": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "CreateTask": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + "DeleteTask": { + "timeout_millis": 10000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + }, + "RunTask": { + "timeout_millis": 10000, + "retry_codes_name": "non_idempotent", + "retry_params_name": "default", + }, + }, + } + } +} diff --git a/tasks/google/cloud/tasks_v2/gapic/enums.py b/tasks/google/cloud/tasks_v2/gapic/enums.py new file mode 100644 index 0000000000000..071d4f86f0de0 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/gapic/enums.py @@ -0,0 +1,112 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Wrappers for protocol buffer enum types.""" + +import enum + + +class HttpMethod(enum.IntEnum): + """ + The HTTP method used to deliver the task. + + Attributes: + HTTP_METHOD_UNSPECIFIED (int): HTTP method unspecified + POST (int): HTTP POST + GET (int): HTTP GET + HEAD (int): HTTP HEAD + PUT (int): HTTP PUT + DELETE (int): HTTP DELETE + PATCH (int): HTTP PATCH + OPTIONS (int): HTTP OPTIONS + """ + + HTTP_METHOD_UNSPECIFIED = 0 + POST = 1 + GET = 2 + HEAD = 3 + PUT = 4 + DELETE = 5 + PATCH = 6 + OPTIONS = 7 + + +class Queue(object): + class State(enum.IntEnum): + """ + State of the queue. + + Attributes: + STATE_UNSPECIFIED (int): Unspecified state. + RUNNING (int): The queue is running. Tasks can be dispatched. + + If the queue was created using Cloud Tasks and the queue has had no + activity (method calls or task dispatches) for 30 days, the queue may + take a few minutes to re-activate. Some method calls may return + ``NOT_FOUND`` and tasks may not be dispatched for a few minutes until + the queue has been re-activated. + PAUSED (int): Tasks are paused by the user. If the queue is paused then Cloud + Tasks will stop delivering tasks from it, but more tasks can + still be added to it by the user. + DISABLED (int): The queue is disabled. + + A queue becomes ``DISABLED`` when + `queue.yaml `__ + or + `queue.xml `__ + is uploaded which does not contain the queue. You cannot directly + disable a queue. + + When a queue is disabled, tasks can still be added to a queue but the + tasks are not dispatched. + + To permanently delete this queue and all of its tasks, call + ``DeleteQueue``. + """ + + STATE_UNSPECIFIED = 0 + RUNNING = 1 + PAUSED = 2 + DISABLED = 3 + + +class Task(object): + class View(enum.IntEnum): + """ + The view specifies a subset of ``Task`` data. + + When a task is returned in a response, not all information is retrieved + by default because some data, such as payloads, might be desirable to + return only when needed because of its large size or because of the + sensitivity of data that it contains. + + Attributes: + VIEW_UNSPECIFIED (int): Unspecified. Defaults to BASIC. + BASIC (int): The basic view omits fields which can be large or can contain sensitive + data. + + This view does not include the ``body in AppEngineHttpRequest``. Bodies + are desirable to return only when needed, because they can be large and + because of the sensitivity of the data that you choose to store in it. + FULL (int): All information is returned. + + Authorization for ``FULL`` requires ``cloudtasks.tasks.fullView`` + `Google IAM `__ permission on the + ``Queue`` resource. + """ + + VIEW_UNSPECIFIED = 0 + BASIC = 1 + FULL = 2 diff --git a/tasks/google/cloud/tasks_v2/gapic/transports/__init__.py b/tasks/google/cloud/tasks_v2/gapic/transports/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tasks/google/cloud/tasks_v2/gapic/transports/cloud_tasks_grpc_transport.py b/tasks/google/cloud/tasks_v2/gapic/transports/cloud_tasks_grpc_transport.py new file mode 100644 index 0000000000000..ed0641c4638a0 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/gapic/transports/cloud_tasks_grpc_transport.py @@ -0,0 +1,414 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import google.api_core.grpc_helpers + +from google.cloud.tasks_v2.proto import cloudtasks_pb2_grpc + + +class CloudTasksGrpcTransport(object): + """gRPC transport class providing stubs for + google.cloud.tasks.v2 CloudTasks API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + def __init__( + self, channel=None, credentials=None, address="cloudtasks.googleapis.com:443" + ): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + "The `channel` and `credentials` arguments are mutually " "exclusive." + ) + + # Create the channel. + if channel is None: + channel = self.create_channel(address=address, credentials=credentials) + + self._channel = channel + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = {"cloud_tasks_stub": cloudtasks_pb2_grpc.CloudTasksStub(channel)} + + @classmethod + def create_channel(cls, address="cloudtasks.googleapis.com:443", credentials=None): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return google.api_core.grpc_helpers.create_channel( + address, credentials=credentials, scopes=cls._OAUTH_SCOPES + ) + + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + + @property + def list_queues(self): + """Return the gRPC stub for :meth:`CloudTasksClient.list_queues`. + + Lists queues. + + Queues are returned in lexicographical order. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].ListQueues + + @property + def get_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.get_queue`. + + Gets a queue. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].GetQueue + + @property + def create_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.create_queue`. + + Creates a queue. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless + of whether it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].CreateQueue + + @property + def update_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.update_queue`. + + Updates a queue. + + This method creates the queue if it does not exist and updates the queue + if it does exist. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless + of whether it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].UpdateQueue + + @property + def delete_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.delete_queue`. + + Deletes a queue. + + This command will delete the queue even if it has tasks in it. + + Note: If you delete a queue, a queue with the same name can't be created + for 7 days. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine ``queue.yaml`` or ``queue.xml`` file to manage your + queues. Read `Overview of Queue Management and + queue.yaml `__ before + using this method. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].DeleteQueue + + @property + def purge_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.purge_queue`. + + Purges a queue by deleting all of its tasks. + + All tasks created before this method is called are permanently deleted. + + Purge operations can take up to one minute to take effect. Tasks + might be dispatched before the purge takes effect. A purge is irreversible. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].PurgeQueue + + @property + def pause_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.pause_queue`. + + Pauses the queue. + + If a queue is paused then the system will stop dispatching tasks until + the queue is resumed via ``ResumeQueue``. Tasks can still be added when + the queue is paused. A queue is paused if its ``state`` is ``PAUSED``. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].PauseQueue + + @property + def resume_queue(self): + """Return the gRPC stub for :meth:`CloudTasksClient.resume_queue`. + + Resume a queue. + + This method resumes a queue after it has been ``PAUSED`` or + ``DISABLED``. The state of a queue is stored in the queue's ``state``; + after calling this method it will be set to ``RUNNING``. + + WARNING: Resuming many high-QPS queues at the same time can lead to + target overloading. If you are resuming high-QPS queues, follow the + 500/50/5 pattern described in `Managing Cloud Tasks Scaling + Risks `__. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].ResumeQueue + + @property + def get_iam_policy(self): + """Return the gRPC stub for :meth:`CloudTasksClient.get_iam_policy`. + + Gets the access control policy for a ``Queue``. Returns an empty policy + if the resource exists and does not have a policy set. + + Authorization requires the following `Google + IAM `__ permission on the specified + resource parent: + + - ``cloudtasks.queues.getIamPolicy`` + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].GetIamPolicy + + @property + def set_iam_policy(self): + """Return the gRPC stub for :meth:`CloudTasksClient.set_iam_policy`. + + Sets the access control policy for a ``Queue``. Replaces any existing + policy. + + Note: The Cloud Console does not check queue-level IAM permissions yet. + Project-level permissions are required to use the Cloud Console. + + Authorization requires the following `Google + IAM `__ permission on the specified + resource parent: + + - ``cloudtasks.queues.setIamPolicy`` + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].SetIamPolicy + + @property + def test_iam_permissions(self): + """Return the gRPC stub for :meth:`CloudTasksClient.test_iam_permissions`. + + Returns permissions that a caller has on a ``Queue``. If the resource + does not exist, this will return an empty set of permissions, not a + ``NOT_FOUND`` error. + + Note: This operation is designed to be used for building + permission-aware UIs and command-line tools, not for authorization + checking. This operation may "fail open" without warning. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].TestIamPermissions + + @property + def list_tasks(self): + """Return the gRPC stub for :meth:`CloudTasksClient.list_tasks`. + + Lists the tasks in a queue. + + By default, only the ``BASIC`` view is retrieved due to performance + considerations; ``response_view`` controls the subset of information + which is returned. + + The tasks may be returned in any order. The ordering may change at any + time. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].ListTasks + + @property + def get_task(self): + """Return the gRPC stub for :meth:`CloudTasksClient.get_task`. + + Gets a task. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].GetTask + + @property + def create_task(self): + """Return the gRPC stub for :meth:`CloudTasksClient.create_task`. + + Creates a task and adds it to a queue. + + Tasks cannot be updated after creation; there is no UpdateTask command. + + - For ``App Engine queues``, the maximum task size is 100KB. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].CreateTask + + @property + def delete_task(self): + """Return the gRPC stub for :meth:`CloudTasksClient.delete_task`. + + Deletes a task. + + A task can be deleted if it is scheduled or dispatched. A task + cannot be deleted if it has executed successfully or permanently + failed. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].DeleteTask + + @property + def run_task(self): + """Return the gRPC stub for :meth:`CloudTasksClient.run_task`. + + Forces a task to run now. + + When this method is called, Cloud Tasks will dispatch the task, even if + the task is already running, the queue has reached its ``RateLimits`` or + is ``PAUSED``. + + This command is meant to be used for manual debugging. For example, + ``RunTask`` can be used to retry a failed task after a fix has been made + or to manually force a task to be dispatched now. + + The dispatched task is returned. That is, the task that is returned + contains the ``status`` after the task is dispatched but before the task + is received by its target. + + If Cloud Tasks receives a successful response from the task's target, + then the task will be deleted; otherwise the task's ``schedule_time`` + will be reset to the time that ``RunTask`` was called plus the retry + delay specified in the queue's ``RetryConfig``. + + ``RunTask`` returns ``NOT_FOUND`` when it is called on a task that has + already succeeded or permanently failed. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["cloud_tasks_stub"].RunTask diff --git a/tasks/google/cloud/tasks_v2/proto/__init__.py b/tasks/google/cloud/tasks_v2/proto/__init__.py new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/tasks/google/cloud/tasks_v2/proto/cloudtasks.proto b/tasks/google/cloud/tasks_v2/proto/cloudtasks.proto new file mode 100644 index 0000000000000..dfad1f91e0480 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/cloudtasks.proto @@ -0,0 +1,601 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.tasks.v2; + +import "google/api/annotations.proto"; +import "google/api/resource.proto"; +import "google/protobuf/empty.proto"; +import "google/protobuf/field_mask.proto"; +import "google/cloud/tasks/v2/task.proto"; +import "google/cloud/tasks/v2/queue.proto"; +import "google/iam/v1/iam_policy.proto"; +import "google/iam/v1/policy.proto"; +import "google/rpc/code.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks"; +option java_multiple_files = true; +option java_outer_classname = "CloudTasksProto"; +option java_package = "com.google.cloud.tasks.v2"; +option objc_class_prefix = "TASKS"; + + +// Cloud Tasks allows developers to manage the execution of background +// work in their applications. +service CloudTasks { + // Lists queues. + // + // Queues are returned in lexicographical order. + rpc ListQueues(ListQueuesRequest) returns (ListQueuesResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*}/queues" + }; + } + + // Gets a queue. + rpc GetQueue(GetQueueRequest) returns (Queue) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/queues/*}" + }; + } + + // Creates a queue. + // + // Queues created with this method allow tasks to live for a maximum of 31 + // days. After a task is 31 days old, the task will be deleted regardless of whether + // it was dispatched or not. + // + // WARNING: Using this method may have unintended side effects if you are + // using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + // Read + // [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + // before using this method. + rpc CreateQueue(CreateQueueRequest) returns (Queue) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*}/queues" + body: "queue" + }; + } + + // Updates a queue. + // + // This method creates the queue if it does not exist and updates + // the queue if it does exist. + // + // Queues created with this method allow tasks to live for a maximum of 31 + // days. After a task is 31 days old, the task will be deleted regardless of whether + // it was dispatched or not. + // + // WARNING: Using this method may have unintended side effects if you are + // using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + // Read + // [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + // before using this method. + rpc UpdateQueue(UpdateQueueRequest) returns (Queue) { + option (google.api.http) = { + patch: "/v2/{queue.name=projects/*/locations/*/queues/*}" + body: "queue" + }; + } + + // Deletes a queue. + // + // This command will delete the queue even if it has tasks in it. + // + // Note: If you delete a queue, a queue with the same name can't be created + // for 7 days. + // + // WARNING: Using this method may have unintended side effects if you are + // using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + // Read + // [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + // before using this method. + rpc DeleteQueue(DeleteQueueRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/queues/*}" + }; + } + + // Purges a queue by deleting all of its tasks. + // + // All tasks created before this method is called are permanently deleted. + // + // Purge operations can take up to one minute to take effect. Tasks + // might be dispatched before the purge takes effect. A purge is irreversible. + rpc PurgeQueue(PurgeQueueRequest) returns (Queue) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/queues/*}:purge" + body: "*" + }; + } + + // Pauses the queue. + // + // If a queue is paused then the system will stop dispatching tasks + // until the queue is resumed via + // [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. Tasks can still be added + // when the queue is paused. A queue is paused if its + // [state][google.cloud.tasks.v2.Queue.state] is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + rpc PauseQueue(PauseQueueRequest) returns (Queue) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/queues/*}:pause" + body: "*" + }; + } + + // Resume a queue. + // + // This method resumes a queue after it has been + // [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED] or + // [DISABLED][google.cloud.tasks.v2.Queue.State.DISABLED]. The state of a queue is stored + // in the queue's [state][google.cloud.tasks.v2.Queue.state]; after calling this method it + // will be set to [RUNNING][google.cloud.tasks.v2.Queue.State.RUNNING]. + // + // WARNING: Resuming many high-QPS queues at the same time can + // lead to target overloading. If you are resuming high-QPS + // queues, follow the 500/50/5 pattern described in + // [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + rpc ResumeQueue(ResumeQueueRequest) returns (Queue) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/queues/*}:resume" + body: "*" + }; + } + + // Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. + // Returns an empty policy if the resource exists and does not have a policy + // set. + // + // Authorization requires the following + // [Google IAM](https://cloud.google.com/iam) permission on the specified + // resource parent: + // + // * `cloudtasks.queues.getIamPolicy` + rpc GetIamPolicy(google.iam.v1.GetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/queues/*}:getIamPolicy" + body: "*" + }; + } + + // Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Replaces any existing + // policy. + // + // Note: The Cloud Console does not check queue-level IAM permissions yet. + // Project-level permissions are required to use the Cloud Console. + // + // Authorization requires the following + // [Google IAM](https://cloud.google.com/iam) permission on the specified + // resource parent: + // + // * `cloudtasks.queues.setIamPolicy` + rpc SetIamPolicy(google.iam.v1.SetIamPolicyRequest) returns (google.iam.v1.Policy) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/queues/*}:setIamPolicy" + body: "*" + }; + } + + // Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2.Queue]. + // If the resource does not exist, this will return an empty set of + // permissions, not a [NOT_FOUND][google.rpc.Code.NOT_FOUND] error. + // + // Note: This operation is designed to be used for building permission-aware + // UIs and command-line tools, not for authorization checking. This operation + // may "fail open" without warning. + rpc TestIamPermissions(google.iam.v1.TestIamPermissionsRequest) returns (google.iam.v1.TestIamPermissionsResponse) { + option (google.api.http) = { + post: "/v2/{resource=projects/*/locations/*/queues/*}:testIamPermissions" + body: "*" + }; + } + + // Lists the tasks in a queue. + // + // By default, only the [BASIC][google.cloud.tasks.v2.Task.View.BASIC] view is retrieved + // due to performance considerations; + // [response_view][google.cloud.tasks.v2.ListTasksRequest.response_view] controls the + // subset of information which is returned. + // + // The tasks may be returned in any order. The ordering may change at any + // time. + rpc ListTasks(ListTasksRequest) returns (ListTasksResponse) { + option (google.api.http) = { + get: "/v2/{parent=projects/*/locations/*/queues/*}/tasks" + }; + } + + // Gets a task. + rpc GetTask(GetTaskRequest) returns (Task) { + option (google.api.http) = { + get: "/v2/{name=projects/*/locations/*/queues/*/tasks/*}" + }; + } + + // Creates a task and adds it to a queue. + // + // Tasks cannot be updated after creation; there is no UpdateTask command. + // + // * For [App Engine queues][google.cloud.tasks.v2.AppEngineHttpQueue], the maximum task size is + // 100KB. + rpc CreateTask(CreateTaskRequest) returns (Task) { + option (google.api.http) = { + post: "/v2/{parent=projects/*/locations/*/queues/*}/tasks" + body: "*" + }; + } + + // Deletes a task. + // + // A task can be deleted if it is scheduled or dispatched. A task + // cannot be deleted if it has executed successfully or permanently + // failed. + rpc DeleteTask(DeleteTaskRequest) returns (google.protobuf.Empty) { + option (google.api.http) = { + delete: "/v2/{name=projects/*/locations/*/queues/*/tasks/*}" + }; + } + + // Forces a task to run now. + // + // When this method is called, Cloud Tasks will dispatch the task, even if + // the task is already running, the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits] or + // is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + // + // This command is meant to be used for manual debugging. For + // example, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] can be used to retry a failed + // task after a fix has been made or to manually force a task to be + // dispatched now. + // + // The dispatched task is returned. That is, the task that is returned + // contains the [status][Task.status] after the task is dispatched but + // before the task is received by its target. + // + // If Cloud Tasks receives a successful response from the task's + // target, then the task will be deleted; otherwise the task's + // [schedule_time][google.cloud.tasks.v2.Task.schedule_time] will be reset to the time that + // [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] was called plus the retry delay specified + // in the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig]. + // + // [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] returns + // [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a + // task that has already succeeded or permanently failed. + rpc RunTask(RunTaskRequest) returns (Task) { + option (google.api.http) = { + post: "/v2/{name=projects/*/locations/*/queues/*/tasks/*}:run" + body: "*" + }; + } +} + +// Request message for [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. +message ListQueuesRequest { + // Required. + // + // The location name. + // For example: `projects/PROJECT_ID/locations/LOCATION_ID` + string parent = 1; + + // `filter` can be used to specify a subset of queues. Any [Queue][google.cloud.tasks.v2.Queue] + // field can be used as a filter and several operators as supported. + // For example: `<=, <, >=, >, !=, =, :`. The filter syntax is the same as + // described in + // [Stackdriver's Advanced Logs Filters](https://cloud.google.com/logging/docs/view/advanced_filters). + // + // Sample filter "state: PAUSED". + // + // Note that using filters might cause fewer queues than the + // requested page_size to be returned. + string filter = 2; + + // Requested page size. + // + // The maximum page size is 9800. If unspecified, the page size will + // be the maximum. Fewer queues than requested might be returned, + // even if more queues exist; use the + // [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token] in the + // response to determine if more queues exist. + int32 page_size = 3; + + // A token identifying the page of results to return. + // + // To request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.tasks.v2.ListQueuesResponse.next_page_token] returned + // from the previous call to [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] + // method. It is an error to switch the value of the + // [filter][google.cloud.tasks.v2.ListQueuesRequest.filter] while iterating through pages. + string page_token = 4; +} + +// Response message for [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. +message ListQueuesResponse { + // The list of queues. + repeated Queue queues = 1; + + // A token to retrieve next page of results. + // + // To return the next page of results, call + // [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] with this value as the + // [page_token][google.cloud.tasks.v2.ListQueuesRequest.page_token]. + // + // If the next_page_token is empty, there are no more results. + // + // The page token is valid for only 2 hours. + string next_page_token = 2; +} + +// Request message for [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue]. +message GetQueueRequest { + // Required. + // + // The resource name of the queue. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + string name = 1; +} + +// Request message for [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue]. +message CreateQueueRequest { + // Required. + // + // The location name in which the queue will be created. + // For example: `projects/PROJECT_ID/locations/LOCATION_ID` + // + // The list of allowed locations can be obtained by calling Cloud + // Tasks' implementation of + // [ListLocations][google.cloud.location.Locations.ListLocations]. + string parent = 1; + + // Required. + // + // The queue to create. + // + // [Queue's name][google.cloud.tasks.v2.Queue.name] cannot be the same as an existing queue. + Queue queue = 2; +} + +// Request message for [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue]. +message UpdateQueueRequest { + // Required. + // + // The queue to create or update. + // + // The queue's [name][google.cloud.tasks.v2.Queue.name] must be specified. + // + // Output only fields cannot be modified using UpdateQueue. + // Any value specified for an output only field will be ignored. + // The queue's [name][google.cloud.tasks.v2.Queue.name] cannot be changed. + Queue queue = 1; + + // A mask used to specify which fields of the queue are being updated. + // + // If empty, then all fields will be updated. + google.protobuf.FieldMask update_mask = 2; +} + +// Request message for [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue]. +message DeleteQueueRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + string name = 1; +} + +// Request message for [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue]. +message PurgeQueueRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` + string name = 1; +} + +// Request message for [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue]. +message PauseQueueRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` + string name = 1; +} + +// Request message for [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. +message ResumeQueueRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID` + string name = 1; +} + +// Request message for listing tasks using [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. +message ListTasksRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + string parent = 1; + + // The response_view specifies which subset of the [Task][google.cloud.tasks.v2.Task] will be + // returned. + // + // By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + // information is retrieved by default because some data, such as + // payloads, might be desirable to return only when needed because + // of its large size or because of the sensitivity of data that it + // contains. + // + // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + // permission on the [Task][google.cloud.tasks.v2.Task] resource. + Task.View response_view = 2; + + // Requested page size. Fewer tasks than requested might be returned. + // + // The maximum page size is 1000. If unspecified, the page size will + // be the maximum. Fewer tasks than requested might be returned, + // even if more tasks exist; use + // [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token] in the + // response to determine if more tasks exist. + int32 page_size = 3; + + // A token identifying the page of results to return. + // + // To request the first page results, page_token must be empty. To + // request the next page of results, page_token must be the value of + // [next_page_token][google.cloud.tasks.v2.ListTasksResponse.next_page_token] returned + // from the previous call to [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] + // method. + // + // The page token is valid for only 2 hours. + string page_token = 4; +} + +// Response message for listing tasks using [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. +message ListTasksResponse { + // The list of tasks. + repeated Task tasks = 1; + + // A token to retrieve next page of results. + // + // To return the next page of results, call + // [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] with this value as the + // [page_token][google.cloud.tasks.v2.ListTasksRequest.page_token]. + // + // If the next_page_token is empty, there are no more results. + string next_page_token = 2; +} + +// Request message for getting a task using [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask]. +message GetTaskRequest { + // Required. + // + // The task name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + string name = 1; + + // The response_view specifies which subset of the [Task][google.cloud.tasks.v2.Task] will be + // returned. + // + // By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + // information is retrieved by default because some data, such as + // payloads, might be desirable to return only when needed because + // of its large size or because of the sensitivity of data that it + // contains. + // + // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + // permission on the [Task][google.cloud.tasks.v2.Task] resource. + Task.View response_view = 2; +} + +// Request message for [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. +message CreateTaskRequest { + // Required. + // + // The queue name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + // + // The queue must already exist. + string parent = 1; + + // Required. + // + // The task to add. + // + // Task names have the following format: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`. + // The user can optionally specify a task [name][google.cloud.tasks.v2.Task.name]. If a + // name is not specified then the system will generate a random + // unique task id, which will be set in the task returned in the + // [response][google.cloud.tasks.v2.Task.name]. + // + // If [schedule_time][google.cloud.tasks.v2.Task.schedule_time] is not set or is in the + // past then Cloud Tasks will set it to the current time. + // + // Task De-duplication: + // + // Explicitly specifying a task ID enables task de-duplication. If + // a task's ID is identical to that of an existing task or a task + // that was deleted or executed recently then the call will fail + // with [ALREADY_EXISTS][google.rpc.Code.ALREADY_EXISTS]. + // If the task's queue was created using Cloud Tasks, then another task with + // the same name can't be created for ~1hour after the original task was + // deleted or executed. If the task's queue was created using queue.yaml or + // queue.xml, then another task with the same name can't be created + // for ~9days after the original task was deleted or executed. + // + // Because there is an extra lookup cost to identify duplicate task + // names, these [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] calls have significantly + // increased latency. Using hashed strings for the task id or for + // the prefix of the task id is recommended. Choosing task ids that + // are sequential or have sequential prefixes, for example using a + // timestamp, causes an increase in latency and error rates in all + // task commands. The infrastructure relies on an approximately + // uniform distribution of task ids to store and serve tasks + // efficiently. + Task task = 2; + + // The response_view specifies which subset of the [Task][google.cloud.tasks.v2.Task] will be + // returned. + // + // By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + // information is retrieved by default because some data, such as + // payloads, might be desirable to return only when needed because + // of its large size or because of the sensitivity of data that it + // contains. + // + // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + // permission on the [Task][google.cloud.tasks.v2.Task] resource. + Task.View response_view = 3; +} + +// Request message for deleting a task using +// [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask]. +message DeleteTaskRequest { + // Required. + // + // The task name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + string name = 1; +} + +// Request message for forcing a task to run now using +// [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask]. +message RunTaskRequest { + // Required. + // + // The task name. For example: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + string name = 1; + + // The response_view specifies which subset of the [Task][google.cloud.tasks.v2.Task] will be + // returned. + // + // By default response_view is [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + // information is retrieved by default because some data, such as + // payloads, might be desirable to return only when needed because + // of its large size or because of the sensitivity of data that it + // contains. + // + // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + // permission on the [Task][google.cloud.tasks.v2.Task] resource. + Task.View response_view = 2; +} diff --git a/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2.py b/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2.py new file mode 100644 index 0000000000000..f5c93d27bc46a --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2.py @@ -0,0 +1,1585 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/tasks_v2/proto/cloudtasks.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 +from google.protobuf import field_mask_pb2 as google_dot_protobuf_dot_field__mask__pb2 +from google.cloud.tasks_v2.proto import ( + task_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2, +) +from google.cloud.tasks_v2.proto import ( + queue_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2, +) +from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 +from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 +from google.rpc import code_pb2 as google_dot_rpc_dot_code__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/tasks_v2/proto/cloudtasks.proto", + package="google.cloud.tasks.v2", + syntax="proto3", + serialized_options=_b( + "\n\031com.google.cloud.tasks.v2B\017CloudTasksProtoP\001Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks\242\002\005TASKS" + ), + serialized_pb=_b( + '\n,google/cloud/tasks_v2/proto/cloudtasks.proto\x12\x15google.cloud.tasks.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/api/resource.proto\x1a\x1bgoogle/protobuf/empty.proto\x1a google/protobuf/field_mask.proto\x1a&google/cloud/tasks_v2/proto/task.proto\x1a\'google/cloud/tasks_v2/proto/queue.proto\x1a\x1egoogle/iam/v1/iam_policy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a\x15google/rpc/code.proto"Z\n\x11ListQueuesRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x0e\n\x06\x66ilter\x18\x02 \x01(\t\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"[\n\x12ListQueuesResponse\x12,\n\x06queues\x18\x01 \x03(\x0b\x32\x1c.google.cloud.tasks.v2.Queue\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"\x1f\n\x0fGetQueueRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"Q\n\x12\x43reateQueueRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12+\n\x05queue\x18\x02 \x01(\x0b\x32\x1c.google.cloud.tasks.v2.Queue"r\n\x12UpdateQueueRequest\x12+\n\x05queue\x18\x01 \x01(\x0b\x32\x1c.google.cloud.tasks.v2.Queue\x12/\n\x0bupdate_mask\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.FieldMask""\n\x12\x44\x65leteQueueRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"!\n\x11PurgeQueueRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"!\n\x11PauseQueueRequest\x12\x0c\n\x04name\x18\x01 \x01(\t""\n\x12ResumeQueueRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"\x82\x01\n\x10ListTasksRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12\x37\n\rresponse_view\x18\x02 \x01(\x0e\x32 .google.cloud.tasks.v2.Task.View\x12\x11\n\tpage_size\x18\x03 \x01(\x05\x12\x12\n\npage_token\x18\x04 \x01(\t"X\n\x11ListTasksResponse\x12*\n\x05tasks\x18\x01 \x03(\x0b\x32\x1b.google.cloud.tasks.v2.Task\x12\x17\n\x0fnext_page_token\x18\x02 \x01(\t"W\n\x0eGetTaskRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\rresponse_view\x18\x02 \x01(\x0e\x32 .google.cloud.tasks.v2.Task.View"\x87\x01\n\x11\x43reateTaskRequest\x12\x0e\n\x06parent\x18\x01 \x01(\t\x12)\n\x04task\x18\x02 \x01(\x0b\x32\x1b.google.cloud.tasks.v2.Task\x12\x37\n\rresponse_view\x18\x03 \x01(\x0e\x32 .google.cloud.tasks.v2.Task.View"!\n\x11\x44\x65leteTaskRequest\x12\x0c\n\x04name\x18\x01 \x01(\t"W\n\x0eRunTaskRequest\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x37\n\rresponse_view\x18\x02 \x01(\x0e\x32 .google.cloud.tasks.v2.Task.View2\xdf\x12\n\nCloudTasks\x12\x95\x01\n\nListQueues\x12(.google.cloud.tasks.v2.ListQueuesRequest\x1a).google.cloud.tasks.v2.ListQueuesResponse"2\x82\xd3\xe4\x93\x02,\x12*/v2/{parent=projects/*/locations/*}/queues\x12\x84\x01\n\x08GetQueue\x12&.google.cloud.tasks.v2.GetQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue"2\x82\xd3\xe4\x93\x02,\x12*/v2/{name=projects/*/locations/*/queues/*}\x12\x91\x01\n\x0b\x43reateQueue\x12).google.cloud.tasks.v2.CreateQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue"9\x82\xd3\xe4\x93\x02\x33"*/v2/{parent=projects/*/locations/*}/queues:\x05queue\x12\x97\x01\n\x0bUpdateQueue\x12).google.cloud.tasks.v2.UpdateQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue"?\x82\xd3\xe4\x93\x02\x39\x32\x30/v2/{queue.name=projects/*/locations/*/queues/*}:\x05queue\x12\x84\x01\n\x0b\x44\x65leteQueue\x12).google.cloud.tasks.v2.DeleteQueueRequest\x1a\x16.google.protobuf.Empty"2\x82\xd3\xe4\x93\x02,**/v2/{name=projects/*/locations/*/queues/*}\x12\x91\x01\n\nPurgeQueue\x12(.google.cloud.tasks.v2.PurgeQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue";\x82\xd3\xe4\x93\x02\x35"0/v2/{name=projects/*/locations/*/queues/*}:purge:\x01*\x12\x91\x01\n\nPauseQueue\x12(.google.cloud.tasks.v2.PauseQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue";\x82\xd3\xe4\x93\x02\x35"0/v2/{name=projects/*/locations/*/queues/*}:pause:\x01*\x12\x94\x01\n\x0bResumeQueue\x12).google.cloud.tasks.v2.ResumeQueueRequest\x1a\x1c.google.cloud.tasks.v2.Queue"<\x82\xd3\xe4\x93\x02\x36"1/v2/{name=projects/*/locations/*/queues/*}:resume:\x01*\x12\x91\x01\n\x0cGetIamPolicy\x12".google.iam.v1.GetIamPolicyRequest\x1a\x15.google.iam.v1.Policy"F\x82\xd3\xe4\x93\x02@";/v2/{resource=projects/*/locations/*/queues/*}:getIamPolicy:\x01*\x12\x91\x01\n\x0cSetIamPolicy\x12".google.iam.v1.SetIamPolicyRequest\x1a\x15.google.iam.v1.Policy"F\x82\xd3\xe4\x93\x02@";/v2/{resource=projects/*/locations/*/queues/*}:setIamPolicy:\x01*\x12\xb7\x01\n\x12TestIamPermissions\x12(.google.iam.v1.TestIamPermissionsRequest\x1a).google.iam.v1.TestIamPermissionsResponse"L\x82\xd3\xe4\x93\x02\x46"A/v2/{resource=projects/*/locations/*/queues/*}:testIamPermissions:\x01*\x12\x9a\x01\n\tListTasks\x12\'.google.cloud.tasks.v2.ListTasksRequest\x1a(.google.cloud.tasks.v2.ListTasksResponse":\x82\xd3\xe4\x93\x02\x34\x12\x32/v2/{parent=projects/*/locations/*/queues/*}/tasks\x12\x89\x01\n\x07GetTask\x12%.google.cloud.tasks.v2.GetTaskRequest\x1a\x1b.google.cloud.tasks.v2.Task":\x82\xd3\xe4\x93\x02\x34\x12\x32/v2/{name=projects/*/locations/*/queues/*/tasks/*}\x12\x92\x01\n\nCreateTask\x12(.google.cloud.tasks.v2.CreateTaskRequest\x1a\x1b.google.cloud.tasks.v2.Task"=\x82\xd3\xe4\x93\x02\x37"2/v2/{parent=projects/*/locations/*/queues/*}/tasks:\x01*\x12\x8a\x01\n\nDeleteTask\x12(.google.cloud.tasks.v2.DeleteTaskRequest\x1a\x16.google.protobuf.Empty":\x82\xd3\xe4\x93\x02\x34*2/v2/{name=projects/*/locations/*/queues/*/tasks/*}\x12\x90\x01\n\x07RunTask\x12%.google.cloud.tasks.v2.RunTaskRequest\x1a\x1b.google.cloud.tasks.v2.Task"A\x82\xd3\xe4\x93\x02;"6/v2/{name=projects/*/locations/*/queues/*/tasks/*}:run:\x01*Br\n\x19\x63om.google.cloud.tasks.v2B\x0f\x43loudTasksProtoP\x01Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks\xa2\x02\x05TASKSb\x06proto3' + ), + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_protobuf_dot_empty__pb2.DESCRIPTOR, + google_dot_protobuf_dot_field__mask__pb2.DESCRIPTOR, + google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.DESCRIPTOR, + google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.DESCRIPTOR, + google_dot_iam_dot_v1_dot_iam__policy__pb2.DESCRIPTOR, + google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR, + google_dot_rpc_dot_code__pb2.DESCRIPTOR, + ], +) + + +_LISTQUEUESREQUEST = _descriptor.Descriptor( + name="ListQueuesRequest", + full_name="google.cloud.tasks.v2.ListQueuesRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.tasks.v2.ListQueuesRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="filter", + full_name="google.cloud.tasks.v2.ListQueuesRequest.filter", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.cloud.tasks.v2.ListQueuesRequest.page_size", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.cloud.tasks.v2.ListQueuesRequest.page_token", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=355, + serialized_end=445, +) + + +_LISTQUEUESRESPONSE = _descriptor.Descriptor( + name="ListQueuesResponse", + full_name="google.cloud.tasks.v2.ListQueuesResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="queues", + full_name="google.cloud.tasks.v2.ListQueuesResponse.queues", + index=0, + number=1, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.cloud.tasks.v2.ListQueuesResponse.next_page_token", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=447, + serialized_end=538, +) + + +_GETQUEUEREQUEST = _descriptor.Descriptor( + name="GetQueueRequest", + full_name="google.cloud.tasks.v2.GetQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.GetQueueRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=540, + serialized_end=571, +) + + +_CREATEQUEUEREQUEST = _descriptor.Descriptor( + name="CreateQueueRequest", + full_name="google.cloud.tasks.v2.CreateQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.tasks.v2.CreateQueueRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="queue", + full_name="google.cloud.tasks.v2.CreateQueueRequest.queue", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=573, + serialized_end=654, +) + + +_UPDATEQUEUEREQUEST = _descriptor.Descriptor( + name="UpdateQueueRequest", + full_name="google.cloud.tasks.v2.UpdateQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="queue", + full_name="google.cloud.tasks.v2.UpdateQueueRequest.queue", + index=0, + number=1, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="update_mask", + full_name="google.cloud.tasks.v2.UpdateQueueRequest.update_mask", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=656, + serialized_end=770, +) + + +_DELETEQUEUEREQUEST = _descriptor.Descriptor( + name="DeleteQueueRequest", + full_name="google.cloud.tasks.v2.DeleteQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.DeleteQueueRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=772, + serialized_end=806, +) + + +_PURGEQUEUEREQUEST = _descriptor.Descriptor( + name="PurgeQueueRequest", + full_name="google.cloud.tasks.v2.PurgeQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.PurgeQueueRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=808, + serialized_end=841, +) + + +_PAUSEQUEUEREQUEST = _descriptor.Descriptor( + name="PauseQueueRequest", + full_name="google.cloud.tasks.v2.PauseQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.PauseQueueRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=843, + serialized_end=876, +) + + +_RESUMEQUEUEREQUEST = _descriptor.Descriptor( + name="ResumeQueueRequest", + full_name="google.cloud.tasks.v2.ResumeQueueRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.ResumeQueueRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=878, + serialized_end=912, +) + + +_LISTTASKSREQUEST = _descriptor.Descriptor( + name="ListTasksRequest", + full_name="google.cloud.tasks.v2.ListTasksRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.tasks.v2.ListTasksRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_view", + full_name="google.cloud.tasks.v2.ListTasksRequest.response_view", + index=1, + number=2, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.cloud.tasks.v2.ListTasksRequest.page_size", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.cloud.tasks.v2.ListTasksRequest.page_token", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=915, + serialized_end=1045, +) + + +_LISTTASKSRESPONSE = _descriptor.Descriptor( + name="ListTasksResponse", + full_name="google.cloud.tasks.v2.ListTasksResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="tasks", + full_name="google.cloud.tasks.v2.ListTasksResponse.tasks", + index=0, + number=1, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.cloud.tasks.v2.ListTasksResponse.next_page_token", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1047, + serialized_end=1135, +) + + +_GETTASKREQUEST = _descriptor.Descriptor( + name="GetTaskRequest", + full_name="google.cloud.tasks.v2.GetTaskRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.GetTaskRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_view", + full_name="google.cloud.tasks.v2.GetTaskRequest.response_view", + index=1, + number=2, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1137, + serialized_end=1224, +) + + +_CREATETASKREQUEST = _descriptor.Descriptor( + name="CreateTaskRequest", + full_name="google.cloud.tasks.v2.CreateTaskRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.tasks.v2.CreateTaskRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="task", + full_name="google.cloud.tasks.v2.CreateTaskRequest.task", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_view", + full_name="google.cloud.tasks.v2.CreateTaskRequest.response_view", + index=2, + number=3, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1227, + serialized_end=1362, +) + + +_DELETETASKREQUEST = _descriptor.Descriptor( + name="DeleteTaskRequest", + full_name="google.cloud.tasks.v2.DeleteTaskRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.DeleteTaskRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ) + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1364, + serialized_end=1397, +) + + +_RUNTASKREQUEST = _descriptor.Descriptor( + name="RunTaskRequest", + full_name="google.cloud.tasks.v2.RunTaskRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.RunTaskRequest.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_view", + full_name="google.cloud.tasks.v2.RunTaskRequest.response_view", + index=1, + number=2, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1399, + serialized_end=1486, +) + +_LISTQUEUESRESPONSE.fields_by_name[ + "queues" +].message_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE +_CREATEQUEUEREQUEST.fields_by_name[ + "queue" +].message_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE +_UPDATEQUEUEREQUEST.fields_by_name[ + "queue" +].message_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE +_UPDATEQUEUEREQUEST.fields_by_name[ + "update_mask" +].message_type = google_dot_protobuf_dot_field__mask__pb2._FIELDMASK +_LISTTASKSREQUEST.fields_by_name[ + "response_view" +].enum_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK_VIEW +_LISTTASKSRESPONSE.fields_by_name[ + "tasks" +].message_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK +_GETTASKREQUEST.fields_by_name[ + "response_view" +].enum_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK_VIEW +_CREATETASKREQUEST.fields_by_name[ + "task" +].message_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK +_CREATETASKREQUEST.fields_by_name[ + "response_view" +].enum_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK_VIEW +_RUNTASKREQUEST.fields_by_name[ + "response_view" +].enum_type = google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK_VIEW +DESCRIPTOR.message_types_by_name["ListQueuesRequest"] = _LISTQUEUESREQUEST +DESCRIPTOR.message_types_by_name["ListQueuesResponse"] = _LISTQUEUESRESPONSE +DESCRIPTOR.message_types_by_name["GetQueueRequest"] = _GETQUEUEREQUEST +DESCRIPTOR.message_types_by_name["CreateQueueRequest"] = _CREATEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["UpdateQueueRequest"] = _UPDATEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["DeleteQueueRequest"] = _DELETEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["PurgeQueueRequest"] = _PURGEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["PauseQueueRequest"] = _PAUSEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["ResumeQueueRequest"] = _RESUMEQUEUEREQUEST +DESCRIPTOR.message_types_by_name["ListTasksRequest"] = _LISTTASKSREQUEST +DESCRIPTOR.message_types_by_name["ListTasksResponse"] = _LISTTASKSRESPONSE +DESCRIPTOR.message_types_by_name["GetTaskRequest"] = _GETTASKREQUEST +DESCRIPTOR.message_types_by_name["CreateTaskRequest"] = _CREATETASKREQUEST +DESCRIPTOR.message_types_by_name["DeleteTaskRequest"] = _DELETETASKREQUEST +DESCRIPTOR.message_types_by_name["RunTaskRequest"] = _RUNTASKREQUEST +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListQueuesRequest = _reflection.GeneratedProtocolMessageType( + "ListQueuesRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTQUEUESREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. + + + Attributes: + parent: + Required. The location name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID`` + filter: + ``filter`` can be used to specify a subset of queues. Any + [Queue][google.cloud.tasks.v2.Queue] field can be used as a + filter and several operators as supported. For example: ``<=, + <, >=, >, !=, =, :``. The filter syntax is the same as + described in `Stackdriver's Advanced Logs Filters `_. Sample + filter "state: PAUSED". Note that using filters might cause + fewer queues than the requested page\_size to be returned. + page_size: + Requested page size. The maximum page size is 9800. If + unspecified, the page size will be the maximum. Fewer queues + than requested might be returned, even if more queues exist; + use the [next\_page\_token][google.cloud.tasks.v2.ListQueuesRe + sponse.next\_page\_token] in the response to determine if more + queues exist. + page_token: + A token identifying the page of results to return. To request + the first page results, page\_token must be empty. To request + the next page of results, page\_token must be the value of [ne + xt\_page\_token][google.cloud.tasks.v2.ListQueuesResponse.next + \_page\_token] returned from the previous call to + [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] + method. It is an error to switch the value of the + [filter][google.cloud.tasks.v2.ListQueuesRequest.filter] while + iterating through pages. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.ListQueuesRequest) + ), +) +_sym_db.RegisterMessage(ListQueuesRequest) + +ListQueuesResponse = _reflection.GeneratedProtocolMessageType( + "ListQueuesResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTQUEUESRESPONSE, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Response message for + [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues]. + + + Attributes: + queues: + The list of queues. + next_page_token: + A token to retrieve next page of results. To return the next + page of results, call + [ListQueues][google.cloud.tasks.v2.CloudTasks.ListQueues] with + this value as the [page\_token][google.cloud.tasks.v2.ListQueu + esRequest.page\_token]. If the next\_page\_token is empty, + there are no more results. The page token is valid for only 2 + hours. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.ListQueuesResponse) + ), +) +_sym_db.RegisterMessage(ListQueuesResponse) + +GetQueueRequest = _reflection.GeneratedProtocolMessageType( + "GetQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_GETQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [GetQueue][google.cloud.tasks.v2.CloudTasks.GetQueue]. + + + Attributes: + name: + Required. The resource name of the queue. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.GetQueueRequest) + ), +) +_sym_db.RegisterMessage(GetQueueRequest) + +CreateQueueRequest = _reflection.GeneratedProtocolMessageType( + "CreateQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_CREATEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue]. + + + Attributes: + parent: + Required. The location name in which the queue will be + created. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID`` The list of + allowed locations can be obtained by calling Cloud Tasks' + implementation of [ListLocations][google.cloud.location.Locati + ons.ListLocations]. + queue: + Required. The queue to create. [Queue's + name][google.cloud.tasks.v2.Queue.name] cannot be the same as + an existing queue. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.CreateQueueRequest) + ), +) +_sym_db.RegisterMessage(CreateQueueRequest) + +UpdateQueueRequest = _reflection.GeneratedProtocolMessageType( + "UpdateQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_UPDATEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue]. + + + Attributes: + queue: + Required. The queue to create or update. The queue's + [name][google.cloud.tasks.v2.Queue.name] must be specified. + Output only fields cannot be modified using UpdateQueue. Any + value specified for an output only field will be ignored. The + queue's [name][google.cloud.tasks.v2.Queue.name] cannot be + changed. + update_mask: + A mask used to specify which fields of the queue are being + updated. If empty, then all fields will be updated. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.UpdateQueueRequest) + ), +) +_sym_db.RegisterMessage(UpdateQueueRequest) + +DeleteQueueRequest = _reflection.GeneratedProtocolMessageType( + "DeleteQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_DELETEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue]. + + + Attributes: + name: + Required. The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.DeleteQueueRequest) + ), +) +_sym_db.RegisterMessage(DeleteQueueRequest) + +PurgeQueueRequest = _reflection.GeneratedProtocolMessageType( + "PurgeQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_PURGEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue]. + + + Attributes: + name: + Required. The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.PurgeQueueRequest) + ), +) +_sym_db.RegisterMessage(PurgeQueueRequest) + +PauseQueueRequest = _reflection.GeneratedProtocolMessageType( + "PauseQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_PAUSEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue]. + + + Attributes: + name: + Required. The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.PauseQueueRequest) + ), +) +_sym_db.RegisterMessage(PauseQueueRequest) + +ResumeQueueRequest = _reflection.GeneratedProtocolMessageType( + "ResumeQueueRequest", + (_message.Message,), + dict( + DESCRIPTOR=_RESUMEQUEUEREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. + + + Attributes: + name: + Required. The queue name. For example: + ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.ResumeQueueRequest) + ), +) +_sym_db.RegisterMessage(ResumeQueueRequest) + +ListTasksRequest = _reflection.GeneratedProtocolMessageType( + "ListTasksRequest", + (_message.Message,), + dict( + DESCRIPTOR=_LISTTASKSREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for listing tasks using + [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. + + + Attributes: + parent: + Required. The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + response_view: + The response\_view specifies which subset of the + [Task][google.cloud.tasks.v2.Task] will be returned. By + default response\_view is + [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + information is retrieved by default because some data, such as + payloads, might be desirable to return only when needed + because of its large size or because of the sensitivity of + data that it contains. Authorization for + [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + ``cloudtasks.tasks.fullView`` `Google IAM + `_ permission on the + [Task][google.cloud.tasks.v2.Task] resource. + page_size: + Requested page size. Fewer tasks than requested might be + returned. The maximum page size is 1000. If unspecified, the + page size will be the maximum. Fewer tasks than requested + might be returned, even if more tasks exist; use [next\_page\_ + token][google.cloud.tasks.v2.ListTasksResponse.next\_page\_tok + en] in the response to determine if more tasks exist. + page_token: + A token identifying the page of results to return. To request + the first page results, page\_token must be empty. To request + the next page of results, page\_token must be the value of [ne + xt\_page\_token][google.cloud.tasks.v2.ListTasksResponse.next\ + _page\_token] returned from the previous call to + [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] + method. The page token is valid for only 2 hours. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.ListTasksRequest) + ), +) +_sym_db.RegisterMessage(ListTasksRequest) + +ListTasksResponse = _reflection.GeneratedProtocolMessageType( + "ListTasksResponse", + (_message.Message,), + dict( + DESCRIPTOR=_LISTTASKSRESPONSE, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Response message for listing tasks using + [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks]. + + + Attributes: + tasks: + The list of tasks. + next_page_token: + A token to retrieve next page of results. To return the next + page of results, call + [ListTasks][google.cloud.tasks.v2.CloudTasks.ListTasks] with + this value as the [page\_token][google.cloud.tasks.v2.ListTask + sRequest.page\_token]. If the next\_page\_token is empty, + there are no more results. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.ListTasksResponse) + ), +) +_sym_db.RegisterMessage(ListTasksResponse) + +GetTaskRequest = _reflection.GeneratedProtocolMessageType( + "GetTaskRequest", + (_message.Message,), + dict( + DESCRIPTOR=_GETTASKREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for getting a task using + [GetTask][google.cloud.tasks.v2.CloudTasks.GetTask]. + + + Attributes: + name: + Required. The task name. For example: ``projects/PROJECT_ID/l + ocations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + response_view: + The response\_view specifies which subset of the + [Task][google.cloud.tasks.v2.Task] will be returned. By + default response\_view is + [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + information is retrieved by default because some data, such as + payloads, might be desirable to return only when needed + because of its large size or because of the sensitivity of + data that it contains. Authorization for + [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + ``cloudtasks.tasks.fullView`` `Google IAM + `_ permission on the + [Task][google.cloud.tasks.v2.Task] resource. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.GetTaskRequest) + ), +) +_sym_db.RegisterMessage(GetTaskRequest) + +CreateTaskRequest = _reflection.GeneratedProtocolMessageType( + "CreateTaskRequest", + (_message.Message,), + dict( + DESCRIPTOR=_CREATETASKREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for + [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. + + + Attributes: + parent: + Required. The queue name. For example: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + The queue must already exist. + task: + Required. The task to add. Task names have the following + format: ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUE + UE_ID/tasks/TASK_ID``. The user can optionally specify a task + [name][google.cloud.tasks.v2.Task.name]. If a name is not + specified then the system will generate a random unique task + id, which will be set in the task returned in the + [response][google.cloud.tasks.v2.Task.name]. If + [schedule\_time][google.cloud.tasks.v2.Task.schedule\_time] is + not set or is in the past then Cloud Tasks will set it to the + current time. Task De-duplication: Explicitly specifying a + task ID enables task de-duplication. If a task's ID is + identical to that of an existing task or a task that was + deleted or executed recently then the call will fail with + [ALREADY\_EXISTS][google.rpc.Code.ALREADY\_EXISTS]. If the + task's queue was created using Cloud Tasks, then another task + with the same name can't be created for ~1hour after the + original task was deleted or executed. If the task's queue was + created using queue.yaml or queue.xml, then another task with + the same name can't be created for ~9days after the original + task was deleted or executed. Because there is an extra + lookup cost to identify duplicate task names, these + [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] + calls have significantly increased latency. Using hashed + strings for the task id or for the prefix of the task id is + recommended. Choosing task ids that are sequential or have + sequential prefixes, for example using a timestamp, causes an + increase in latency and error rates in all task commands. The + infrastructure relies on an approximately uniform distribution + of task ids to store and serve tasks efficiently. + response_view: + The response\_view specifies which subset of the + [Task][google.cloud.tasks.v2.Task] will be returned. By + default response\_view is + [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + information is retrieved by default because some data, such as + payloads, might be desirable to return only when needed + because of its large size or because of the sensitivity of + data that it contains. Authorization for + [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + ``cloudtasks.tasks.fullView`` `Google IAM + `_ permission on the + [Task][google.cloud.tasks.v2.Task] resource. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.CreateTaskRequest) + ), +) +_sym_db.RegisterMessage(CreateTaskRequest) + +DeleteTaskRequest = _reflection.GeneratedProtocolMessageType( + "DeleteTaskRequest", + (_message.Message,), + dict( + DESCRIPTOR=_DELETETASKREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for deleting a task using + [DeleteTask][google.cloud.tasks.v2.CloudTasks.DeleteTask]. + + + Attributes: + name: + Required. The task name. For example: ``projects/PROJECT_ID/l + ocations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.DeleteTaskRequest) + ), +) +_sym_db.RegisterMessage(DeleteTaskRequest) + +RunTaskRequest = _reflection.GeneratedProtocolMessageType( + "RunTaskRequest", + (_message.Message,), + dict( + DESCRIPTOR=_RUNTASKREQUEST, + __module__="google.cloud.tasks_v2.proto.cloudtasks_pb2", + __doc__="""Request message for forcing a task to run now using + [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask]. + + + Attributes: + name: + Required. The task name. For example: ``projects/PROJECT_ID/l + ocations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` + response_view: + The response\_view specifies which subset of the + [Task][google.cloud.tasks.v2.Task] will be returned. By + default response\_view is + [BASIC][google.cloud.tasks.v2.Task.View.BASIC]; not all + information is retrieved by default because some data, such as + payloads, might be desirable to return only when needed + because of its large size or because of the sensitivity of + data that it contains. Authorization for + [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + ``cloudtasks.tasks.fullView`` `Google IAM + `_ permission on the + [Task][google.cloud.tasks.v2.Task] resource. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.RunTaskRequest) + ), +) +_sym_db.RegisterMessage(RunTaskRequest) + + +DESCRIPTOR._options = None + +_CLOUDTASKS = _descriptor.ServiceDescriptor( + name="CloudTasks", + full_name="google.cloud.tasks.v2.CloudTasks", + file=DESCRIPTOR, + index=0, + serialized_options=None, + serialized_start=1489, + serialized_end=3888, + methods=[ + _descriptor.MethodDescriptor( + name="ListQueues", + full_name="google.cloud.tasks.v2.CloudTasks.ListQueues", + index=0, + containing_service=None, + input_type=_LISTQUEUESREQUEST, + output_type=_LISTQUEUESRESPONSE, + serialized_options=_b( + "\202\323\344\223\002,\022*/v2/{parent=projects/*/locations/*}/queues" + ), + ), + _descriptor.MethodDescriptor( + name="GetQueue", + full_name="google.cloud.tasks.v2.CloudTasks.GetQueue", + index=1, + containing_service=None, + input_type=_GETQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + "\202\323\344\223\002,\022*/v2/{name=projects/*/locations/*/queues/*}" + ), + ), + _descriptor.MethodDescriptor( + name="CreateQueue", + full_name="google.cloud.tasks.v2.CloudTasks.CreateQueue", + index=2, + containing_service=None, + input_type=_CREATEQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + '\202\323\344\223\0023"*/v2/{parent=projects/*/locations/*}/queues:\005queue' + ), + ), + _descriptor.MethodDescriptor( + name="UpdateQueue", + full_name="google.cloud.tasks.v2.CloudTasks.UpdateQueue", + index=3, + containing_service=None, + input_type=_UPDATEQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + "\202\323\344\223\002920/v2/{queue.name=projects/*/locations/*/queues/*}:\005queue" + ), + ), + _descriptor.MethodDescriptor( + name="DeleteQueue", + full_name="google.cloud.tasks.v2.CloudTasks.DeleteQueue", + index=4, + containing_service=None, + input_type=_DELETEQUEUEREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + serialized_options=_b( + "\202\323\344\223\002,**/v2/{name=projects/*/locations/*/queues/*}" + ), + ), + _descriptor.MethodDescriptor( + name="PurgeQueue", + full_name="google.cloud.tasks.v2.CloudTasks.PurgeQueue", + index=5, + containing_service=None, + input_type=_PURGEQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + '\202\323\344\223\0025"0/v2/{name=projects/*/locations/*/queues/*}:purge:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="PauseQueue", + full_name="google.cloud.tasks.v2.CloudTasks.PauseQueue", + index=6, + containing_service=None, + input_type=_PAUSEQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + '\202\323\344\223\0025"0/v2/{name=projects/*/locations/*/queues/*}:pause:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="ResumeQueue", + full_name="google.cloud.tasks.v2.CloudTasks.ResumeQueue", + index=7, + containing_service=None, + input_type=_RESUMEQUEUEREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2._QUEUE, + serialized_options=_b( + '\202\323\344\223\0026"1/v2/{name=projects/*/locations/*/queues/*}:resume:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="GetIamPolicy", + full_name="google.cloud.tasks.v2.CloudTasks.GetIamPolicy", + index=8, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._GETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + serialized_options=_b( + '\202\323\344\223\002@";/v2/{resource=projects/*/locations/*/queues/*}:getIamPolicy:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="SetIamPolicy", + full_name="google.cloud.tasks.v2.CloudTasks.SetIamPolicy", + index=9, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._SETIAMPOLICYREQUEST, + output_type=google_dot_iam_dot_v1_dot_policy__pb2._POLICY, + serialized_options=_b( + '\202\323\344\223\002@";/v2/{resource=projects/*/locations/*/queues/*}:setIamPolicy:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="TestIamPermissions", + full_name="google.cloud.tasks.v2.CloudTasks.TestIamPermissions", + index=10, + containing_service=None, + input_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSREQUEST, + output_type=google_dot_iam_dot_v1_dot_iam__policy__pb2._TESTIAMPERMISSIONSRESPONSE, + serialized_options=_b( + '\202\323\344\223\002F"A/v2/{resource=projects/*/locations/*/queues/*}:testIamPermissions:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="ListTasks", + full_name="google.cloud.tasks.v2.CloudTasks.ListTasks", + index=11, + containing_service=None, + input_type=_LISTTASKSREQUEST, + output_type=_LISTTASKSRESPONSE, + serialized_options=_b( + "\202\323\344\223\0024\0222/v2/{parent=projects/*/locations/*/queues/*}/tasks" + ), + ), + _descriptor.MethodDescriptor( + name="GetTask", + full_name="google.cloud.tasks.v2.CloudTasks.GetTask", + index=12, + containing_service=None, + input_type=_GETTASKREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK, + serialized_options=_b( + "\202\323\344\223\0024\0222/v2/{name=projects/*/locations/*/queues/*/tasks/*}" + ), + ), + _descriptor.MethodDescriptor( + name="CreateTask", + full_name="google.cloud.tasks.v2.CloudTasks.CreateTask", + index=13, + containing_service=None, + input_type=_CREATETASKREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK, + serialized_options=_b( + '\202\323\344\223\0027"2/v2/{parent=projects/*/locations/*/queues/*}/tasks:\001*' + ), + ), + _descriptor.MethodDescriptor( + name="DeleteTask", + full_name="google.cloud.tasks.v2.CloudTasks.DeleteTask", + index=14, + containing_service=None, + input_type=_DELETETASKREQUEST, + output_type=google_dot_protobuf_dot_empty__pb2._EMPTY, + serialized_options=_b( + "\202\323\344\223\0024*2/v2/{name=projects/*/locations/*/queues/*/tasks/*}" + ), + ), + _descriptor.MethodDescriptor( + name="RunTask", + full_name="google.cloud.tasks.v2.CloudTasks.RunTask", + index=15, + containing_service=None, + input_type=_RUNTASKREQUEST, + output_type=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2._TASK, + serialized_options=_b( + '\202\323\344\223\002;"6/v2/{name=projects/*/locations/*/queues/*/tasks/*}:run:\001*' + ), + ), + ], +) +_sym_db.RegisterServiceDescriptor(_CLOUDTASKS) + +DESCRIPTOR.services_by_name["CloudTasks"] = _CLOUDTASKS + +# @@protoc_insertion_point(module_scope) diff --git a/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2_grpc.py b/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2_grpc.py new file mode 100644 index 0000000000000..7b2c706e05dd9 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/cloudtasks_pb2_grpc.py @@ -0,0 +1,437 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.tasks_v2.proto import ( + cloudtasks_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2, +) +from google.cloud.tasks_v2.proto import ( + queue_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2, +) +from google.cloud.tasks_v2.proto import ( + task_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2, +) +from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_iam__policy__pb2 +from google.iam.v1 import policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 +from google.protobuf import empty_pb2 as google_dot_protobuf_dot_empty__pb2 + + +class CloudTasksStub(object): + """Cloud Tasks allows developers to manage the execution of background + work in their applications. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListQueues = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/ListQueues", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListQueuesRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListQueuesResponse.FromString, + ) + self.GetQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/GetQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.GetQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.CreateQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/CreateQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.CreateQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.UpdateQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/UpdateQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.UpdateQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.DeleteQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/DeleteQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.DeleteQueueRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.PurgeQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/PurgeQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.PurgeQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.PauseQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/PauseQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.PauseQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.ResumeQueue = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/ResumeQueue", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ResumeQueueRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.FromString, + ) + self.GetIamPolicy = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/GetIamPolicy", + request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.SerializeToString, + response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, + ) + self.SetIamPolicy = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/SetIamPolicy", + request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.SerializeToString, + response_deserializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.FromString, + ) + self.TestIamPermissions = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/TestIamPermissions", + request_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.SerializeToString, + response_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.FromString, + ) + self.ListTasks = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/ListTasks", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListTasksRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListTasksResponse.FromString, + ) + self.GetTask = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/GetTask", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.GetTaskRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.FromString, + ) + self.CreateTask = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/CreateTask", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.CreateTaskRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.FromString, + ) + self.DeleteTask = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/DeleteTask", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.DeleteTaskRequest.SerializeToString, + response_deserializer=google_dot_protobuf_dot_empty__pb2.Empty.FromString, + ) + self.RunTask = channel.unary_unary( + "/google.cloud.tasks.v2.CloudTasks/RunTask", + request_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.RunTaskRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.FromString, + ) + + +class CloudTasksServicer(object): + """Cloud Tasks allows developers to manage the execution of background + work in their applications. + """ + + def ListQueues(self, request, context): + """Lists queues. + + Queues are returned in lexicographical order. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetQueue(self, request, context): + """Gets a queue. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def CreateQueue(self, request, context): + """Creates a queue. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless of whether + it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + Read + [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + before using this method. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def UpdateQueue(self, request, context): + """Updates a queue. + + This method creates the queue if it does not exist and updates + the queue if it does exist. + + Queues created with this method allow tasks to live for a maximum of 31 + days. After a task is 31 days old, the task will be deleted regardless of whether + it was dispatched or not. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + Read + [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + before using this method. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def DeleteQueue(self, request, context): + """Deletes a queue. + + This command will delete the queue even if it has tasks in it. + + Note: If you delete a queue, a queue with the same name can't be created + for 7 days. + + WARNING: Using this method may have unintended side effects if you are + using an App Engine `queue.yaml` or `queue.xml` file to manage your queues. + Read + [Overview of Queue Management and queue.yaml](https://cloud.google.com/tasks/docs/queue-yaml) + before using this method. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def PurgeQueue(self, request, context): + """Purges a queue by deleting all of its tasks. + + All tasks created before this method is called are permanently deleted. + + Purge operations can take up to one minute to take effect. Tasks + might be dispatched before the purge takes effect. A purge is irreversible. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def PauseQueue(self, request, context): + """Pauses the queue. + + If a queue is paused then the system will stop dispatching tasks + until the queue is resumed via + [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue]. Tasks can still be added + when the queue is paused. A queue is paused if its + [state][google.cloud.tasks.v2.Queue.state] is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ResumeQueue(self, request, context): + """Resume a queue. + + This method resumes a queue after it has been + [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED] or + [DISABLED][google.cloud.tasks.v2.Queue.State.DISABLED]. The state of a queue is stored + in the queue's [state][google.cloud.tasks.v2.Queue.state]; after calling this method it + will be set to [RUNNING][google.cloud.tasks.v2.Queue.State.RUNNING]. + + WARNING: Resuming many high-QPS queues at the same time can + lead to target overloading. If you are resuming high-QPS + queues, follow the 500/50/5 pattern described in + [Managing Cloud Tasks Scaling Risks](https://cloud.google.com/tasks/docs/manage-cloud-task-scaling). + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetIamPolicy(self, request, context): + """Gets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. + Returns an empty policy if the resource exists and does not have a policy + set. + + Authorization requires the following + [Google IAM](https://cloud.google.com/iam) permission on the specified + resource parent: + + * `cloudtasks.queues.getIamPolicy` + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def SetIamPolicy(self, request, context): + """Sets the access control policy for a [Queue][google.cloud.tasks.v2.Queue]. Replaces any existing + policy. + + Note: The Cloud Console does not check queue-level IAM permissions yet. + Project-level permissions are required to use the Cloud Console. + + Authorization requires the following + [Google IAM](https://cloud.google.com/iam) permission on the specified + resource parent: + + * `cloudtasks.queues.setIamPolicy` + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def TestIamPermissions(self, request, context): + """Returns permissions that a caller has on a [Queue][google.cloud.tasks.v2.Queue]. + If the resource does not exist, this will return an empty set of + permissions, not a [NOT_FOUND][google.rpc.Code.NOT_FOUND] error. + + Note: This operation is designed to be used for building permission-aware + UIs and command-line tools, not for authorization checking. This operation + may "fail open" without warning. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def ListTasks(self, request, context): + """Lists the tasks in a queue. + + By default, only the [BASIC][google.cloud.tasks.v2.Task.View.BASIC] view is retrieved + due to performance considerations; + [response_view][google.cloud.tasks.v2.ListTasksRequest.response_view] controls the + subset of information which is returned. + + The tasks may be returned in any order. The ordering may change at any + time. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def GetTask(self, request, context): + """Gets a task. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def CreateTask(self, request, context): + """Creates a task and adds it to a queue. + + Tasks cannot be updated after creation; there is no UpdateTask command. + + * For [App Engine queues][google.cloud.tasks.v2.AppEngineHttpQueue], the maximum task size is + 100KB. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def DeleteTask(self, request, context): + """Deletes a task. + + A task can be deleted if it is scheduled or dispatched. A task + cannot be deleted if it has executed successfully or permanently + failed. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + def RunTask(self, request, context): + """Forces a task to run now. + + When this method is called, Cloud Tasks will dispatch the task, even if + the task is already running, the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits] or + is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + + This command is meant to be used for manual debugging. For + example, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] can be used to retry a failed + task after a fix has been made or to manually force a task to be + dispatched now. + + The dispatched task is returned. That is, the task that is returned + contains the [status][Task.status] after the task is dispatched but + before the task is received by its target. + + If Cloud Tasks receives a successful response from the task's + target, then the task will be deleted; otherwise the task's + [schedule_time][google.cloud.tasks.v2.Task.schedule_time] will be reset to the time that + [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] was called plus the retry delay specified + in the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig]. + + [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask] returns + [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a + task that has already succeeded or permanently failed. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + +def add_CloudTasksServicer_to_server(servicer, server): + rpc_method_handlers = { + "ListQueues": grpc.unary_unary_rpc_method_handler( + servicer.ListQueues, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListQueuesRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListQueuesResponse.SerializeToString, + ), + "GetQueue": grpc.unary_unary_rpc_method_handler( + servicer.GetQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.GetQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "CreateQueue": grpc.unary_unary_rpc_method_handler( + servicer.CreateQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.CreateQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "UpdateQueue": grpc.unary_unary_rpc_method_handler( + servicer.UpdateQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.UpdateQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "DeleteQueue": grpc.unary_unary_rpc_method_handler( + servicer.DeleteQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.DeleteQueueRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + "PurgeQueue": grpc.unary_unary_rpc_method_handler( + servicer.PurgeQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.PurgeQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "PauseQueue": grpc.unary_unary_rpc_method_handler( + servicer.PauseQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.PauseQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "ResumeQueue": grpc.unary_unary_rpc_method_handler( + servicer.ResumeQueue, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ResumeQueueRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_queue__pb2.Queue.SerializeToString, + ), + "GetIamPolicy": grpc.unary_unary_rpc_method_handler( + servicer.GetIamPolicy, + request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.GetIamPolicyRequest.FromString, + response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, + ), + "SetIamPolicy": grpc.unary_unary_rpc_method_handler( + servicer.SetIamPolicy, + request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.SetIamPolicyRequest.FromString, + response_serializer=google_dot_iam_dot_v1_dot_policy__pb2.Policy.SerializeToString, + ), + "TestIamPermissions": grpc.unary_unary_rpc_method_handler( + servicer.TestIamPermissions, + request_deserializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsRequest.FromString, + response_serializer=google_dot_iam_dot_v1_dot_iam__policy__pb2.TestIamPermissionsResponse.SerializeToString, + ), + "ListTasks": grpc.unary_unary_rpc_method_handler( + servicer.ListTasks, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListTasksRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.ListTasksResponse.SerializeToString, + ), + "GetTask": grpc.unary_unary_rpc_method_handler( + servicer.GetTask, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.GetTaskRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.SerializeToString, + ), + "CreateTask": grpc.unary_unary_rpc_method_handler( + servicer.CreateTask, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.CreateTaskRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.SerializeToString, + ), + "DeleteTask": grpc.unary_unary_rpc_method_handler( + servicer.DeleteTask, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.DeleteTaskRequest.FromString, + response_serializer=google_dot_protobuf_dot_empty__pb2.Empty.SerializeToString, + ), + "RunTask": grpc.unary_unary_rpc_method_handler( + servicer.RunTask, + request_deserializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_cloudtasks__pb2.RunTaskRequest.FromString, + response_serializer=google_dot_cloud_dot_tasks__v2_dot_proto_dot_task__pb2.Task.SerializeToString, + ), + } + generic_handler = grpc.method_handlers_generic_handler( + "google.cloud.tasks.v2.CloudTasks", rpc_method_handlers + ) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/tasks/google/cloud/tasks_v2/proto/queue.proto b/tasks/google/cloud/tasks_v2/proto/queue.proto new file mode 100644 index 0000000000000..b38b614151682 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/queue.proto @@ -0,0 +1,342 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.tasks.v2; + +import "google/api/annotations.proto"; +import "google/api/resource.proto"; +import "google/cloud/tasks/v2/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks"; +option java_multiple_files = true; +option java_outer_classname = "QueueProto"; +option java_package = "com.google.cloud.tasks.v2"; + + +// A queue is a container of related tasks. Queues are configured to manage +// how those tasks are dispatched. Configurable properties include rate limits, +// retry options, queue types, and others. +message Queue { + // State of the queue. + enum State { + // Unspecified state. + STATE_UNSPECIFIED = 0; + + // The queue is running. Tasks can be dispatched. + // + // If the queue was created using Cloud Tasks and the queue has + // had no activity (method calls or task dispatches) for 30 days, + // the queue may take a few minutes to re-activate. Some method + // calls may return [NOT_FOUND][google.rpc.Code.NOT_FOUND] and + // tasks may not be dispatched for a few minutes until the queue + // has been re-activated. + RUNNING = 1; + + // Tasks are paused by the user. If the queue is paused then Cloud + // Tasks will stop delivering tasks from it, but more tasks can + // still be added to it by the user. + PAUSED = 2; + + // The queue is disabled. + // + // A queue becomes `DISABLED` when + // [queue.yaml](https://cloud.google.com/appengine/docs/python/config/queueref) + // or + // [queue.xml](https://cloud.google.com/appengine/docs/standard/java/config/queueref) + // is uploaded which does not contain the queue. You cannot directly disable + // a queue. + // + // When a queue is disabled, tasks can still be added to a queue + // but the tasks are not dispatched. + // + // To permanently delete this queue and all of its tasks, call + // [DeleteQueue][google.cloud.tasks.v2.CloudTasks.DeleteQueue]. + DISABLED = 3; + } + + // Caller-specified and required in [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue], + // after which it becomes output only. + // + // The queue name. + // + // The queue name must have the following format: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID` + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the queue's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or + // hyphens (-). The maximum length is 100 characters. + string name = 1; + + // Overrides for + // [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. + // These settings apply only to + // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in this queue. + // + // If set, `app_engine_routing_override` is used for all + // [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in the queue, no matter what the + // setting is for the + // [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. + AppEngineRouting app_engine_routing_override = 2; + + // Rate limits for task dispatches. + // + // [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] and [retry_config][google.cloud.tasks.v2.Queue.retry_config] are + // related because they both control task attempts. However they control task + // attempts in different ways: + // + // * [rate_limits][google.cloud.tasks.v2.Queue.rate_limits] controls the total rate of + // dispatches from a queue (i.e. all traffic dispatched from the + // queue, regardless of whether the dispatch is from a first + // attempt or a retry). + // * [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls what happens to + // particular a task after its first attempt fails. That is, + // [retry_config][google.cloud.tasks.v2.Queue.retry_config] controls task retries (the + // second attempt, third attempt, etc). + // + // The queue's actual dispatch rate is the result of: + // + // * Number of tasks in the queue + // * User-specified throttling: [rate_limits][google.cloud.tasks.v2.Queue.rate_limits], + // [retry_config][google.cloud.tasks.v2.Queue.retry_config], and the + // [queue's state][google.cloud.tasks.v2.Queue.state]. + // * System throttling due to `429` (Too Many Requests) or `503` (Service + // Unavailable) responses from the worker, high error rates, or to smooth + // sudden large traffic spikes. + RateLimits rate_limits = 3; + + // Settings that determine the retry behavior. + // + // * For tasks created using Cloud Tasks: the queue-level retry settings + // apply to all tasks in the queue that were created using Cloud Tasks. + // Retry settings cannot be set on individual tasks. + // * For tasks created using the App Engine SDK: the queue-level retry + // settings apply to all tasks in the queue which do not have retry settings + // explicitly set on the task and were created by the App Engine SDK. See + // [App Engine + // documentation](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/retrying-tasks). + RetryConfig retry_config = 4; + + // Output only. The state of the queue. + // + // `state` can only be changed by called + // [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue], + // [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue], or uploading + // [queue.yaml/xml](https://cloud.google.com/appengine/docs/python/config/queueref). + // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] cannot be used to change `state`. + State state = 5; + + // Output only. The last time this queue was purged. + // + // All tasks that were [created][google.cloud.tasks.v2.Task.create_time] before this time + // were purged. + // + // A queue can be purged using [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue], the + // [App Engine Task Queue SDK, or the Cloud + // Console](https://cloud.google.com/appengine/docs/standard/python/taskqueue/push/deleting-tasks-and-queues#purging_all_tasks_from_a_queue). + // + // Purge time will be truncated to the nearest microsecond. Purge + // time will be unset if the queue has never been purged. + google.protobuf.Timestamp purge_time = 6; +} + +// Rate limits. +// +// This message determines the maximum rate that tasks can be dispatched by a +// queue, regardless of whether the dispatch is a first task attempt or a retry. +// +// Note: The debugging command, [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask], will run a task +// even if the queue has reached its [RateLimits][google.cloud.tasks.v2.RateLimits]. +message RateLimits { + // The maximum rate at which tasks are dispatched from this queue. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // * For [App Engine queues][google.cloud.tasks.v2.AppEngineHttpQueue], the maximum allowed value + // is 500. + // + // + // This field has the same meaning as + // [rate in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#rate). + double max_dispatches_per_second = 1; + + // Output only. The max burst size. + // + // Max burst size limits how fast tasks in queue are processed when + // many tasks are in the queue and the rate is high. This field + // allows the queue to have a high rate so processing starts shortly + // after a task is enqueued, but still limits resource usage when + // many tasks are enqueued in a short period of time. + // + // The [token bucket](https://wikipedia.org/wiki/Token_Bucket) + // algorithm is used to control the rate of task dispatches. Each + // queue has a token bucket that holds tokens, up to the maximum + // specified by `max_burst_size`. Each time a task is dispatched, a + // token is removed from the bucket. Tasks will be dispatched until + // the queue's bucket runs out of tokens. The bucket will be + // continuously refilled with new tokens based on + // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]. + // + // Cloud Tasks will pick the value of `max_burst_size` based on the + // value of + // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second]. + // + // For App Engine queues that were created or updated using + // `queue.yaml/xml`, `max_burst_size` is equal to + // [bucket_size](https://cloud.google.com/appengine/docs/standard/python/config/queueref#bucket_size). + // Since `max_burst_size` is output only, if + // [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] is called on a queue + // created by `queue.yaml/xml`, `max_burst_size` will be reset based + // on the value of + // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second], + // regardless of whether + // [max_dispatches_per_second][google.cloud.tasks.v2.RateLimits.max_dispatches_per_second] + // is updated. + // + int32 max_burst_size = 2; + + // The maximum number of concurrent tasks that Cloud Tasks allows + // to be dispatched for this queue. After this threshold has been + // reached, Cloud Tasks stops dispatching tasks until the number of + // concurrent requests decreases. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // + // The maximum allowed value is 5,000. + // + // + // This field has the same meaning as + // [max_concurrent_requests in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#max_concurrent_requests). + int32 max_concurrent_dispatches = 3; +} + +// Retry config. +// +// These settings determine when a failed task attempt is retried. +message RetryConfig { + // Number of attempts per task. + // + // Cloud Tasks will attempt the task `max_attempts` times (that is, if the + // first attempt fails, then there will be `max_attempts - 1` retries). Must + // be >= -1. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // -1 indicates unlimited attempts. + // + // This field has the same meaning as + // [task_retry_limit in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). + int32 max_attempts = 1; + + // If positive, `max_retry_duration` specifies the time limit for + // retrying a failed task, measured from when the task was first + // attempted. Once `max_retry_duration` time has passed *and* the + // task has been attempted [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] + // times, no further attempts will be made and the task will be + // deleted. + // + // If zero, then the task age is unlimited. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // + // `max_retry_duration` will be truncated to the nearest second. + // + // This field has the same meaning as + // [task_age_limit in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). + google.protobuf.Duration max_retry_duration = 2; + + // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for retry between + // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] and + // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration after it fails, + // if the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task should be + // retried. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // + // `min_backoff` will be truncated to the nearest second. + // + // This field has the same meaning as + // [min_backoff_seconds in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). + google.protobuf.Duration min_backoff = 3; + + // A task will be [scheduled][google.cloud.tasks.v2.Task.schedule_time] for retry between + // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] and + // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] duration after it fails, + // if the queue's [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies that the task should be + // retried. + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // + // `max_backoff` will be truncated to the nearest second. + // + // This field has the same meaning as + // [max_backoff_seconds in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). + google.protobuf.Duration max_backoff = 4; + + // The time between retries will double `max_doublings` times. + // + // A task's retry interval starts at + // [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff], then doubles + // `max_doublings` times, then increases linearly, and finally + // retries retries at intervals of + // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] up to + // [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] times. + // + // For example, if [min_backoff][google.cloud.tasks.v2.RetryConfig.min_backoff] is 10s, + // [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] is 300s, and + // `max_doublings` is 3, then the a task will first be retried in + // 10s. The retry interval will double three times, and then + // increase linearly by 2^3 * 10s. Finally, the task will retry at + // intervals of [max_backoff][google.cloud.tasks.v2.RetryConfig.max_backoff] until the + // task has been attempted [max_attempts][google.cloud.tasks.v2.RetryConfig.max_attempts] + // times. Thus, the requests will retry at 10s, 20s, 40s, 80s, 160s, + // 240s, 300s, 300s, .... + // + // If unspecified when the queue is created, Cloud Tasks will pick the + // default. + // + // + // This field has the same meaning as + // [max_doublings in + // queue.yaml/xml](https://cloud.google.com/appengine/docs/standard/python/config/queueref#retry_parameters). + int32 max_doublings = 5; +} diff --git a/tasks/google/cloud/tasks_v2/proto/queue_pb2.py b/tasks/google/cloud/tasks_v2/proto/queue_pb2.py new file mode 100644 index 0000000000000..34d36b269cc71 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/queue_pb2.py @@ -0,0 +1,687 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/tasks_v2/proto/queue.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.cloud.tasks_v2.proto import ( + target_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2, +) +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/tasks_v2/proto/queue.proto", + package="google.cloud.tasks.v2", + syntax="proto3", + serialized_options=_b( + "\n\031com.google.cloud.tasks.v2B\nQueueProtoP\001Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks" + ), + serialized_pb=_b( + '\n\'google/cloud/tasks_v2/proto/queue.proto\x12\x15google.cloud.tasks.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/tasks_v2/proto/target.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xff\x02\n\x05Queue\x12\x0c\n\x04name\x18\x01 \x01(\t\x12L\n\x1b\x61pp_engine_routing_override\x18\x02 \x01(\x0b\x32\'.google.cloud.tasks.v2.AppEngineRouting\x12\x36\n\x0brate_limits\x18\x03 \x01(\x0b\x32!.google.cloud.tasks.v2.RateLimits\x12\x38\n\x0cretry_config\x18\x04 \x01(\x0b\x32".google.cloud.tasks.v2.RetryConfig\x12\x31\n\x05state\x18\x05 \x01(\x0e\x32".google.cloud.tasks.v2.Queue.State\x12.\n\npurge_time\x18\x06 \x01(\x0b\x32\x1a.google.protobuf.Timestamp"E\n\x05State\x12\x15\n\x11STATE_UNSPECIFIED\x10\x00\x12\x0b\n\x07RUNNING\x10\x01\x12\n\n\x06PAUSED\x10\x02\x12\x0c\n\x08\x44ISABLED\x10\x03"j\n\nRateLimits\x12!\n\x19max_dispatches_per_second\x18\x01 \x01(\x01\x12\x16\n\x0emax_burst_size\x18\x02 \x01(\x05\x12!\n\x19max_concurrent_dispatches\x18\x03 \x01(\x05"\xd1\x01\n\x0bRetryConfig\x12\x14\n\x0cmax_attempts\x18\x01 \x01(\x05\x12\x35\n\x12max_retry_duration\x18\x02 \x01(\x0b\x32\x19.google.protobuf.Duration\x12.\n\x0bmin_backoff\x18\x03 \x01(\x0b\x32\x19.google.protobuf.Duration\x12.\n\x0bmax_backoff\x18\x04 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x15\n\rmax_doublings\x18\x05 \x01(\x05\x42\x65\n\x19\x63om.google.cloud.tasks.v2B\nQueueProtoP\x01Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasksb\x06proto3' + ), + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2.DESCRIPTOR, + google_dot_protobuf_dot_duration__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + ], +) + + +_QUEUE_STATE = _descriptor.EnumDescriptor( + name="State", + full_name="google.cloud.tasks.v2.Queue.State", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="STATE_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="RUNNING", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="PAUSED", index=2, number=2, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="DISABLED", index=3, number=3, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=545, + serialized_end=614, +) +_sym_db.RegisterEnumDescriptor(_QUEUE_STATE) + + +_QUEUE = _descriptor.Descriptor( + name="Queue", + full_name="google.cloud.tasks.v2.Queue", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.Queue.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="app_engine_routing_override", + full_name="google.cloud.tasks.v2.Queue.app_engine_routing_override", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="rate_limits", + full_name="google.cloud.tasks.v2.Queue.rate_limits", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="retry_config", + full_name="google.cloud.tasks.v2.Queue.retry_config", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="state", + full_name="google.cloud.tasks.v2.Queue.state", + index=4, + number=5, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="purge_time", + full_name="google.cloud.tasks.v2.Queue.purge_time", + index=5, + number=6, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[_QUEUE_STATE], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=231, + serialized_end=614, +) + + +_RATELIMITS = _descriptor.Descriptor( + name="RateLimits", + full_name="google.cloud.tasks.v2.RateLimits", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="max_dispatches_per_second", + full_name="google.cloud.tasks.v2.RateLimits.max_dispatches_per_second", + index=0, + number=1, + type=1, + cpp_type=5, + label=1, + has_default_value=False, + default_value=float(0), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="max_burst_size", + full_name="google.cloud.tasks.v2.RateLimits.max_burst_size", + index=1, + number=2, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="max_concurrent_dispatches", + full_name="google.cloud.tasks.v2.RateLimits.max_concurrent_dispatches", + index=2, + number=3, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=616, + serialized_end=722, +) + + +_RETRYCONFIG = _descriptor.Descriptor( + name="RetryConfig", + full_name="google.cloud.tasks.v2.RetryConfig", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="max_attempts", + full_name="google.cloud.tasks.v2.RetryConfig.max_attempts", + index=0, + number=1, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="max_retry_duration", + full_name="google.cloud.tasks.v2.RetryConfig.max_retry_duration", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="min_backoff", + full_name="google.cloud.tasks.v2.RetryConfig.min_backoff", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="max_backoff", + full_name="google.cloud.tasks.v2.RetryConfig.max_backoff", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="max_doublings", + full_name="google.cloud.tasks.v2.RetryConfig.max_doublings", + index=4, + number=5, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=725, + serialized_end=934, +) + +_QUEUE.fields_by_name[ + "app_engine_routing_override" +].message_type = ( + google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2._APPENGINEROUTING +) +_QUEUE.fields_by_name["rate_limits"].message_type = _RATELIMITS +_QUEUE.fields_by_name["retry_config"].message_type = _RETRYCONFIG +_QUEUE.fields_by_name["state"].enum_type = _QUEUE_STATE +_QUEUE.fields_by_name[ + "purge_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_QUEUE_STATE.containing_type = _QUEUE +_RETRYCONFIG.fields_by_name[ + "max_retry_duration" +].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_RETRYCONFIG.fields_by_name[ + "min_backoff" +].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_RETRYCONFIG.fields_by_name[ + "max_backoff" +].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +DESCRIPTOR.message_types_by_name["Queue"] = _QUEUE +DESCRIPTOR.message_types_by_name["RateLimits"] = _RATELIMITS +DESCRIPTOR.message_types_by_name["RetryConfig"] = _RETRYCONFIG +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Queue = _reflection.GeneratedProtocolMessageType( + "Queue", + (_message.Message,), + dict( + DESCRIPTOR=_QUEUE, + __module__="google.cloud.tasks_v2.proto.queue_pb2", + __doc__="""A queue is a container of related tasks. Queues are configured to manage + how those tasks are dispatched. Configurable properties include rate + limits, retry options, queue types, and others. + + + Attributes: + name: + Caller-specified and required in + [CreateQueue][google.cloud.tasks.v2.CloudTasks.CreateQueue], + after which it becomes output only. The queue name. The + queue name must have the following format: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` + - ``PROJECT_ID`` can contain letters ([A-Za-z]), numbers + ([0-9]), hyphens (-), colons (:), or periods (.). For more + information, see `Identifying projects + `_ - ``LOCATION_ID`` + is the canonical ID for the queue's location. The list of + available locations can be obtained by calling [ListLocatio + ns][google.cloud.location.Locations.ListLocations]. For + more information, see + https://cloud.google.com/about/locations/. - ``QUEUE_ID`` can + contain letters ([A-Za-z]), numbers ([0-9]), or hyphens + (-). The maximum length is 100 characters. + app_engine_routing_override: + Overrides for [task-level app\_engine\_routing][google.cloud.t + asks.v2.AppEngineHttpRequest.app\_engine\_routing]. These + settings apply only to [App Engine + tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in this + queue. If set, ``app_engine_routing_override`` is used for + all [App Engine + tasks][google.cloud.tasks.v2.AppEngineHttpRequest] in the + queue, no matter what the setting is for the [task-level app\_ + engine\_routing][google.cloud.tasks.v2.AppEngineHttpRequest.ap + p\_engine\_routing]. + rate_limits: + Rate limits for task dispatches. + [rate\_limits][google.cloud.tasks.v2.Queue.rate\_limits] and + [retry\_config][google.cloud.tasks.v2.Queue.retry\_config] are + related because they both control task attempts. However they + control task attempts in different ways: - + [rate\_limits][google.cloud.tasks.v2.Queue.rate\_limits] + controls the total rate of dispatches from a queue (i.e. + all traffic dispatched from the queue, regardless of + whether the dispatch is from a first attempt or a retry). - + [retry\_config][google.cloud.tasks.v2.Queue.retry\_config] + controls what happens to particular a task after its first + attempt fails. That is, + [retry\_config][google.cloud.tasks.v2.Queue.retry\_config] + controls task retries (the second attempt, third attempt, + etc). The queue's actual dispatch rate is the result of: - + Number of tasks in the queue - User-specified throttling: + [rate\_limits][google.cloud.tasks.v2.Queue.rate\_limits], + [retry\_config][google.cloud.tasks.v2.Queue.retry\_config], + and the [queue's state][google.cloud.tasks.v2.Queue.state]. + - System throttling due to ``429`` (Too Many Requests) or + ``503`` (Service Unavailable) responses from the worker, + high error rates, or to smooth sudden large traffic spikes. + retry_config: + Settings that determine the retry behavior. - For tasks + created using Cloud Tasks: the queue-level retry settings + apply to all tasks in the queue that were created using Cloud + Tasks. Retry settings cannot be set on individual tasks. - + For tasks created using the App Engine SDK: the queue-level + retry settings apply to all tasks in the queue which do not + have retry settings explicitly set on the task and were + created by the App Engine SDK. See `App Engine + documentation `_. + state: + Output only. The state of the queue. ``state`` can only be + changed by called + [PauseQueue][google.cloud.tasks.v2.CloudTasks.PauseQueue], + [ResumeQueue][google.cloud.tasks.v2.CloudTasks.ResumeQueue], + or uploading `queue.yaml/xml `_. + [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] + cannot be used to change ``state``. + purge_time: + Output only. The last time this queue was purged. All tasks + that were [created][google.cloud.tasks.v2.Task.create\_time] + before this time were purged. A queue can be purged using + [PurgeQueue][google.cloud.tasks.v2.CloudTasks.PurgeQueue], the + `App Engine Task Queue SDK, or the Cloud Console `_. + Purge time will be truncated to the nearest microsecond. Purge + time will be unset if the queue has never been purged. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.Queue) + ), +) +_sym_db.RegisterMessage(Queue) + +RateLimits = _reflection.GeneratedProtocolMessageType( + "RateLimits", + (_message.Message,), + dict( + DESCRIPTOR=_RATELIMITS, + __module__="google.cloud.tasks_v2.proto.queue_pb2", + __doc__="""Rate limits. + + This message determines the maximum rate that tasks can be dispatched by + a queue, regardless of whether the dispatch is a first task attempt or a + retry. + + Note: The debugging command, + [RunTask][google.cloud.tasks.v2.CloudTasks.RunTask], will run a task + even if the queue has reached its + [RateLimits][google.cloud.tasks.v2.RateLimits]. + + + Attributes: + max_dispatches_per_second: + The maximum rate at which tasks are dispatched from this + queue. If unspecified when the queue is created, Cloud Tasks + will pick the default. - For [App Engine + queues][google.cloud.tasks.v2.AppEngineHttpQueue], the + maximum allowed value is 500. This field has the same meaning + as `rate in queue.yaml/xml `_. + max_burst_size: + Output only. The max burst size. Max burst size limits how + fast tasks in queue are processed when many tasks are in the + queue and the rate is high. This field allows the queue to + have a high rate so processing starts shortly after a task is + enqueued, but still limits resource usage when many tasks are + enqueued in a short period of time. The `token bucket + `_ algorithm is used + to control the rate of task dispatches. Each queue has a token + bucket that holds tokens, up to the maximum specified by + ``max_burst_size``. Each time a task is dispatched, a token is + removed from the bucket. Tasks will be dispatched until the + queue's bucket runs out of tokens. The bucket will be + continuously refilled with new tokens based on [max\_dispatche + s\_per\_second][google.cloud.tasks.v2.RateLimits.max\_dispatch + es\_per\_second]. Cloud Tasks will pick the value of + ``max_burst_size`` based on the value of [max\_dispatches\_per + \_second][google.cloud.tasks.v2.RateLimits.max\_dispatches\_pe + r\_second]. For App Engine queues that were created or + updated using ``queue.yaml/xml``, ``max_burst_size`` is equal + to `bucket\_size `_. Since + ``max_burst_size`` is output only, if + [UpdateQueue][google.cloud.tasks.v2.CloudTasks.UpdateQueue] is + called on a queue created by ``queue.yaml/xml``, + ``max_burst_size`` will be reset based on the value of [max\_d + ispatches\_per\_second][google.cloud.tasks.v2.RateLimits.max\_ + dispatches\_per\_second], regardless of whether [max\_dispatch + es\_per\_second][google.cloud.tasks.v2.RateLimits.max\_dispatc + hes\_per\_second] is updated. + max_concurrent_dispatches: + The maximum number of concurrent tasks that Cloud Tasks allows + to be dispatched for this queue. After this threshold has been + reached, Cloud Tasks stops dispatching tasks until the number + of concurrent requests decreases. If unspecified when the + queue is created, Cloud Tasks will pick the default. The + maximum allowed value is 5,000. This field has the same + meaning as `max\_concurrent\_requests in queue.yaml/xml `_. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.RateLimits) + ), +) +_sym_db.RegisterMessage(RateLimits) + +RetryConfig = _reflection.GeneratedProtocolMessageType( + "RetryConfig", + (_message.Message,), + dict( + DESCRIPTOR=_RETRYCONFIG, + __module__="google.cloud.tasks_v2.proto.queue_pb2", + __doc__="""Retry config. + + These settings determine when a failed task attempt is retried. + + + Attributes: + max_attempts: + Number of attempts per task. Cloud Tasks will attempt the + task ``max_attempts`` times (that is, if the first attempt + fails, then there will be ``max_attempts - 1`` retries). Must + be >= -1. If unspecified when the queue is created, Cloud + Tasks will pick the default. -1 indicates unlimited attempts. + This field has the same meaning as `task\_retry\_limit in + queue.yaml/xml `_. + max_retry_duration: + If positive, ``max_retry_duration`` specifies the time limit + for retrying a failed task, measured from when the task was + first attempted. Once ``max_retry_duration`` time has passed + *and* the task has been attempted [max\_attempts][google.cloud + .tasks.v2.RetryConfig.max\_attempts] times, no further + attempts will be made and the task will be deleted. If zero, + then the task age is unlimited. If unspecified when the queue + is created, Cloud Tasks will pick the default. + ``max_retry_duration`` will be truncated to the nearest + second. This field has the same meaning as `task\_age\_limit + in queue.yaml/xml `_. + min_backoff: + A task will be + [scheduled][google.cloud.tasks.v2.Task.schedule\_time] for + retry between + [min\_backoff][google.cloud.tasks.v2.RetryConfig.min\_backoff] + and + [max\_backoff][google.cloud.tasks.v2.RetryConfig.max\_backoff] + duration after it fails, if the queue's + [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies + that the task should be retried. If unspecified when the + queue is created, Cloud Tasks will pick the default. + ``min_backoff`` will be truncated to the nearest second. This + field has the same meaning as `min\_backoff\_seconds in + queue.yaml/xml `_. + max_backoff: + A task will be + [scheduled][google.cloud.tasks.v2.Task.schedule\_time] for + retry between + [min\_backoff][google.cloud.tasks.v2.RetryConfig.min\_backoff] + and + [max\_backoff][google.cloud.tasks.v2.RetryConfig.max\_backoff] + duration after it fails, if the queue's + [RetryConfig][google.cloud.tasks.v2.RetryConfig] specifies + that the task should be retried. If unspecified when the + queue is created, Cloud Tasks will pick the default. + ``max_backoff`` will be truncated to the nearest second. This + field has the same meaning as `max\_backoff\_seconds in + queue.yaml/xml `_. + max_doublings: + The time between retries will double ``max_doublings`` times. + A task's retry interval starts at [min\_backoff][google.cloud. + tasks.v2.RetryConfig.min\_backoff], then doubles + ``max_doublings`` times, then increases linearly, and finally + retries retries at intervals of + [max\_backoff][google.cloud.tasks.v2.RetryConfig.max\_backoff] + up to [max\_attempts][google.cloud.tasks.v2.RetryConfig.max\_a + ttempts] times. For example, if + [min\_backoff][google.cloud.tasks.v2.RetryConfig.min\_backoff] + is 10s, + [max\_backoff][google.cloud.tasks.v2.RetryConfig.max\_backoff] + is 300s, and ``max_doublings`` is 3, then the a task will + first be retried in 10s. The retry interval will double three + times, and then increase linearly by 2^3 \* 10s. Finally, the + task will retry at intervals of + [max\_backoff][google.cloud.tasks.v2.RetryConfig.max\_backoff] + until the task has been attempted [max\_attempts][google.cloud + .tasks.v2.RetryConfig.max\_attempts] times. Thus, the requests + will retry at 10s, 20s, 40s, 80s, 160s, 240s, 300s, 300s, .... + If unspecified when the queue is created, Cloud Tasks will + pick the default. This field has the same meaning as + `max\_doublings in queue.yaml/xml + `__. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.RetryConfig) + ), +) +_sym_db.RegisterMessage(RetryConfig) + + +DESCRIPTOR._options = None +# @@protoc_insertion_point(module_scope) diff --git a/tasks/google/cloud/tasks_v2/proto/queue_pb2_grpc.py b/tasks/google/cloud/tasks_v2/proto/queue_pb2_grpc.py new file mode 100644 index 0000000000000..07cb78fe03a94 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/queue_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/tasks/google/cloud/tasks_v2/proto/target.proto b/tasks/google/cloud/tasks_v2/proto/target.proto new file mode 100644 index 0000000000000..8cf991e97bf1e --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/target.proto @@ -0,0 +1,274 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.tasks.v2; + +import "google/api/annotations.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks"; +option java_multiple_files = true; +option java_outer_classname = "TargetProto"; +option java_package = "com.google.cloud.tasks.v2"; + + +// App Engine HTTP request. +// +// The message defines the HTTP request that is sent to an App Engine app when +// the task is dispatched. +// +// This proto can only be used for tasks in a queue which has +// [app_engine_http_queue][Queue.app_engine_http_queue] set. +// +// Using [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] requires +// [`appengine.applications.get`](https://cloud.google.com/appengine/docs/admin-api/access-control) +// Google IAM permission for the project +// and the following scope: +// +// `https://www.googleapis.com/auth/cloud-platform` +// +// The task will be delivered to the App Engine app which belongs to the same +// project as the queue. For more information, see +// [How Requests are +// Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) +// and how routing is affected by +// [dispatch +// files](https://cloud.google.com/appengine/docs/python/config/dispatchref). +// Traffic is encrypted during transport and never leaves Google datacenters. +// Because this traffic is carried over a communication mechanism internal to +// Google, you cannot explicitly set the protocol (for example, HTTP or HTTPS). +// The request to the handler, however, will appear to have used the HTTP +// protocol. +// +// The [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] used to construct the URL that the task is +// delivered to can be set at the queue-level or task-level: +// +// * If set, +// [app_engine_routing_override][google.cloud.tasks.v2.AppEngineHttpQueue.app_engine_routing_override] +// is used for all tasks in the queue, no matter what the setting +// is for the +// [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. +// +// +// The `url` that the task will be sent to is: +// +// * `url =` [host][google.cloud.tasks.v2.AppEngineRouting.host] `+` +// [relative_uri][google.cloud.tasks.v2.AppEngineHttpRequest.relative_uri] +// +// Tasks can be dispatched to secure app handlers, unsecure app handlers, and +// URIs restricted with +// [`login: +// admin`](https://cloud.google.com/appengine/docs/standard/python/config/appref). +// Because tasks are not run as any user, they cannot be dispatched to URIs +// restricted with +// [`login: +// required`](https://cloud.google.com/appengine/docs/standard/python/config/appref) +// Task dispatches also do not follow redirects. +// +// The task attempt has succeeded if the app's request handler returns +// an HTTP response code in the range [`200` - `299`]. `503` is +// considered an App Engine system error instead of an application +// error. Requests returning error `503` will be retried regardless of +// retry configuration and not counted against retry counts. +// Any other response code or a failure to receive a response before the +// deadline is a failed attempt. +message AppEngineHttpRequest { + // The HTTP method to use for the request. The default is POST. + // + // The app's request handler for the task's target URL must be able to handle + // HTTP requests with this http_method, otherwise the task attempt will fail + // with error code 405 (Method Not Allowed). See + // [Writing a push task request + // handler](https://cloud.google.com/appengine/docs/java/taskqueue/push/creating-handlers#writing_a_push_task_request_handler) + // and the documentation for the request handlers in the language your app is + // written in e.g. + // [Python Request + // Handler](https://cloud.google.com/appengine/docs/python/tools/webapp/requesthandlerclass). + HttpMethod http_method = 1; + + // Task-level setting for App Engine routing. + // + // If set, + // [app_engine_routing_override][google.cloud.tasks.v2.AppEngineHttpQueue.app_engine_routing_override] + // is used for all tasks in the queue, no matter what the setting is for the + // [task-level app_engine_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing]. + AppEngineRouting app_engine_routing = 2; + + // The relative URI. + // + // The relative URI must begin with "/" and must be a valid HTTP relative URI. + // It can contain a path and query string arguments. + // If the relative URI is empty, then the root path "/" will be used. + // No spaces are allowed, and the maximum length allowed is 2083 characters. + string relative_uri = 3; + + // HTTP request headers. + // + // This map contains the header field names and values. + // Headers can be set when the + // [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask]. + // Repeated headers are not supported but a header value can contain commas. + // + // Cloud Tasks sets some headers to default values: + // + // * `User-Agent`: By default, this header is + // `"AppEngine-Google; (+http://code.google.com/appengine)"`. + // This header can be modified, but Cloud Tasks will append + // `"AppEngine-Google; (+http://code.google.com/appengine)"` to the + // modified `User-Agent`. + // + // If the task has a [body][google.cloud.tasks.v2.AppEngineHttpRequest.body], Cloud + // Tasks sets the following headers: + // + // * `Content-Type`: By default, the `Content-Type` header is set to + // `"application/octet-stream"`. The default can be overridden by explicitly + // setting `Content-Type` to a particular media type when the + // [task is created][google.cloud.tasks.v2.CloudTasks.CreateTask]. + // For example, `Content-Type` can be set to `"application/json"`. + // * `Content-Length`: This is computed by Cloud Tasks. This value is + // output only. It cannot be changed. + // + // The headers below cannot be set or overridden: + // + // * `Host` + // * `X-Google-*` + // * `X-AppEngine-*` + // + // In addition, Cloud Tasks sets some headers when the task is dispatched, + // such as headers containing information about the task; see + // [request + // headers](https://cloud.google.com/appengine/docs/python/taskqueue/push/creating-handlers#reading_request_headers). + // These headers are set only when the task is dispatched, so they are not + // visible when the task is returned in a Cloud Tasks response. + // + // Although there is no specific limit for the maximum number of headers or + // the size, there is a limit on the maximum size of the [Task][google.cloud.tasks.v2.Task]. For more + // information, see the [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] documentation. + map headers = 4; + + // HTTP request body. + // + // A request body is allowed only if the HTTP method is POST or PUT. It is + // an error to set a body on a task with an incompatible [HttpMethod][google.cloud.tasks.v2.HttpMethod]. + bytes body = 5; +} + +// App Engine Routing. +// +// Defines routing characteristics specific to App Engine - service, version, +// and instance. +// +// For more information about services, versions, and instances see +// [An Overview of App +// Engine](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine), +// [Microservices Architecture on Google App +// Engine](https://cloud.google.com/appengine/docs/python/microservices-on-app-engine), +// [App Engine Standard request +// routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed), +// and [App Engine Flex request +// routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). +message AppEngineRouting { + // App service. + // + // By default, the task is sent to the service which is the default + // service when the task is attempted. + // + // For some queues or tasks which were created using the App Engine + // Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable + // into [service][google.cloud.tasks.v2.AppEngineRouting.service], + // [version][google.cloud.tasks.v2.AppEngineRouting.version], and + // [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example, some tasks + // which were created using the App Engine SDK use a custom domain + // name; custom domains are not parsed by Cloud Tasks. If + // [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then + // [service][google.cloud.tasks.v2.AppEngineRouting.service], + // [version][google.cloud.tasks.v2.AppEngineRouting.version], and + // [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty string. + string service = 1; + + // App version. + // + // By default, the task is sent to the version which is the default + // version when the task is attempted. + // + // For some queues or tasks which were created using the App Engine + // Task Queue API, [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable + // into [service][google.cloud.tasks.v2.AppEngineRouting.service], + // [version][google.cloud.tasks.v2.AppEngineRouting.version], and + // [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. For example, some tasks + // which were created using the App Engine SDK use a custom domain + // name; custom domains are not parsed by Cloud Tasks. If + // [host][google.cloud.tasks.v2.AppEngineRouting.host] is not parsable, then + // [service][google.cloud.tasks.v2.AppEngineRouting.service], + // [version][google.cloud.tasks.v2.AppEngineRouting.version], and + // [instance][google.cloud.tasks.v2.AppEngineRouting.instance] are the empty string. + string version = 2; + + // App instance. + // + // By default, the task is sent to an instance which is available when + // the task is attempted. + // + // Requests can only be sent to a specific instance if + // [manual scaling is used in App Engine + // Standard](https://cloud.google.com/appengine/docs/python/an-overview-of-app-engine?hl=en_US#scaling_types_and_instance_classes). + // App Engine Flex does not support instances. For more information, see + // [App Engine Standard request + // routing](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed) + // and [App Engine Flex request + // routing](https://cloud.google.com/appengine/docs/flexible/python/how-requests-are-routed). + string instance = 3; + + // Output only. The host that the task is sent to. + // + // The host is constructed from the domain name of the app associated with + // the queue's project ID (for example .appspot.com), and the + // [service][google.cloud.tasks.v2.AppEngineRouting.service], [version][google.cloud.tasks.v2.AppEngineRouting.version], + // and [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. Tasks which were created using + // the App Engine SDK might have a custom domain name. + // + // For more information, see + // [How Requests are + // Routed](https://cloud.google.com/appengine/docs/standard/python/how-requests-are-routed). + string host = 4; +} + +// The HTTP method used to deliver the task. +enum HttpMethod { + // HTTP method unspecified + HTTP_METHOD_UNSPECIFIED = 0; + + // HTTP POST + POST = 1; + + // HTTP GET + GET = 2; + + // HTTP HEAD + HEAD = 3; + + // HTTP PUT + PUT = 4; + + // HTTP DELETE + DELETE = 5; + + // HTTP PATCH + PATCH = 6; + + // HTTP OPTIONS + OPTIONS = 7; +} diff --git a/tasks/google/cloud/tasks_v2/proto/target_pb2.py b/tasks/google/cloud/tasks_v2/proto/target_pb2.py new file mode 100644 index 0000000000000..57a1bf2550f0d --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/target_pb2.py @@ -0,0 +1,600 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/tasks_v2/proto/target.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/tasks_v2/proto/target.proto", + package="google.cloud.tasks.v2", + syntax="proto3", + serialized_options=_b( + "\n\031com.google.cloud.tasks.v2B\013TargetProtoP\001Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks" + ), + serialized_pb=_b( + '\n(google/cloud/tasks_v2/proto/target.proto\x12\x15google.cloud.tasks.v2\x1a\x1cgoogle/api/annotations.proto"\xb2\x02\n\x14\x41ppEngineHttpRequest\x12\x36\n\x0bhttp_method\x18\x01 \x01(\x0e\x32!.google.cloud.tasks.v2.HttpMethod\x12\x43\n\x12\x61pp_engine_routing\x18\x02 \x01(\x0b\x32\'.google.cloud.tasks.v2.AppEngineRouting\x12\x14\n\x0crelative_uri\x18\x03 \x01(\t\x12I\n\x07headers\x18\x04 \x03(\x0b\x32\x38.google.cloud.tasks.v2.AppEngineHttpRequest.HeadersEntry\x12\x0c\n\x04\x62ody\x18\x05 \x01(\x0c\x1a.\n\x0cHeadersEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\r\n\x05value\x18\x02 \x01(\t:\x02\x38\x01"T\n\x10\x41ppEngineRouting\x12\x0f\n\x07service\x18\x01 \x01(\t\x12\x0f\n\x07version\x18\x02 \x01(\t\x12\x10\n\x08instance\x18\x03 \x01(\t\x12\x0c\n\x04host\x18\x04 \x01(\t*s\n\nHttpMethod\x12\x1b\n\x17HTTP_METHOD_UNSPECIFIED\x10\x00\x12\x08\n\x04POST\x10\x01\x12\x07\n\x03GET\x10\x02\x12\x08\n\x04HEAD\x10\x03\x12\x07\n\x03PUT\x10\x04\x12\n\n\x06\x44\x45LETE\x10\x05\x12\t\n\x05PATCH\x10\x06\x12\x0b\n\x07OPTIONS\x10\x07\x42\x66\n\x19\x63om.google.cloud.tasks.v2B\x0bTargetProtoP\x01Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasksb\x06proto3' + ), + dependencies=[google_dot_api_dot_annotations__pb2.DESCRIPTOR], +) + +_HTTPMETHOD = _descriptor.EnumDescriptor( + name="HttpMethod", + full_name="google.cloud.tasks.v2.HttpMethod", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="HTTP_METHOD_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="POST", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="GET", index=2, number=2, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="HEAD", index=3, number=3, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="PUT", index=4, number=4, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="DELETE", index=5, number=5, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="PATCH", index=6, number=6, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="OPTIONS", index=7, number=7, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=492, + serialized_end=607, +) +_sym_db.RegisterEnumDescriptor(_HTTPMETHOD) + +HttpMethod = enum_type_wrapper.EnumTypeWrapper(_HTTPMETHOD) +HTTP_METHOD_UNSPECIFIED = 0 +POST = 1 +GET = 2 +HEAD = 3 +PUT = 4 +DELETE = 5 +PATCH = 6 +OPTIONS = 7 + + +_APPENGINEHTTPREQUEST_HEADERSENTRY = _descriptor.Descriptor( + name="HeadersEntry", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.HeadersEntry", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="key", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.HeadersEntry.key", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="value", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.HeadersEntry.value", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=_b("8\001"), + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=358, + serialized_end=404, +) + +_APPENGINEHTTPREQUEST = _descriptor.Descriptor( + name="AppEngineHttpRequest", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="http_method", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.http_method", + index=0, + number=1, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="app_engine_routing", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.app_engine_routing", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="relative_uri", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.relative_uri", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="headers", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.headers", + index=3, + number=4, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="body", + full_name="google.cloud.tasks.v2.AppEngineHttpRequest.body", + index=4, + number=5, + type=12, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b(""), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[_APPENGINEHTTPREQUEST_HEADERSENTRY], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=98, + serialized_end=404, +) + + +_APPENGINEROUTING = _descriptor.Descriptor( + name="AppEngineRouting", + full_name="google.cloud.tasks.v2.AppEngineRouting", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="service", + full_name="google.cloud.tasks.v2.AppEngineRouting.service", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="version", + full_name="google.cloud.tasks.v2.AppEngineRouting.version", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="instance", + full_name="google.cloud.tasks.v2.AppEngineRouting.instance", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="host", + full_name="google.cloud.tasks.v2.AppEngineRouting.host", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=406, + serialized_end=490, +) + +_APPENGINEHTTPREQUEST_HEADERSENTRY.containing_type = _APPENGINEHTTPREQUEST +_APPENGINEHTTPREQUEST.fields_by_name["http_method"].enum_type = _HTTPMETHOD +_APPENGINEHTTPREQUEST.fields_by_name[ + "app_engine_routing" +].message_type = _APPENGINEROUTING +_APPENGINEHTTPREQUEST.fields_by_name[ + "headers" +].message_type = _APPENGINEHTTPREQUEST_HEADERSENTRY +DESCRIPTOR.message_types_by_name["AppEngineHttpRequest"] = _APPENGINEHTTPREQUEST +DESCRIPTOR.message_types_by_name["AppEngineRouting"] = _APPENGINEROUTING +DESCRIPTOR.enum_types_by_name["HttpMethod"] = _HTTPMETHOD +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +AppEngineHttpRequest = _reflection.GeneratedProtocolMessageType( + "AppEngineHttpRequest", + (_message.Message,), + dict( + HeadersEntry=_reflection.GeneratedProtocolMessageType( + "HeadersEntry", + (_message.Message,), + dict( + DESCRIPTOR=_APPENGINEHTTPREQUEST_HEADERSENTRY, + __module__="google.cloud.tasks_v2.proto.target_pb2" + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.AppEngineHttpRequest.HeadersEntry) + ), + ), + DESCRIPTOR=_APPENGINEHTTPREQUEST, + __module__="google.cloud.tasks_v2.proto.target_pb2", + __doc__="""App Engine HTTP request. + + The message defines the HTTP request that is sent to an App Engine app + when the task is dispatched. + + This proto can only be used for tasks in a queue which has + [app\_engine\_http\_queue][Queue.app\_engine\_http\_queue] set. + + Using [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] + requires + ```appengine.applications.get`` `_ + Google IAM permission for the project and the following scope: + + ``https://www.googleapis.com/auth/cloud-platform`` + + The task will be delivered to the App Engine app which belongs to the + same project as the queue. For more information, see `How Requests are + Routed `_ + and how routing is affected by `dispatch + files `_. + Traffic is encrypted during transport and never leaves Google + datacenters. Because this traffic is carried over a communication + mechanism internal to Google, you cannot explicitly set the protocol + (for example, HTTP or HTTPS). The request to the handler, however, will + appear to have used the HTTP protocol. + + The [AppEngineRouting][google.cloud.tasks.v2.AppEngineRouting] used to + construct the URL that the task is delivered to can be set at the + queue-level or task-level: + + - If set, + [app\_engine\_routing\_override][google.cloud.tasks.v2.AppEngineHttpQueue.app\_engine\_routing\_override] + is used for all tasks in the queue, no matter what the setting is for + the [task-level + app\_engine\_routing][google.cloud.tasks.v2.AppEngineHttpRequest.app\_engine\_routing]. + + The ``url`` that the task will be sent to is: + + - ``url =`` [host][google.cloud.tasks.v2.AppEngineRouting.host] ``+`` + [relative\_uri][google.cloud.tasks.v2.AppEngineHttpRequest.relative\_uri] + + Tasks can be dispatched to secure app handlers, unsecure app handlers, + and URIs restricted with + ```login: admin`` `_. + Because tasks are not run as any user, they cannot be dispatched to URIs + restricted with + ```login: required`` `_ + Task dispatches also do not follow redirects. + + The task attempt has succeeded if the app's request handler returns an + HTTP response code in the range [``200`` - ``299``]. ``503`` is + considered an App Engine system error instead of an application error. + Requests returning error ``503`` will be retried regardless of retry + configuration and not counted against retry counts. Any other response + code or a failure to receive a response before the deadline is a failed + attempt. + + + Attributes: + http_method: + The HTTP method to use for the request. The default is POST. + The app's request handler for the task's target URL must be + able to handle HTTP requests with this http\_method, otherwise + the task attempt will fail with error code 405 (Method Not + Allowed). See `Writing a push task request handler `_ and the + documentation for the request handlers in the language your + app is written in e.g. `Python Request Handler `_. + app_engine_routing: + Task-level setting for App Engine routing. If set, [app\_engi + ne\_routing\_override][google.cloud.tasks.v2.AppEngineHttpQueu + e.app\_engine\_routing\_override] is used for all tasks in the + queue, no matter what the setting is for the [task-level app\_ + engine\_routing][google.cloud.tasks.v2.AppEngineHttpRequest.ap + p\_engine\_routing]. + relative_uri: + The relative URI. The relative URI must begin with "/" and + must be a valid HTTP relative URI. It can contain a path and + query string arguments. If the relative URI is empty, then the + root path "/" will be used. No spaces are allowed, and the + maximum length allowed is 2083 characters. + headers: + HTTP request headers. This map contains the header field + names and values. Headers can be set when the [task is + created][google.cloud.tasks.v2.CloudTasks.CreateTask]. + Repeated headers are not supported but a header value can + contain commas. Cloud Tasks sets some headers to default + values: - ``User-Agent``: By default, this header is + ``"AppEngine-Google; (+http://code.google.com/appengine)"``. + This header can be modified, but Cloud Tasks will append + ``"AppEngine-Google; (+http://code.google.com/appengine)"`` to + the modified ``User-Agent``. If the task has a + [body][google.cloud.tasks.v2.AppEngineHttpRequest.body], Cloud + Tasks sets the following headers: - ``Content-Type``: By + default, the ``Content-Type`` header is set to + ``"application/octet-stream"``. The default can be overridden + by explicitly setting ``Content-Type`` to a particular + media type when the [task is + created][google.cloud.tasks.v2.CloudTasks.CreateTask]. For + example, ``Content-Type`` can be set to + ``"application/json"``. - ``Content-Length``: This is + computed by Cloud Tasks. This value is output only. It + cannot be changed. The headers below cannot be set or + overridden: - ``Host`` - ``X-Google-*`` - + ``X-AppEngine-*`` In addition, Cloud Tasks sets some headers + when the task is dispatched, such as headers containing + information about the task; see `request headers `_. These headers are set + only when the task is dispatched, so they are not visible when + the task is returned in a Cloud Tasks response. Although + there is no specific limit for the maximum number of headers + or the size, there is a limit on the maximum size of the + [Task][google.cloud.tasks.v2.Task]. For more information, see + the [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask] + documentation. + body: + HTTP request body. A request body is allowed only if the HTTP + method is POST or PUT. It is an error to set a body on a task + with an incompatible + [HttpMethod][google.cloud.tasks.v2.HttpMethod]. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.AppEngineHttpRequest) + ), +) +_sym_db.RegisterMessage(AppEngineHttpRequest) +_sym_db.RegisterMessage(AppEngineHttpRequest.HeadersEntry) + +AppEngineRouting = _reflection.GeneratedProtocolMessageType( + "AppEngineRouting", + (_message.Message,), + dict( + DESCRIPTOR=_APPENGINEROUTING, + __module__="google.cloud.tasks_v2.proto.target_pb2", + __doc__="""App Engine Routing. + + Defines routing characteristics specific to App Engine - service, + version, and instance. + + For more information about services, versions, and instances see `An + Overview of App + Engine `_, + `Microservices Architecture on Google App + Engine `_, + `App Engine Standard request + routing `_, + and `App Engine Flex request + routing `_. + + + Attributes: + service: + App service. By default, the task is sent to the service + which is the default service when the task is attempted. For + some queues or tasks which were created using the App Engine + Task Queue API, + [host][google.cloud.tasks.v2.AppEngineRouting.host] is not + parsable into + [service][google.cloud.tasks.v2.AppEngineRouting.service], + [version][google.cloud.tasks.v2.AppEngineRouting.version], and + [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. + For example, some tasks which were created using the App + Engine SDK use a custom domain name; custom domains are not + parsed by Cloud Tasks. If + [host][google.cloud.tasks.v2.AppEngineRouting.host] is not + parsable, then + [service][google.cloud.tasks.v2.AppEngineRouting.service], + [version][google.cloud.tasks.v2.AppEngineRouting.version], and + [instance][google.cloud.tasks.v2.AppEngineRouting.instance] + are the empty string. + version: + App version. By default, the task is sent to the version + which is the default version when the task is attempted. For + some queues or tasks which were created using the App Engine + Task Queue API, + [host][google.cloud.tasks.v2.AppEngineRouting.host] is not + parsable into + [service][google.cloud.tasks.v2.AppEngineRouting.service], + [version][google.cloud.tasks.v2.AppEngineRouting.version], and + [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. + For example, some tasks which were created using the App + Engine SDK use a custom domain name; custom domains are not + parsed by Cloud Tasks. If + [host][google.cloud.tasks.v2.AppEngineRouting.host] is not + parsable, then + [service][google.cloud.tasks.v2.AppEngineRouting.service], + [version][google.cloud.tasks.v2.AppEngineRouting.version], and + [instance][google.cloud.tasks.v2.AppEngineRouting.instance] + are the empty string. + instance: + App instance. By default, the task is sent to an instance + which is available when the task is attempted. Requests can + only be sent to a specific instance if `manual scaling is used + in App Engine Standard + `_. + App Engine Flex does not support instances. For more + information, see `App Engine Standard request routing + `_ and `App Engine Flex request routing + `_. + host: + Output only. The host that the task is sent to. The host is + constructed from the domain name of the app associated with + the queue's project ID (for example .appspot.com), and the + [service][google.cloud.tasks.v2.AppEngineRouting.service], + [version][google.cloud.tasks.v2.AppEngineRouting.version], and + [instance][google.cloud.tasks.v2.AppEngineRouting.instance]. + Tasks which were created using the App Engine SDK might have a + custom domain name. For more information, see `How Requests + are Routed + `_. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.AppEngineRouting) + ), +) +_sym_db.RegisterMessage(AppEngineRouting) + + +DESCRIPTOR._options = None +_APPENGINEHTTPREQUEST_HEADERSENTRY._options = None +# @@protoc_insertion_point(module_scope) diff --git a/tasks/google/cloud/tasks_v2/proto/target_pb2_grpc.py b/tasks/google/cloud/tasks_v2/proto/target_pb2_grpc.py new file mode 100644 index 0000000000000..07cb78fe03a94 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/target_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/tasks/google/cloud/tasks_v2/proto/task.proto b/tasks/google/cloud/tasks_v2/proto/task.proto new file mode 100644 index 0000000000000..11be05c46d335 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/task.proto @@ -0,0 +1,182 @@ +// Copyright 2019 Google LLC. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// + +syntax = "proto3"; + +package google.cloud.tasks.v2; + +import "google/api/annotations.proto"; +import "google/api/resource.proto"; +import "google/cloud/tasks/v2/target.proto"; +import "google/protobuf/duration.proto"; +import "google/protobuf/timestamp.proto"; +import "google/rpc/status.proto"; + +option go_package = "google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks"; +option java_multiple_files = true; +option java_outer_classname = "TaskProto"; +option java_package = "com.google.cloud.tasks.v2"; + + +// A unit of scheduled work. +message Task { + // The view specifies a subset of [Task][google.cloud.tasks.v2.Task] data. + // + // When a task is returned in a response, not all + // information is retrieved by default because some data, such as + // payloads, might be desirable to return only when needed because + // of its large size or because of the sensitivity of data that it + // contains. + enum View { + // Unspecified. Defaults to BASIC. + VIEW_UNSPECIFIED = 0; + + // The basic view omits fields which can be large or can contain + // sensitive data. + // + // This view does not include the + // [body in AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest.body]. + // Bodies are desirable to return only when needed, because they + // can be large and because of the sensitivity of the data that you + // choose to store in it. + BASIC = 1; + + // All information is returned. + // + // Authorization for [FULL][google.cloud.tasks.v2.Task.View.FULL] requires + // `cloudtasks.tasks.fullView` [Google IAM](https://cloud.google.com/iam/) + // permission on the [Queue][google.cloud.tasks.v2.Queue] resource. + FULL = 2; + } + + // Optionally caller-specified in [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. + // + // The task name. + // + // The task name must have the following format: + // `projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID` + // + // * `PROJECT_ID` can contain letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), colons (:), or periods (.). + // For more information, see + // [Identifying + // projects](https://cloud.google.com/resource-manager/docs/creating-managing-projects#identifying_projects) + // * `LOCATION_ID` is the canonical ID for the task's location. + // The list of available locations can be obtained by calling + // [ListLocations][google.cloud.location.Locations.ListLocations]. + // For more information, see https://cloud.google.com/about/locations/. + // * `QUEUE_ID` can contain letters ([A-Za-z]), numbers ([0-9]), or + // hyphens (-). The maximum length is 100 characters. + // * `TASK_ID` can contain only letters ([A-Za-z]), numbers ([0-9]), + // hyphens (-), or underscores (_). The maximum length is 500 characters. + string name = 1; + + // Required. The message to send to the worker. + oneof message_type { + // HTTP request that is sent to the App Engine app handler. + // + // An App Engine task is a task that has [AppEngineHttpRequest][google.cloud.tasks.v2.AppEngineHttpRequest] set. + AppEngineHttpRequest app_engine_http_request = 2; + } + + // The time when the task is scheduled to be attempted. + // + // For App Engine queues, this is when the task will be attempted or retried. + // + // `schedule_time` will be truncated to the nearest microsecond. + google.protobuf.Timestamp schedule_time = 4; + + // Output only. The time that the task was created. + // + // `create_time` will be truncated to the nearest second. + google.protobuf.Timestamp create_time = 5; + + // The deadline for requests sent to the worker. If the worker does not + // respond by this deadline then the request is cancelled and the attempt + // is marked as a `DEADLINE_EXCEEDED` failure. Cloud Tasks will retry the + // task according to the [RetryConfig][google.cloud.tasks.v2.RetryConfig]. + // + // Note that when the request is cancelled, Cloud Tasks will stop listing for + // the response, but whether the worker stops processing depends on the + // worker. For example, if the worker is stuck, it may not react to cancelled + // requests. + // + // The default and maximum values depend on the type of request: + // + // + // * For [App Engine tasks][google.cloud.tasks.v2.AppEngineHttpRequest], 0 indicates that the + // request has the default deadline. The default deadline depends on the + // [scaling + // type](https://cloud.google.com/appengine/docs/standard/go/how-instances-are-managed#instance_scaling) + // of the service: 10 minutes for standard apps with automatic scaling, 24 + // hours for standard apps with manual and basic scaling, and 60 minutes for + // flex apps. If the request deadline is set, it must be in the interval [15 + // seconds, 24 hours 15 seconds]. Regardless of the task's + // `dispatch_deadline`, the app handler will not run for longer than than + // the service's timeout. We recommend setting the `dispatch_deadline` to + // at most a few seconds more than the app handler's timeout. For more + // information see + // [Timeouts](https://cloud.google.com/tasks/docs/creating-appengine-handlers#timeouts). + // + // `dispatch_deadline` will be truncated to the nearest millisecond. The + // deadline is an approximate deadline. + google.protobuf.Duration dispatch_deadline = 6; + + // Output only. The number of attempts dispatched. + // + // This count includes attempts which have been dispatched but haven't + // received a response. + int32 dispatch_count = 7; + + // Output only. The number of attempts which have received a response. + int32 response_count = 8; + + // Output only. The status of the task's first attempt. + // + // Only [dispatch_time][google.cloud.tasks.v2.Attempt.dispatch_time] will be set. + // The other [Attempt][google.cloud.tasks.v2.Attempt] information is not retained by Cloud Tasks. + Attempt first_attempt = 9; + + // Output only. The status of the task's last attempt. + Attempt last_attempt = 10; + + // Output only. The view specifies which subset of the [Task][google.cloud.tasks.v2.Task] has + // been returned. + View view = 11; +} + +// The status of a task attempt. +message Attempt { + // Output only. The time that this attempt was scheduled. + // + // `schedule_time` will be truncated to the nearest microsecond. + google.protobuf.Timestamp schedule_time = 1; + + // Output only. The time that this attempt was dispatched. + // + // `dispatch_time` will be truncated to the nearest microsecond. + google.protobuf.Timestamp dispatch_time = 2; + + // Output only. The time that this attempt response was received. + // + // `response_time` will be truncated to the nearest microsecond. + google.protobuf.Timestamp response_time = 3; + + // Output only. The response from the worker for this attempt. + // + // If `response_time` is unset, then the task has not been attempted or is + // currently running and the `response_status` field is meaningless. + google.rpc.Status response_status = 4; +} diff --git a/tasks/google/cloud/tasks_v2/proto/task_pb2.py b/tasks/google/cloud/tasks_v2/proto/task_pb2.py new file mode 100644 index 0000000000000..474699e1bc221 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/task_pb2.py @@ -0,0 +1,549 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/tasks_v2/proto/task.proto + +import sys + +_b = sys.version_info[0] < 3 and (lambda x: x) or (lambda x: x.encode("latin1")) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.cloud.tasks_v2.proto import ( + target_pb2 as google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2, +) +from google.protobuf import duration_pb2 as google_dot_protobuf_dot_duration__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 +from google.rpc import status_pb2 as google_dot_rpc_dot_status__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/tasks_v2/proto/task.proto", + package="google.cloud.tasks.v2", + syntax="proto3", + serialized_options=_b( + "\n\031com.google.cloud.tasks.v2B\tTaskProtoP\001Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasks" + ), + serialized_pb=_b( + '\n&google/cloud/tasks_v2/proto/task.proto\x12\x15google.cloud.tasks.v2\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/api/resource.proto\x1a(google/cloud/tasks_v2/proto/target.proto\x1a\x1egoogle/protobuf/duration.proto\x1a\x1fgoogle/protobuf/timestamp.proto\x1a\x17google/rpc/status.proto"\x8e\x04\n\x04Task\x12\x0c\n\x04name\x18\x01 \x01(\t\x12N\n\x17\x61pp_engine_http_request\x18\x02 \x01(\x0b\x32+.google.cloud.tasks.v2.AppEngineHttpRequestH\x00\x12\x31\n\rschedule_time\x18\x04 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12/\n\x0b\x63reate_time\x18\x05 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x34\n\x11\x64ispatch_deadline\x18\x06 \x01(\x0b\x32\x19.google.protobuf.Duration\x12\x16\n\x0e\x64ispatch_count\x18\x07 \x01(\x05\x12\x16\n\x0eresponse_count\x18\x08 \x01(\x05\x12\x35\n\rfirst_attempt\x18\t \x01(\x0b\x32\x1e.google.cloud.tasks.v2.Attempt\x12\x34\n\x0clast_attempt\x18\n \x01(\x0b\x32\x1e.google.cloud.tasks.v2.Attempt\x12.\n\x04view\x18\x0b \x01(\x0e\x32 .google.cloud.tasks.v2.Task.View"1\n\x04View\x12\x14\n\x10VIEW_UNSPECIFIED\x10\x00\x12\t\n\x05\x42\x41SIC\x10\x01\x12\x08\n\x04\x46ULL\x10\x02\x42\x0e\n\x0cmessage_type"\xcf\x01\n\x07\x41ttempt\x12\x31\n\rschedule_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x31\n\rdispatch_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x31\n\rresponse_time\x18\x03 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12+\n\x0fresponse_status\x18\x04 \x01(\x0b\x32\x12.google.rpc.StatusBd\n\x19\x63om.google.cloud.tasks.v2B\tTaskProtoP\x01Z:google.golang.org/genproto/googleapis/cloud/tasks/v2;tasksb\x06proto3' + ), + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2.DESCRIPTOR, + google_dot_protobuf_dot_duration__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + google_dot_rpc_dot_status__pb2.DESCRIPTOR, + ], +) + + +_TASK_VIEW = _descriptor.EnumDescriptor( + name="View", + full_name="google.cloud.tasks.v2.Task.View", + filename=None, + file=DESCRIPTOR, + values=[ + _descriptor.EnumValueDescriptor( + name="VIEW_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + ), + _descriptor.EnumValueDescriptor( + name="BASIC", index=1, number=1, serialized_options=None, type=None + ), + _descriptor.EnumValueDescriptor( + name="FULL", index=2, number=2, serialized_options=None, type=None + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=716, + serialized_end=765, +) +_sym_db.RegisterEnumDescriptor(_TASK_VIEW) + + +_TASK = _descriptor.Descriptor( + name="Task", + full_name="google.cloud.tasks.v2.Task", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.tasks.v2.Task.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=_b("").decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="app_engine_http_request", + full_name="google.cloud.tasks.v2.Task.app_engine_http_request", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="schedule_time", + full_name="google.cloud.tasks.v2.Task.schedule_time", + index=2, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="create_time", + full_name="google.cloud.tasks.v2.Task.create_time", + index=3, + number=5, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="dispatch_deadline", + full_name="google.cloud.tasks.v2.Task.dispatch_deadline", + index=4, + number=6, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="dispatch_count", + full_name="google.cloud.tasks.v2.Task.dispatch_count", + index=5, + number=7, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_count", + full_name="google.cloud.tasks.v2.Task.response_count", + index=6, + number=8, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="first_attempt", + full_name="google.cloud.tasks.v2.Task.first_attempt", + index=7, + number=9, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="last_attempt", + full_name="google.cloud.tasks.v2.Task.last_attempt", + index=8, + number=10, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="view", + full_name="google.cloud.tasks.v2.Task.view", + index=9, + number=11, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[_TASK_VIEW], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="message_type", + full_name="google.cloud.tasks.v2.Task.message_type", + index=0, + containing_type=None, + fields=[], + ) + ], + serialized_start=255, + serialized_end=781, +) + + +_ATTEMPT = _descriptor.Descriptor( + name="Attempt", + full_name="google.cloud.tasks.v2.Attempt", + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name="schedule_time", + full_name="google.cloud.tasks.v2.Attempt.schedule_time", + index=0, + number=1, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="dispatch_time", + full_name="google.cloud.tasks.v2.Attempt.dispatch_time", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_time", + full_name="google.cloud.tasks.v2.Attempt.response_time", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + _descriptor.FieldDescriptor( + name="response_status", + full_name="google.cloud.tasks.v2.Attempt.response_status", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=784, + serialized_end=991, +) + +_TASK.fields_by_name[ + "app_engine_http_request" +].message_type = ( + google_dot_cloud_dot_tasks__v2_dot_proto_dot_target__pb2._APPENGINEHTTPREQUEST +) +_TASK.fields_by_name[ + "schedule_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_TASK.fields_by_name[ + "create_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_TASK.fields_by_name[ + "dispatch_deadline" +].message_type = google_dot_protobuf_dot_duration__pb2._DURATION +_TASK.fields_by_name["first_attempt"].message_type = _ATTEMPT +_TASK.fields_by_name["last_attempt"].message_type = _ATTEMPT +_TASK.fields_by_name["view"].enum_type = _TASK_VIEW +_TASK_VIEW.containing_type = _TASK +_TASK.oneofs_by_name["message_type"].fields.append( + _TASK.fields_by_name["app_engine_http_request"] +) +_TASK.fields_by_name["app_engine_http_request"].containing_oneof = _TASK.oneofs_by_name[ + "message_type" +] +_ATTEMPT.fields_by_name[ + "schedule_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_ATTEMPT.fields_by_name[ + "dispatch_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_ATTEMPT.fields_by_name[ + "response_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_ATTEMPT.fields_by_name[ + "response_status" +].message_type = google_dot_rpc_dot_status__pb2._STATUS +DESCRIPTOR.message_types_by_name["Task"] = _TASK +DESCRIPTOR.message_types_by_name["Attempt"] = _ATTEMPT +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Task = _reflection.GeneratedProtocolMessageType( + "Task", + (_message.Message,), + dict( + DESCRIPTOR=_TASK, + __module__="google.cloud.tasks_v2.proto.task_pb2", + __doc__="""A unit of scheduled work. + + + Attributes: + name: + Optionally caller-specified in + [CreateTask][google.cloud.tasks.v2.CloudTasks.CreateTask]. + The task name. The task name must have the following format: + ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/ta + sks/TASK_ID`` - ``PROJECT_ID`` can contain letters + ([A-Za-z]), numbers ([0-9]), hyphens (-), colons (:), or + periods (.). For more information, see `Identifying + projects `_ - ``LOCATION_ID`` is the + canonical ID for the task's location. The list of available + locations can be obtained by calling [ListLocations][google + .cloud.location.Locations.ListLocations]. For more + information, see https://cloud.google.com/about/locations/. - + ``QUEUE_ID`` can contain letters ([A-Za-z]), numbers ([0-9]), + or hyphens (-). The maximum length is 100 characters. - + ``TASK_ID`` can contain only letters ([A-Za-z]), numbers + ([0-9]), hyphens (-), or underscores (\_). The maximum + length is 500 characters. + message_type: + Required. The message to send to the worker. + app_engine_http_request: + HTTP request that is sent to the App Engine app handler. An + App Engine task is a task that has [AppEngineHttpRequest][goog + le.cloud.tasks.v2.AppEngineHttpRequest] set. + schedule_time: + The time when the task is scheduled to be attempted. For App + Engine queues, this is when the task will be attempted or + retried. ``schedule_time`` will be truncated to the nearest + microsecond. + create_time: + Output only. The time that the task was created. + ``create_time`` will be truncated to the nearest second. + dispatch_deadline: + The deadline for requests sent to the worker. If the worker + does not respond by this deadline then the request is + cancelled and the attempt is marked as a ``DEADLINE_EXCEEDED`` + failure. Cloud Tasks will retry the task according to the + [RetryConfig][google.cloud.tasks.v2.RetryConfig]. Note that + when the request is cancelled, Cloud Tasks will stop listing + for the response, but whether the worker stops processing + depends on the worker. For example, if the worker is stuck, it + may not react to cancelled requests. The default and maximum + values depend on the type of request: - For [App Engine + tasks][google.cloud.tasks.v2.AppEngineHttpRequest], 0 + indicates that the request has the default deadline. The + default deadline depends on the `scaling type + `_ of the service: + 10 minutes for standard apps with automatic scaling, 24 + hours for standard apps with manual and basic scaling, and 60 + minutes for flex apps. If the request deadline is set, it must + be in the interval [15 seconds, 24 hours 15 seconds]. + Regardless of the task's ``dispatch_deadline``, the app + handler will not run for longer than than the service's + timeout. We recommend setting the ``dispatch_deadline`` to + at most a few seconds more than the app handler's timeout. + For more information see `Timeouts + `_. ``dispatch_deadline`` will be + truncated to the nearest millisecond. The deadline is an + approximate deadline. + dispatch_count: + Output only. The number of attempts dispatched. This count + includes attempts which have been dispatched but haven't + received a response. + response_count: + Output only. The number of attempts which have received a + response. + first_attempt: + Output only. The status of the task's first attempt. Only + [dispatch\_time][google.cloud.tasks.v2.Attempt.dispatch\_time] + will be set. The other + [Attempt][google.cloud.tasks.v2.Attempt] information is not + retained by Cloud Tasks. + last_attempt: + Output only. The status of the task's last attempt. + view: + Output only. The view specifies which subset of the + [Task][google.cloud.tasks.v2.Task] has been returned. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.Task) + ), +) +_sym_db.RegisterMessage(Task) + +Attempt = _reflection.GeneratedProtocolMessageType( + "Attempt", + (_message.Message,), + dict( + DESCRIPTOR=_ATTEMPT, + __module__="google.cloud.tasks_v2.proto.task_pb2", + __doc__="""The status of a task attempt. + + + Attributes: + schedule_time: + Output only. The time that this attempt was scheduled. + ``schedule_time`` will be truncated to the nearest + microsecond. + dispatch_time: + Output only. The time that this attempt was dispatched. + ``dispatch_time`` will be truncated to the nearest + microsecond. + response_time: + Output only. The time that this attempt response was received. + ``response_time`` will be truncated to the nearest + microsecond. + response_status: + Output only. The response from the worker for this attempt. + If ``response_time`` is unset, then the task has not been + attempted or is currently running and the ``response_status`` + field is meaningless. + """, + # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.Attempt) + ), +) +_sym_db.RegisterMessage(Attempt) + + +DESCRIPTOR._options = None +# @@protoc_insertion_point(module_scope) diff --git a/tasks/google/cloud/tasks_v2/proto/task_pb2_grpc.py b/tasks/google/cloud/tasks_v2/proto/task_pb2_grpc.py new file mode 100644 index 0000000000000..07cb78fe03a94 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/proto/task_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/tasks/google/cloud/tasks_v2/types.py b/tasks/google/cloud/tasks_v2/types.py new file mode 100644 index 0000000000000..8c2730ce5fd68 --- /dev/null +++ b/tasks/google/cloud/tasks_v2/types.py @@ -0,0 +1,60 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from __future__ import absolute_import +import sys + +from google.api_core.protobuf_helpers import get_messages + +from google.cloud.tasks_v2.proto import cloudtasks_pb2 +from google.cloud.tasks_v2.proto import queue_pb2 +from google.cloud.tasks_v2.proto import target_pb2 +from google.cloud.tasks_v2.proto import task_pb2 +from google.iam.v1 import iam_policy_pb2 +from google.iam.v1 import policy_pb2 +from google.protobuf import any_pb2 +from google.protobuf import duration_pb2 +from google.protobuf import empty_pb2 +from google.protobuf import field_mask_pb2 +from google.protobuf import timestamp_pb2 +from google.rpc import status_pb2 + +_shared_modules = [ + iam_policy_pb2, + policy_pb2, + any_pb2, + duration_pb2, + empty_pb2, + field_mask_pb2, + timestamp_pb2, + status_pb2, +] + +_local_modules = [cloudtasks_pb2, queue_pb2, target_pb2, task_pb2] + +names = [] + +for module in _shared_modules: + for name, message in get_messages(module).items(): + setattr(sys.modules[__name__], name, message) + names.append(name) +for module in _local_modules: + for name, message in get_messages(module).items(): + message.__module__ = "google.cloud.tasks_v2.types" + setattr(sys.modules[__name__], name, message) + names.append(name) + +__all__ = tuple(sorted(names)) diff --git a/tasks/synth.metadata b/tasks/synth.metadata index ec2d2d4297e9c..cd3b14637cfb9 100644 --- a/tasks/synth.metadata +++ b/tasks/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-03-01T13:26:46.421824Z", + "updateTime": "2019-03-22T21:25:46.611708Z", "sources": [ { "generator": { "name": "artman", - "version": "0.16.14", - "dockerImage": "googleapis/artman@sha256:f3d61ae45abaeefb6be5f228cda22732c2f1b00fb687c79c4bd4f2c42bb1e1a7" + "version": "0.16.18", + "dockerImage": "googleapis/artman@sha256:e8ac9200640e76d54643f370db71a1556bf254f565ce46b45a467bbcbacbdb37" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "41d72d444fbe445f4da89e13be02078734fb7875", - "internalRef": "236230004" + "sha": "621908b5974b0ea5736fde114b2d5d4bd938e99d", + "internalRef": "239857314" } }, { @@ -44,6 +44,16 @@ "generator": "gapic", "config": "google/cloud/tasks/artman_cloudtasks_v2beta3.yaml" } + }, + { + "client": { + "source": "googleapis", + "apiName": "tasks", + "apiVersion": "v2", + "language": "python", + "generator": "gapic", + "config": "google/cloud/tasks/artman_cloudtasks_v2.yaml" + } } ] } \ No newline at end of file diff --git a/tasks/synth.py b/tasks/synth.py index b61df3478790a..8b20335e0bdea 100644 --- a/tasks/synth.py +++ b/tasks/synth.py @@ -27,7 +27,7 @@ # ---------------------------------------------------------------------------- # Generate tasks GAPIC layer # ---------------------------------------------------------------------------- -for version in ["v2beta2", "v2beta3"]: +for version in ["v2beta2", "v2beta3", "v2"]: library = gapic.py_library( "tasks", version, diff --git a/tasks/tests/unit/gapic/v2/test_cloud_tasks_client_v2.py b/tasks/tests/unit/gapic/v2/test_cloud_tasks_client_v2.py new file mode 100644 index 0000000000000..2dff7fcd54461 --- /dev/null +++ b/tasks/tests/unit/gapic/v2/test_cloud_tasks_client_v2.py @@ -0,0 +1,702 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +"""Unit tests.""" + +import mock +import pytest + +from google.cloud import tasks_v2 +from google.cloud.tasks_v2.proto import cloudtasks_pb2 +from google.cloud.tasks_v2.proto import queue_pb2 +from google.cloud.tasks_v2.proto import task_pb2 +from google.iam.v1 import iam_policy_pb2 +from google.iam.v1 import policy_pb2 +from google.protobuf import empty_pb2 + + +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" + + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub + + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) + + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() + + if isinstance(response, Exception): + raise response + + if response: + return response + + +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" + + def __init__(self, responses=[]): + self.responses = responses + self.requests = [] + + def unary_unary(self, method, request_serializer=None, response_deserializer=None): + return MultiCallableStub(method, self) + + +class CustomException(Exception): + pass + + +class TestCloudTasksClient(object): + def test_list_queues(self): + # Setup Expected Response + next_page_token = "" + queues_element = {} + queues = [queues_element] + expected_response = {"next_page_token": next_page_token, "queues": queues} + expected_response = cloudtasks_pb2.ListQueuesResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + parent = client.location_path("[PROJECT]", "[LOCATION]") + + paged_list_response = client.list_queues(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.queues[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.ListQueuesRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_queues_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + parent = client.location_path("[PROJECT]", "[LOCATION]") + + paged_list_response = client.list_queues(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_queue(self): + # Setup Expected Response + name_2 = "name2-1052831874" + expected_response = {"name": name_2} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + response = client.get_queue(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.GetQueueRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.get_queue(name) + + def test_create_queue(self): + # Setup Expected Response + name = "name3373707" + expected_response = {"name": name} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + parent = client.location_path("[PROJECT]", "[LOCATION]") + queue = {} + + response = client.create_queue(parent, queue) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.CreateQueueRequest(parent=parent, queue=queue) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + parent = client.location_path("[PROJECT]", "[LOCATION]") + queue = {} + + with pytest.raises(CustomException): + client.create_queue(parent, queue) + + def test_update_queue(self): + # Setup Expected Response + name = "name3373707" + expected_response = {"name": name} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + queue = {} + + response = client.update_queue(queue) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.UpdateQueueRequest(queue=queue) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_update_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + queue = {} + + with pytest.raises(CustomException): + client.update_queue(queue) + + def test_delete_queue(self): + channel = ChannelStub() + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + client.delete_queue(name) + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.DeleteQueueRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.delete_queue(name) + + def test_purge_queue(self): + # Setup Expected Response + name_2 = "name2-1052831874" + expected_response = {"name": name_2} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + response = client.purge_queue(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.PurgeQueueRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_purge_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.purge_queue(name) + + def test_pause_queue(self): + # Setup Expected Response + name_2 = "name2-1052831874" + expected_response = {"name": name_2} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + response = client.pause_queue(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.PauseQueueRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_pause_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.pause_queue(name) + + def test_resume_queue(self): + # Setup Expected Response + name_2 = "name2-1052831874" + expected_response = {"name": name_2} + expected_response = queue_pb2.Queue(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + response = client.resume_queue(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.ResumeQueueRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_resume_queue_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.resume_queue(name) + + def test_get_iam_policy(self): + # Setup Expected Response + version = 351608024 + etag = b"21" + expected_response = {"version": version, "etag": etag} + expected_response = policy_pb2.Policy(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + response = client.get_iam_policy(resource) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = iam_policy_pb2.GetIamPolicyRequest(resource=resource) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_iam_policy_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + with pytest.raises(CustomException): + client.get_iam_policy(resource) + + def test_set_iam_policy(self): + # Setup Expected Response + version = 351608024 + etag = b"21" + expected_response = {"version": version, "etag": etag} + expected_response = policy_pb2.Policy(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + policy = {} + + response = client.set_iam_policy(resource, policy) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, policy=policy + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_set_iam_policy_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + policy = {} + + with pytest.raises(CustomException): + client.set_iam_policy(resource, policy) + + def test_test_iam_permissions(self): + # Setup Expected Response + expected_response = {} + expected_response = iam_policy_pb2.TestIamPermissionsResponse( + **expected_response + ) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + permissions = [] + + response = client.test_iam_permissions(resource, permissions) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = iam_policy_pb2.TestIamPermissionsRequest( + resource=resource, permissions=permissions + ) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_test_iam_permissions_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + resource = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + permissions = [] + + with pytest.raises(CustomException): + client.test_iam_permissions(resource, permissions) + + def test_list_tasks(self): + # Setup Expected Response + next_page_token = "" + tasks_element = {} + tasks = [tasks_element] + expected_response = {"next_page_token": next_page_token, "tasks": tasks} + expected_response = cloudtasks_pb2.ListTasksResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + parent = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + paged_list_response = client.list_tasks(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.tasks[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.ListTasksRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_tasks_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + parent = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + + paged_list_response = client.list_tasks(parent) + with pytest.raises(CustomException): + list(paged_list_response) + + def test_get_task(self): + # Setup Expected Response + name_2 = "name2-1052831874" + dispatch_count = 1217252086 + response_count = 424727441 + expected_response = { + "name": name_2, + "dispatch_count": dispatch_count, + "response_count": response_count, + } + expected_response = task_pb2.Task(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + response = client.get_task(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.GetTaskRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_get_task_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + with pytest.raises(CustomException): + client.get_task(name) + + def test_create_task(self): + # Setup Expected Response + name = "name3373707" + dispatch_count = 1217252086 + response_count = 424727441 + expected_response = { + "name": name, + "dispatch_count": dispatch_count, + "response_count": response_count, + } + expected_response = task_pb2.Task(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + parent = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + task = {} + + response = client.create_task(parent, task) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.CreateTaskRequest(parent=parent, task=task) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_create_task_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + parent = client.queue_path("[PROJECT]", "[LOCATION]", "[QUEUE]") + task = {} + + with pytest.raises(CustomException): + client.create_task(parent, task) + + def test_delete_task(self): + channel = ChannelStub() + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + client.delete_task(name) + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.DeleteTaskRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_delete_task_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + with pytest.raises(CustomException): + client.delete_task(name) + + def test_run_task(self): + # Setup Expected Response + name_2 = "name2-1052831874" + dispatch_count = 1217252086 + response_count = 424727441 + expected_response = { + "name": name_2, + "dispatch_count": dispatch_count, + "response_count": response_count, + } + expected_response = task_pb2.Task(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup Request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + response = client.run_task(name) + assert expected_response == response + + assert len(channel.requests) == 1 + expected_request = cloudtasks_pb2.RunTaskRequest(name=name) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_run_task_exception(self): + # Mock the API response + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = tasks_v2.CloudTasksClient() + + # Setup request + name = client.task_path("[PROJECT]", "[LOCATION]", "[QUEUE]", "[TASK]") + + with pytest.raises(CustomException): + client.run_task(name) From 2ea59a97c11c89c625a62a3d17362888e92095e5 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 22 Mar 2019 16:40:39 -0700 Subject: [PATCH 2/4] Update docs --- tasks/docs/index.rst | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/tasks/docs/index.rst b/tasks/docs/index.rst index 138a1b541e191..ef5bdf513e65e 100644 --- a/tasks/docs/index.rst +++ b/tasks/docs/index.rst @@ -8,19 +8,21 @@ API. By default, you will get ``v2beta3``, the latest version. .. toctree:: :maxdepth: 2 + gapic/v2/api + gapic/v2/types - gapic/v2beta3/api - gapic/v2beta3/types -The previous beta release, spelled ``v2beta2``, is provided to continue to -support code previously written against them. In order to use ththem, you -will want to import from e.g. ``google.cloud.tasks_v2beta2`` in lieu of -``google.cloud.tasks`` (or the equivalent ``google.cloud.tasks_v2beta3``). +The previous beta release, spelled ``v2beta3`` and ``v2beta2``, are provided to continue to +support code previously written against them. In order to use them, you +will want to import from e.g. ``google.cloud.tasks_v2beta3`` in lieu of +``google.cloud.tasks`` (or the equivalent ``google.cloud.tasks_v2``). An API and type reference is provided the this beta also: .. toctree:: :maxdepth: 2 + gapic/v2beta3/api + gapic/v2beta3/types gapic/v2beta2/api gapic/v2beta2/types From 7e30c2734f27c5cbe084cc9d82287a901f2ee5a0 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Fri, 22 Mar 2019 16:41:46 -0700 Subject: [PATCH 3/4] Fix index.rst --- tasks/docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/docs/index.rst b/tasks/docs/index.rst index ef5bdf513e65e..4512c8f0407d4 100644 --- a/tasks/docs/index.rst +++ b/tasks/docs/index.rst @@ -12,7 +12,7 @@ API. By default, you will get ``v2beta3``, the latest version. gapic/v2/types -The previous beta release, spelled ``v2beta3`` and ``v2beta2``, are provided to continue to +The previous beta releases, spelled ``v2beta3`` and ``v2beta2``, are provided to continue to support code previously written against them. In order to use them, you will want to import from e.g. ``google.cloud.tasks_v2beta3`` in lieu of ``google.cloud.tasks`` (or the equivalent ``google.cloud.tasks_v2``). From 504fc672f635f024800cbc3fac2b8372f6787452 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim Date: Mon, 25 Mar 2019 13:47:09 -0700 Subject: [PATCH 4/4] Fix docstring. --- tasks/docs/index.rst | 1 + tasks/google/cloud/tasks_v2/proto/queue_pb2.py | 3 +-- tasks/synth.metadata | 10 +++++----- tasks/synth.py | 10 +++++++++- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/tasks/docs/index.rst b/tasks/docs/index.rst index 4512c8f0407d4..4e5bc96990370 100644 --- a/tasks/docs/index.rst +++ b/tasks/docs/index.rst @@ -8,6 +8,7 @@ API. By default, you will get ``v2beta3``, the latest version. .. toctree:: :maxdepth: 2 + gapic/v2/api gapic/v2/types diff --git a/tasks/google/cloud/tasks_v2/proto/queue_pb2.py b/tasks/google/cloud/tasks_v2/proto/queue_pb2.py index 34d36b269cc71..dd2b4caf882f0 100644 --- a/tasks/google/cloud/tasks_v2/proto/queue_pb2.py +++ b/tasks/google/cloud/tasks_v2/proto/queue_pb2.py @@ -674,8 +674,7 @@ If unspecified when the queue is created, Cloud Tasks will pick the default. This field has the same meaning as `max\_doublings in queue.yaml/xml - `__. + pengine/docs/standard/python/config/queueref#retry_parameters>`__. """, # @@protoc_insertion_point(class_scope:google.cloud.tasks.v2.RetryConfig) ), diff --git a/tasks/synth.metadata b/tasks/synth.metadata index cd3b14637cfb9..8bd9b5c90ecf8 100644 --- a/tasks/synth.metadata +++ b/tasks/synth.metadata @@ -1,19 +1,19 @@ { - "updateTime": "2019-03-22T21:25:46.611708Z", + "updateTime": "2019-03-25T20:46:39.567501Z", "sources": [ { "generator": { "name": "artman", - "version": "0.16.18", - "dockerImage": "googleapis/artman@sha256:e8ac9200640e76d54643f370db71a1556bf254f565ce46b45a467bbcbacbdb37" + "version": "0.16.19", + "dockerImage": "googleapis/artman@sha256:70ba28fda87e032ae44e6df41b7fc342c1b0cce1ed90658c4890eb4f613038c2" } }, { "git": { "name": "googleapis", "remote": "https://github.com/googleapis/googleapis.git", - "sha": "621908b5974b0ea5736fde114b2d5d4bd938e99d", - "internalRef": "239857314" + "sha": "e80435a132c53da26f46daf0787035ee63fb942b", + "internalRef": "239938670" } }, { diff --git a/tasks/synth.py b/tasks/synth.py index 8b20335e0bdea..6fe6b1748f87f 100644 --- a/tasks/synth.py +++ b/tasks/synth.py @@ -49,10 +49,18 @@ # Wrapped link fails due to space in link (v2beta2) s.replace( "google/cloud/tasks_v2beta2/proto/queue_pb2.py", - "(uests in queue.yaml/xml) <\n\s+", + "(in queue.yaml/xml) <\n\s+", "\g<1>\n <", ) +# Wrapped link fails due to newline (v2) +s.replace( + "google/cloud/tasks_v2/proto/queue_pb2.py", + """#retry_parameters> + `__\.""", + "#retry_parameters>`__.", +) + # Restore updated example from PR #7025. s.replace( "google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py",