diff --git a/.flake8 b/.flake8 index 29227d4c..2e438749 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7c..757c9dca 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:81ed5ecdfc7cac5b699ba4537376f3563f6f04122c4ec9e735d3b3dc1d43dd32 +# created: 2022-05-05T22:08:23.383410683Z diff --git a/.github/auto-approve.yml b/.github/auto-approve.yml new file mode 100644 index 00000000..311ebbb8 --- /dev/null +++ b/.github/auto-approve.yml @@ -0,0 +1,3 @@ +# https://github.com/googleapis/repo-automation-bots/tree/main/packages/auto-approve +processes: + - "OwlBotTemplateChanges" diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..41bff0b5 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 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. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5..29601ad4 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,11 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8..238b87b9 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index f88a603f..b9252ae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,23 @@ [1]: https://pypi.org/project/google-cloud-tasks/#history +## [2.9.0](https://github.com/googleapis/python-tasks/compare/v2.8.1...v2.9.0) (2022-05-05) + + +### Features + +* AuditConfig for IAM v1 ([7b7a294](https://github.com/googleapis/python-tasks/commit/7b7a2946a8554a06d8fdc57b13c2726c5d8a443b)) + + +### Bug Fixes + +* **deps:** require grpc-google-iam-v1 >=0.12.4 ([7b7a294](https://github.com/googleapis/python-tasks/commit/7b7a2946a8554a06d8fdc57b13c2726c5d8a443b)) + + +### Documentation + +* fix type in docstring for map fields ([7b7a294](https://github.com/googleapis/python-tasks/commit/7b7a2946a8554a06d8fdc57b13c2726c5d8a443b)) + ### [2.8.1](https://github.com/googleapis/python-tasks/compare/v2.8.0...v2.8.1) (2022-03-05) diff --git a/docs/conf.py b/docs/conf.py index 6a310b89..cfed6c1d 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -24,9 +24,9 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys import os import shlex +import sys # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-tasks", "google-cloud-tasks Documentation", [author], 1,) + ( + root_doc, + "google-cloud-tasks", + "google-cloud-tasks Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/tasks/__init__.py b/google/cloud/tasks/__init__.py index 4858a472..e9b8ecc9 100644 --- a/google/cloud/tasks/__init__.py +++ b/google/cloud/tasks/__init__.py @@ -14,38 +14,42 @@ # limitations under the License. # -from google.cloud.tasks_v2.services.cloud_tasks.client import CloudTasksClient from google.cloud.tasks_v2.services.cloud_tasks.async_client import ( CloudTasksAsyncClient, ) - -from google.cloud.tasks_v2.types.cloudtasks import CreateQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import CreateTaskRequest -from google.cloud.tasks_v2.types.cloudtasks import DeleteQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import DeleteTaskRequest -from google.cloud.tasks_v2.types.cloudtasks import GetQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import GetTaskRequest -from google.cloud.tasks_v2.types.cloudtasks import ListQueuesRequest -from google.cloud.tasks_v2.types.cloudtasks import ListQueuesResponse -from google.cloud.tasks_v2.types.cloudtasks import ListTasksRequest -from google.cloud.tasks_v2.types.cloudtasks import ListTasksResponse -from google.cloud.tasks_v2.types.cloudtasks import PauseQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import PurgeQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import ResumeQueueRequest -from google.cloud.tasks_v2.types.cloudtasks import RunTaskRequest -from google.cloud.tasks_v2.types.cloudtasks import UpdateQueueRequest -from google.cloud.tasks_v2.types.queue import Queue -from google.cloud.tasks_v2.types.queue import RateLimits -from google.cloud.tasks_v2.types.queue import RetryConfig -from google.cloud.tasks_v2.types.queue import StackdriverLoggingConfig -from google.cloud.tasks_v2.types.target import AppEngineHttpRequest -from google.cloud.tasks_v2.types.target import AppEngineRouting -from google.cloud.tasks_v2.types.target import HttpRequest -from google.cloud.tasks_v2.types.target import OAuthToken -from google.cloud.tasks_v2.types.target import OidcToken -from google.cloud.tasks_v2.types.target import HttpMethod -from google.cloud.tasks_v2.types.task import Attempt -from google.cloud.tasks_v2.types.task import Task +from google.cloud.tasks_v2.services.cloud_tasks.client import CloudTasksClient +from google.cloud.tasks_v2.types.cloudtasks import ( + CreateQueueRequest, + CreateTaskRequest, + DeleteQueueRequest, + DeleteTaskRequest, + GetQueueRequest, + GetTaskRequest, + ListQueuesRequest, + ListQueuesResponse, + ListTasksRequest, + ListTasksResponse, + PauseQueueRequest, + PurgeQueueRequest, + ResumeQueueRequest, + RunTaskRequest, + UpdateQueueRequest, +) +from google.cloud.tasks_v2.types.queue import ( + Queue, + RateLimits, + RetryConfig, + StackdriverLoggingConfig, +) +from google.cloud.tasks_v2.types.target import ( + AppEngineHttpRequest, + AppEngineRouting, + HttpMethod, + HttpRequest, + OAuthToken, + OidcToken, +) +from google.cloud.tasks_v2.types.task import Attempt, Task __all__ = ( "CloudTasksClient", diff --git a/google/cloud/tasks_v2/__init__.py b/google/cloud/tasks_v2/__init__.py index 4be35c73..f0f89bca 100644 --- a/google/cloud/tasks_v2/__init__.py +++ b/google/cloud/tasks_v2/__init__.py @@ -14,36 +14,34 @@ # limitations under the License. # -from .services.cloud_tasks import CloudTasksClient -from .services.cloud_tasks import CloudTasksAsyncClient - -from .types.cloudtasks import CreateQueueRequest -from .types.cloudtasks import CreateTaskRequest -from .types.cloudtasks import DeleteQueueRequest -from .types.cloudtasks import DeleteTaskRequest -from .types.cloudtasks import GetQueueRequest -from .types.cloudtasks import GetTaskRequest -from .types.cloudtasks import ListQueuesRequest -from .types.cloudtasks import ListQueuesResponse -from .types.cloudtasks import ListTasksRequest -from .types.cloudtasks import ListTasksResponse -from .types.cloudtasks import PauseQueueRequest -from .types.cloudtasks import PurgeQueueRequest -from .types.cloudtasks import ResumeQueueRequest -from .types.cloudtasks import RunTaskRequest -from .types.cloudtasks import UpdateQueueRequest -from .types.queue import Queue -from .types.queue import RateLimits -from .types.queue import RetryConfig -from .types.queue import StackdriverLoggingConfig -from .types.target import AppEngineHttpRequest -from .types.target import AppEngineRouting -from .types.target import HttpRequest -from .types.target import OAuthToken -from .types.target import OidcToken -from .types.target import HttpMethod -from .types.task import Attempt -from .types.task import Task +from .services.cloud_tasks import CloudTasksAsyncClient, CloudTasksClient +from .types.cloudtasks import ( + CreateQueueRequest, + CreateTaskRequest, + DeleteQueueRequest, + DeleteTaskRequest, + GetQueueRequest, + GetTaskRequest, + ListQueuesRequest, + ListQueuesResponse, + ListTasksRequest, + ListTasksResponse, + PauseQueueRequest, + PurgeQueueRequest, + ResumeQueueRequest, + RunTaskRequest, + UpdateQueueRequest, +) +from .types.queue import Queue, RateLimits, RetryConfig, StackdriverLoggingConfig +from .types.target import ( + AppEngineHttpRequest, + AppEngineRouting, + HttpMethod, + HttpRequest, + OAuthToken, + OidcToken, +) +from .types.task import Attempt, Task __all__ = ( "CloudTasksAsyncClient", diff --git a/google/cloud/tasks_v2/services/cloud_tasks/__init__.py b/google/cloud/tasks_v2/services/cloud_tasks/__init__.py index aedb130d..b47f3823 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/__init__.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import CloudTasksClient from .async_client import CloudTasksAsyncClient +from .client import CloudTasksClient __all__ = ( "CloudTasksClient", diff --git a/google/cloud/tasks_v2/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2/services/cloud_tasks/async_client.py index 7fc2d4a9..fe092df2 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/async_client.py @@ -16,21 +16,27 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2.services.cloud_tasks import pagers from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -38,14 +44,10 @@ from google.cloud.tasks_v2.types import target from google.cloud.tasks_v2.types import task from google.cloud.tasks_v2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport + from .client import CloudTasksClient +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport +from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport class CloudTasksAsyncClient: @@ -222,14 +224,13 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2 - def sample_list_queues(): + async def sample_list_queues(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.ListQueuesRequest( @@ -240,7 +241,7 @@ def sample_list_queues(): page_result = client.list_queues(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -311,12 +312,20 @@ def sample_list_queues(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQueuesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -337,9 +346,9 @@ async def get_queue( from google.cloud import tasks_v2 - def sample_get_queue(): + async def sample_get_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.GetQueueRequest( @@ -347,7 +356,7 @@ def sample_get_queue(): ) # Make the request - response = client.get_queue(request=request) + response = await client.get_queue(request=request) # Handle the response print(response) @@ -421,7 +430,12 @@ def sample_get_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -448,14 +462,13 @@ async def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 - def sample_create_queue(): + async def sample_create_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.CreateQueueRequest( @@ -463,7 +476,7 @@ def sample_create_queue(): ) # Make the request - response = client.create_queue(request=request) + response = await client.create_queue(request=request) # Handle the response print(response) @@ -543,7 +556,12 @@ def sample_create_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -573,21 +591,20 @@ async def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 - def sample_update_queue(): + async def sample_update_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.UpdateQueueRequest( ) # Make the request - response = client.update_queue(request=request) + response = await client.update_queue(request=request) # Handle the response print(response) @@ -672,7 +689,12 @@ def sample_update_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -699,14 +721,13 @@ async def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 - def sample_delete_queue(): + async def sample_delete_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.DeleteQueueRequest( @@ -714,7 +735,7 @@ def sample_delete_queue(): ) # Make the request - client.delete_queue(request=request) + await client.delete_queue(request=request) Args: request (Union[google.cloud.tasks_v2.types.DeleteQueueRequest, dict]): @@ -776,7 +797,10 @@ def sample_delete_queue(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def purge_queue( @@ -795,14 +819,13 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2 - def sample_purge_queue(): + async def sample_purge_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.PurgeQueueRequest( @@ -810,7 +833,7 @@ def sample_purge_queue(): ) # Make the request - response = client.purge_queue(request=request) + response = await client.purge_queue(request=request) # Handle the response print(response) @@ -874,7 +897,12 @@ def sample_purge_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -897,14 +925,13 @@ async def pause_queue( paused if its [state][google.cloud.tasks.v2.Queue.state] is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2 - def sample_pause_queue(): + async def sample_pause_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.PauseQueueRequest( @@ -912,7 +939,7 @@ def sample_pause_queue(): ) # Make the request - response = client.pause_queue(request=request) + response = await client.pause_queue(request=request) # Handle the response print(response) @@ -976,7 +1003,12 @@ def sample_pause_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1006,14 +1038,13 @@ async def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2 - def sample_resume_queue(): + async def sample_resume_queue(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.ResumeQueueRequest( @@ -1021,7 +1052,7 @@ def sample_resume_queue(): ) # Make the request - response = client.resume_queue(request=request) + response = await client.resume_queue(request=request) # Handle the response print(response) @@ -1085,7 +1116,12 @@ def sample_resume_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1109,22 +1145,22 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -1150,21 +1186,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1179,17 +1220,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1200,11 +1241,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1222,7 +1264,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1249,7 +1293,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1277,22 +1326,22 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -1318,21 +1367,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1347,17 +1401,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1368,11 +1422,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1390,7 +1445,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1407,7 +1464,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1432,23 +1494,23 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) @@ -1501,7 +1563,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1529,7 +1592,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1554,14 +1622,13 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2 - def sample_list_tasks(): + async def sample_list_tasks(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.ListTasksRequest( @@ -1572,7 +1639,7 @@ def sample_list_tasks(): page_result = client.list_tasks(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1644,12 +1711,20 @@ def sample_list_tasks(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTasksAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1670,9 +1745,9 @@ async def get_task( from google.cloud import tasks_v2 - def sample_get_task(): + async def sample_get_task(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.GetTaskRequest( @@ -1680,7 +1755,7 @@ def sample_get_task(): ) # Make the request - response = client.get_task(request=request) + response = await client.get_task(request=request) # Handle the response print(response) @@ -1749,7 +1824,12 @@ def sample_get_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1771,14 +1851,13 @@ async def create_task( - The maximum task size is 100KB. - .. code-block:: python from google.cloud import tasks_v2 - def sample_create_task(): + async def sample_create_task(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.CreateTaskRequest( @@ -1786,7 +1865,7 @@ def sample_create_task(): ) # Make the request - response = client.create_task(request=request) + response = await client.create_task(request=request) # Handle the response print(response) @@ -1894,7 +1973,12 @@ def sample_create_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1913,14 +1997,13 @@ async def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2 - def sample_delete_task(): + async def sample_delete_task(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.DeleteTaskRequest( @@ -1928,7 +2011,7 @@ def sample_delete_task(): ) # Make the request - client.delete_task(request=request) + await client.delete_task(request=request) Args: request (Union[google.cloud.tasks_v2.types.DeleteTaskRequest, dict]): @@ -1991,7 +2074,10 @@ def sample_delete_task(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def run_task( @@ -2031,14 +2117,13 @@ async def run_task( [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed. - .. code-block:: python from google.cloud import tasks_v2 - def sample_run_task(): + async def sample_run_task(): # Create a client - client = tasks_v2.CloudTasksClient() + client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2.RunTaskRequest( @@ -2046,7 +2131,7 @@ def sample_run_task(): ) # Make the request - response = client.run_task(request=request) + response = await client.run_task(request=request) # Handle the response print(response) @@ -2105,7 +2190,12 @@ def sample_run_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2119,7 +2209,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2/services/cloud_tasks/client.py b/google/cloud/tasks_v2/services/cloud_tasks/client.py index c1196cc2..c95ba3aa 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/client.py @@ -16,24 +16,30 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2.services.cloud_tasks import pagers from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue @@ -41,12 +47,8 @@ from google.cloud.tasks_v2.types import target from google.cloud.tasks_v2.types import task from google.cloud.tasks_v2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc import CloudTasksGrpcTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport @@ -63,7 +65,10 @@ class CloudTasksClientMeta(type): _transport_registry["grpc"] = CloudTasksGrpcTransport _transport_registry["grpc_asyncio"] = CloudTasksGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudTasksTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudTasksTransport]: """Returns an appropriate transport class. Args: @@ -170,10 +175,16 @@ def transport(self) -> CloudTasksTransport: return self._transport @staticmethod - def queue_path(project: str, location: str, queue: str,) -> str: + def queue_path( + project: str, + location: str, + queue: str, + ) -> str: """Returns a fully-qualified queue string.""" return "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) @staticmethod @@ -186,10 +197,18 @@ def parse_queue_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def task_path(project: str, location: str, queue: str, task: str,) -> str: + def task_path( + project: str, + location: str, + queue: str, + task: str, + ) -> str: """Returns a fully-qualified task string.""" return "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + project=project, + location=location, + queue=queue, + task=task, ) @staticmethod @@ -202,7 +221,9 @@ def parse_task_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -215,9 +236,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -226,9 +251,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -237,9 +266,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -248,10 +281,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -437,7 +474,6 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2 @@ -516,12 +552,20 @@ def sample_list_queues(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQueuesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -616,7 +660,12 @@ def sample_get_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -643,7 +692,6 @@ def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 @@ -738,7 +786,12 @@ def sample_create_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -768,7 +821,6 @@ def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 @@ -867,7 +919,12 @@ def sample_update_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -894,7 +951,6 @@ def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2 @@ -961,7 +1017,10 @@ def sample_delete_queue(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def purge_queue( @@ -980,7 +1039,6 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2 @@ -1059,7 +1117,12 @@ def sample_purge_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1082,7 +1145,6 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2.Queue.state] is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2 @@ -1161,7 +1223,12 @@ def sample_pause_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1191,7 +1258,6 @@ def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2 @@ -1270,7 +1336,12 @@ def sample_resume_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1294,17 +1365,17 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1335,21 +1406,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1364,17 +1440,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1385,11 +1461,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1423,7 +1500,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1451,17 +1533,17 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1492,21 +1574,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1521,17 +1608,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1542,11 +1629,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1580,7 +1668,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1605,17 +1698,17 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -1691,7 +1784,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1716,7 +1814,6 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2 @@ -1796,12 +1893,20 @@ def sample_list_tasks(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTasksPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1891,7 +1996,12 @@ def sample_get_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1913,7 +2023,6 @@ def create_task( - The maximum task size is 100KB. - .. code-block:: python from google.cloud import tasks_v2 @@ -2036,7 +2145,12 @@ def sample_create_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2055,7 +2169,6 @@ def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2 @@ -2123,7 +2236,10 @@ def sample_delete_task(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def run_task( @@ -2163,7 +2279,6 @@ def run_task( [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed. - .. code-block:: python from google.cloud import tasks_v2 @@ -2237,7 +2352,12 @@ def sample_run_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2258,7 +2378,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2/services/cloud_tasks/pagers.py b/google/cloud/tasks_v2/services/cloud_tasks/pagers.py index 1dd9d10d..9e59171a 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/pagers.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/pagers.py @@ -18,15 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.tasks_v2.types import cloudtasks -from google.cloud.tasks_v2.types import queue -from google.cloud.tasks_v2.types import task +from google.cloud.tasks_v2.types import cloudtasks, queue, task class ListQueuesPager: diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/__init__.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/__init__.py index ec04b44d..dd95e460 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/__init__.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import CloudTasksGrpcTransport from .grpc_asyncio import CloudTasksGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[CloudTasksTransport]] _transport_registry["grpc"] = CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py index 796513f3..da4aa8f8 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/base.py @@ -15,28 +15,30 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +from google.protobuf import empty_pb2 # type: ignore +import pkg_resources from google.cloud.tasks_v2.types import cloudtasks from google.cloud.tasks_v2.types import queue from google.cloud.tasks_v2.types import queue as gct_queue from google.cloud.tasks_v2.types import task from google.cloud.tasks_v2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -85,6 +87,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -156,10 +159,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_queue: gapic_v1.method.wrap_method( - self.create_queue, default_timeout=10.0, client_info=client_info, + self.create_queue, + default_timeout=10.0, + client_info=client_info, ), self.update_queue: gapic_v1.method.wrap_method( - self.update_queue, default_timeout=10.0, client_info=client_info, + self.update_queue, + default_timeout=10.0, + client_info=client_info, ), self.delete_queue: gapic_v1.method.wrap_method( self.delete_queue, @@ -177,13 +184,19 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.purge_queue: gapic_v1.method.wrap_method( - self.purge_queue, default_timeout=10.0, client_info=client_info, + self.purge_queue, + default_timeout=10.0, + client_info=client_info, ), self.pause_queue: gapic_v1.method.wrap_method( - self.pause_queue, default_timeout=10.0, client_info=client_info, + self.pause_queue, + default_timeout=10.0, + client_info=client_info, ), self.resume_queue: gapic_v1.method.wrap_method( - self.resume_queue, default_timeout=10.0, client_info=client_info, + self.resume_queue, + default_timeout=10.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -201,7 +214,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=10.0, client_info=client_info, + self.set_iam_policy, + default_timeout=10.0, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, @@ -249,7 +264,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_task: gapic_v1.method.wrap_method( - self.create_task, default_timeout=10.0, client_info=client_info, + self.create_task, + default_timeout=10.0, + client_info=client_info, ), self.delete_task: gapic_v1.method.wrap_method( self.delete_task, @@ -267,16 +284,18 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.run_task: gapic_v1.method.wrap_method( - self.run_task, default_timeout=10.0, client_info=client_info, + self.run_task, + default_timeout=10.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -416,5 +435,9 @@ def run_task( ) -> Callable[[cloudtasks.RunTaskRequest], Union[task.Task, Awaitable[task.Task]]]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("CloudTasksTransport",) diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py index 211d2ef0..1405298b 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py @@ -13,15 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from google.cloud.tasks_v2.types import cloudtasks @@ -29,10 +30,8 @@ from google.cloud.tasks_v2.types import queue as gct_queue from google.cloud.tasks_v2.types import task from google.cloud.tasks_v2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport class CloudTasksGrpcTransport(CloudTasksTransport): @@ -232,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -774,5 +772,9 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("CloudTasksGrpcTransport",) diff --git a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py index a90e0e87..4101e3e8 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc_asyncio.py @@ -13,14 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -29,10 +30,8 @@ from google.cloud.tasks_v2.types import queue as gct_queue from google.cloud.tasks_v2.types import task from google.cloud.tasks_v2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2/types/__init__.py b/google/cloud/tasks_v2/types/__init__.py index 5cd79655..d35c84ef 100644 --- a/google/cloud/tasks_v2/types/__init__.py +++ b/google/cloud/tasks_v2/types/__init__.py @@ -30,24 +30,16 @@ RunTaskRequest, UpdateQueueRequest, ) -from .queue import ( - Queue, - RateLimits, - RetryConfig, - StackdriverLoggingConfig, -) +from .queue import Queue, RateLimits, RetryConfig, StackdriverLoggingConfig from .target import ( AppEngineHttpRequest, AppEngineRouting, + HttpMethod, HttpRequest, OAuthToken, OidcToken, - HttpMethod, -) -from .task import ( - Attempt, - Task, ) +from .task import Attempt, Task __all__ = ( "CreateQueueRequest", diff --git a/google/cloud/tasks_v2/types/cloudtasks.py b/google/cloud/tasks_v2/types/cloudtasks.py index de7059f4..f4cf7e0a 100644 --- a/google/cloud/tasks_v2/types/cloudtasks.py +++ b/google/cloud/tasks_v2/types/cloudtasks.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore from google.cloud.tasks_v2.types import queue as gct_queue from google.cloud.tasks_v2.types import task as gct_task -from google.protobuf import field_mask_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.tasks.v2", @@ -84,10 +83,22 @@ class ListQueuesRequest(proto.Message): while iterating through pages. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListQueuesResponse(proto.Message): @@ -114,8 +125,15 @@ class ListQueuesResponse(proto.Message): def raw_page(self): return self - queues = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_queue.Queue,) - next_page_token = proto.Field(proto.STRING, number=2,) + queues = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetQueueRequest(proto.Message): @@ -128,7 +146,10 @@ class GetQueueRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class CreateQueueRequest(proto.Message): @@ -151,8 +172,15 @@ class CreateQueueRequest(proto.Message): the same as an existing queue. """ - parent = proto.Field(proto.STRING, number=1,) - queue = proto.Field(proto.MESSAGE, number=2, message=gct_queue.Queue,) + parent = proto.Field( + proto.STRING, + number=1, + ) + queue = proto.Field( + proto.MESSAGE, + number=2, + message=gct_queue.Queue, + ) class UpdateQueueRequest(proto.Message): @@ -176,9 +204,15 @@ class UpdateQueueRequest(proto.Message): If empty, then all fields will be updated. """ - queue = proto.Field(proto.MESSAGE, number=1, message=gct_queue.Queue,) + queue = proto.Field( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -192,7 +226,10 @@ class DeleteQueueRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PurgeQueueRequest(proto.Message): @@ -205,7 +242,10 @@ class PurgeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PauseQueueRequest(proto.Message): @@ -218,7 +258,10 @@ class PauseQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ResumeQueueRequest(proto.Message): @@ -231,7 +274,10 @@ class ResumeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListTasksRequest(proto.Message): @@ -282,10 +328,23 @@ class ListTasksRequest(proto.Message): The page token is valid for only 2 hours. """ - parent = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListTasksResponse(proto.Message): @@ -310,8 +369,15 @@ class ListTasksResponse(proto.Message): def raw_page(self): return self - tasks = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_task.Task,) - next_page_token = proto.Field(proto.STRING, number=2,) + tasks = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_task.Task, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetTaskRequest(proto.Message): @@ -340,8 +406,15 @@ class GetTaskRequest(proto.Message): [Task][google.cloud.tasks.v2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) class CreateTaskRequest(proto.Message): @@ -412,9 +485,20 @@ class CreateTaskRequest(proto.Message): [Task][google.cloud.tasks.v2.Task] resource. """ - parent = proto.Field(proto.STRING, number=1,) - task = proto.Field(proto.MESSAGE, number=2, message=gct_task.Task,) - response_view = proto.Field(proto.ENUM, number=3, enum=gct_task.Task.View,) + parent = proto.Field( + proto.STRING, + number=1, + ) + task = proto.Field( + proto.MESSAGE, + number=2, + message=gct_task.Task, + ) + response_view = proto.Field( + proto.ENUM, + number=3, + enum=gct_task.Task.View, + ) class DeleteTaskRequest(proto.Message): @@ -427,7 +511,10 @@ class DeleteTaskRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class RunTaskRequest(proto.Message): @@ -456,8 +543,15 @@ class RunTaskRequest(proto.Message): [Task][google.cloud.tasks.v2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2/types/queue.py b/google/cloud/tasks_v2/types/queue.py index f9ca584c..89a6d123 100644 --- a/google/cloud/tasks_v2/types/queue.py +++ b/google/cloud/tasks_v2/types/queue.py @@ -13,16 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2.types import target from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2.types import target __protobuf__ = proto.module( package="google.cloud.tasks.v2", - manifest={"Queue", "RateLimits", "RetryConfig", "StackdriverLoggingConfig",}, + manifest={ + "Queue", + "RateLimits", + "RetryConfig", + "StackdriverLoggingConfig", + }, ) @@ -149,16 +153,39 @@ class State(proto.Enum): PAUSED = 2 DISABLED = 3 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_routing_override = proto.Field( - proto.MESSAGE, number=2, message=target.AppEngineRouting, + proto.MESSAGE, + number=2, + message=target.AppEngineRouting, + ) + rate_limits = proto.Field( + proto.MESSAGE, + number=3, + message="RateLimits", + ) + retry_config = proto.Field( + proto.MESSAGE, + number=4, + message="RetryConfig", + ) + state = proto.Field( + proto.ENUM, + number=5, + enum=State, + ) + purge_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, ) - rate_limits = proto.Field(proto.MESSAGE, number=3, message="RateLimits",) - retry_config = proto.Field(proto.MESSAGE, number=4, message="RetryConfig",) - state = proto.Field(proto.ENUM, number=5, enum=State,) - purge_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) stackdriver_logging_config = proto.Field( - proto.MESSAGE, number=9, message="StackdriverLoggingConfig", + proto.MESSAGE, + number=9, + message="StackdriverLoggingConfig", ) @@ -238,9 +265,18 @@ class RateLimits(proto.Message): queue.yaml/xml `__. """ - max_dispatches_per_second = proto.Field(proto.DOUBLE, number=1,) - max_burst_size = proto.Field(proto.INT32, number=2,) - max_concurrent_dispatches = proto.Field(proto.INT32, number=3,) + max_dispatches_per_second = proto.Field( + proto.DOUBLE, + number=1, + ) + max_burst_size = proto.Field( + proto.INT32, + number=2, + ) + max_concurrent_dispatches = proto.Field( + proto.INT32, + number=3, + ) class RetryConfig(proto.Message): @@ -351,13 +387,29 @@ class RetryConfig(proto.Message): queue.yaml/xml `__. """ - max_attempts = proto.Field(proto.INT32, number=1,) + max_attempts = proto.Field( + proto.INT32, + number=1, + ) max_retry_duration = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + min_backoff = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + max_backoff = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + max_doublings = proto.Field( + proto.INT32, + number=5, ) - min_backoff = proto.Field(proto.MESSAGE, number=3, message=duration_pb2.Duration,) - max_backoff = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) - max_doublings = proto.Field(proto.INT32, number=5,) class StackdriverLoggingConfig(proto.Message): @@ -373,7 +425,10 @@ class StackdriverLoggingConfig(proto.Message): 0.0 is the default and means that no operations are logged. """ - sampling_ratio = proto.Field(proto.DOUBLE, number=1,) + sampling_ratio = proto.Field( + proto.DOUBLE, + number=1, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2/types/target.py b/google/cloud/tasks_v2/types/target.py index d95381aa..129615dc 100644 --- a/google/cloud/tasks_v2/types/target.py +++ b/google/cloud/tasks_v2/types/target.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.tasks.v2", manifest={ @@ -101,7 +100,7 @@ class HttpRequest(proto.Message): http_method (google.cloud.tasks_v2.types.HttpMethod): The HTTP method to use for the request. The default is POST. - headers (Sequence[google.cloud.tasks_v2.types.HttpRequest.HeadersEntry]): + headers (Mapping[str, str]): HTTP request headers. This map contains the header field names and values. Headers @@ -165,15 +164,35 @@ class HttpRequest(proto.Message): This field is a member of `oneof`_ ``authorization_header``. """ - url = proto.Field(proto.STRING, number=1,) - http_method = proto.Field(proto.ENUM, number=2, enum="HttpMethod",) - headers = proto.MapField(proto.STRING, proto.STRING, number=3,) - body = proto.Field(proto.BYTES, number=4,) + url = proto.Field( + proto.STRING, + number=1, + ) + http_method = proto.Field( + proto.ENUM, + number=2, + enum="HttpMethod", + ) + headers = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + body = proto.Field( + proto.BYTES, + number=4, + ) oauth_token = proto.Field( - proto.MESSAGE, number=5, oneof="authorization_header", message="OAuthToken", + proto.MESSAGE, + number=5, + oneof="authorization_header", + message="OAuthToken", ) oidc_token = proto.Field( - proto.MESSAGE, number=6, oneof="authorization_header", message="OidcToken", + proto.MESSAGE, + number=6, + oneof="authorization_header", + message="OidcToken", ) @@ -269,7 +288,7 @@ class AppEngineHttpRequest(proto.Message): is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters. - headers (Sequence[google.cloud.tasks_v2.types.AppEngineHttpRequest.HeadersEntry]): + headers (Mapping[str, str]): HTTP request headers. This map contains the header field names and values. Headers @@ -328,13 +347,29 @@ class AppEngineHttpRequest(proto.Message): incompatible [HttpMethod][google.cloud.tasks.v2.HttpMethod]. """ - http_method = proto.Field(proto.ENUM, number=1, enum="HttpMethod",) + http_method = proto.Field( + proto.ENUM, + number=1, + enum="HttpMethod", + ) app_engine_routing = proto.Field( - proto.MESSAGE, number=2, message="AppEngineRouting", + proto.MESSAGE, + number=2, + message="AppEngineRouting", + ) + relative_uri = proto.Field( + proto.STRING, + number=3, + ) + headers = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + body = proto.Field( + proto.BYTES, + number=5, ) - relative_uri = proto.Field(proto.STRING, number=3,) - headers = proto.MapField(proto.STRING, proto.STRING, number=4,) - body = proto.Field(proto.BYTES, number=5,) class AppEngineRouting(proto.Message): @@ -440,10 +475,22 @@ class AppEngineRouting(proto.Message): Routed `__. """ - service = proto.Field(proto.STRING, number=1,) - version = proto.Field(proto.STRING, number=2,) - instance = proto.Field(proto.STRING, number=3,) - host = proto.Field(proto.STRING, number=4,) + service = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + instance = proto.Field( + proto.STRING, + number=3, + ) + host = proto.Field( + proto.STRING, + number=4, + ) class OAuthToken(proto.Message): @@ -467,8 +514,14 @@ class OAuthToken(proto.Message): will be used. """ - service_account_email = proto.Field(proto.STRING, number=1,) - scope = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field( + proto.STRING, + number=1, + ) + scope = proto.Field( + proto.STRING, + number=2, + ) class OidcToken(proto.Message): @@ -492,8 +545,14 @@ class OidcToken(proto.Message): target will be used. """ - service_account_email = proto.Field(proto.STRING, number=1,) - audience = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field( + proto.STRING, + number=1, + ) + audience = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2/types/task.py b/google/cloud/tasks_v2/types/task.py index b744c452..09dabb7c 100644 --- a/google/cloud/tasks_v2/types/task.py +++ b/google/cloud/tasks_v2/types/task.py @@ -13,16 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2.types import target from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2.types import target __protobuf__ = proto.module( - package="google.cloud.tasks.v2", manifest={"Task", "Attempt",}, + package="google.cloud.tasks.v2", + manifest={ + "Task", + "Attempt", + }, ) @@ -163,7 +166,10 @@ class View(proto.Enum): BASIC = 1 FULL = 2 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_http_request = proto.Field( proto.MESSAGE, number=2, @@ -171,20 +177,49 @@ class View(proto.Enum): message=target.AppEngineHttpRequest, ) http_request = proto.Field( - proto.MESSAGE, number=3, oneof="message_type", message=target.HttpRequest, + proto.MESSAGE, + number=3, + oneof="message_type", + message=target.HttpRequest, ) schedule_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, ) - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) dispatch_deadline = proto.Field( - proto.MESSAGE, number=6, message=duration_pb2.Duration, + proto.MESSAGE, + number=6, + message=duration_pb2.Duration, + ) + dispatch_count = proto.Field( + proto.INT32, + number=7, + ) + response_count = proto.Field( + proto.INT32, + number=8, + ) + first_attempt = proto.Field( + proto.MESSAGE, + number=9, + message="Attempt", + ) + last_attempt = proto.Field( + proto.MESSAGE, + number=10, + message="Attempt", + ) + view = proto.Field( + proto.ENUM, + number=11, + enum=View, ) - dispatch_count = proto.Field(proto.INT32, number=7,) - response_count = proto.Field(proto.INT32, number=8,) - first_attempt = proto.Field(proto.MESSAGE, number=9, message="Attempt",) - last_attempt = proto.Field(proto.MESSAGE, number=10, message="Attempt",) - view = proto.Field(proto.ENUM, number=11, enum=View,) class Attempt(proto.Message): @@ -216,15 +251,25 @@ class Attempt(proto.Message): """ schedule_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) dispatch_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) response_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + response_status = proto.Field( + proto.MESSAGE, + number=4, + message=status_pb2.Status, ) - response_status = proto.Field(proto.MESSAGE, number=4, message=status_pb2.Status,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta2/__init__.py b/google/cloud/tasks_v2beta2/__init__.py index c44fd1a6..6ad082cb 100644 --- a/google/cloud/tasks_v2beta2/__init__.py +++ b/google/cloud/tasks_v2beta2/__init__.py @@ -14,42 +14,39 @@ # limitations under the License. # -from .services.cloud_tasks import CloudTasksClient -from .services.cloud_tasks import CloudTasksAsyncClient - -from .types.cloudtasks import AcknowledgeTaskRequest -from .types.cloudtasks import CancelLeaseRequest -from .types.cloudtasks import CreateQueueRequest -from .types.cloudtasks import CreateTaskRequest -from .types.cloudtasks import DeleteQueueRequest -from .types.cloudtasks import DeleteTaskRequest -from .types.cloudtasks import GetQueueRequest -from .types.cloudtasks import GetTaskRequest -from .types.cloudtasks import LeaseTasksRequest -from .types.cloudtasks import LeaseTasksResponse -from .types.cloudtasks import ListQueuesRequest -from .types.cloudtasks import ListQueuesResponse -from .types.cloudtasks import ListTasksRequest -from .types.cloudtasks import ListTasksResponse -from .types.cloudtasks import PauseQueueRequest -from .types.cloudtasks import PurgeQueueRequest -from .types.cloudtasks import RenewLeaseRequest -from .types.cloudtasks import ResumeQueueRequest -from .types.cloudtasks import RunTaskRequest -from .types.cloudtasks import UpdateQueueRequest -from .types.queue import Queue -from .types.queue import QueueStats -from .types.queue import RateLimits -from .types.queue import RetryConfig -from .types.target import AppEngineHttpRequest -from .types.target import AppEngineHttpTarget -from .types.target import AppEngineRouting -from .types.target import PullMessage -from .types.target import PullTarget -from .types.target import HttpMethod -from .types.task import AttemptStatus -from .types.task import Task -from .types.task import TaskStatus +from .services.cloud_tasks import CloudTasksAsyncClient, CloudTasksClient +from .types.cloudtasks import ( + AcknowledgeTaskRequest, + CancelLeaseRequest, + CreateQueueRequest, + CreateTaskRequest, + DeleteQueueRequest, + DeleteTaskRequest, + GetQueueRequest, + GetTaskRequest, + LeaseTasksRequest, + LeaseTasksResponse, + ListQueuesRequest, + ListQueuesResponse, + ListTasksRequest, + ListTasksResponse, + PauseQueueRequest, + PurgeQueueRequest, + RenewLeaseRequest, + ResumeQueueRequest, + RunTaskRequest, + UpdateQueueRequest, +) +from .types.queue import Queue, QueueStats, RateLimits, RetryConfig +from .types.target import ( + AppEngineHttpRequest, + AppEngineHttpTarget, + AppEngineRouting, + HttpMethod, + PullMessage, + PullTarget, +) +from .types.task import AttemptStatus, Task, TaskStatus __all__ = ( "CloudTasksAsyncClient", diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/__init__.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/__init__.py index aedb130d..b47f3823 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/__init__.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import CloudTasksClient from .async_client import CloudTasksAsyncClient +from .client import CloudTasksClient __all__ = ( "CloudTasksClient", diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py index 97e616af..a5bf6571 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py @@ -16,21 +16,27 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -38,14 +44,10 @@ from google.cloud.tasks_v2beta2.types import target from google.cloud.tasks_v2beta2.types import task from google.cloud.tasks_v2beta2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport + from .client import CloudTasksClient +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport +from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport class CloudTasksAsyncClient: @@ -222,14 +224,13 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_list_queues(): + async def sample_list_queues(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ListQueuesRequest( @@ -240,7 +241,7 @@ def sample_list_queues(): page_result = client.list_queues(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -311,12 +312,20 @@ def sample_list_queues(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQueuesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -337,9 +346,9 @@ async def get_queue( from google.cloud import tasks_v2beta2 - def sample_get_queue(): + async def sample_get_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.GetQueueRequest( @@ -347,7 +356,7 @@ def sample_get_queue(): ) # Make the request - response = client.get_queue(request=request) + response = await client.get_queue(request=request) # Handle the response print(response) @@ -421,7 +430,12 @@ def sample_get_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -448,14 +462,13 @@ async def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_create_queue(): + async def sample_create_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CreateQueueRequest( @@ -463,7 +476,7 @@ def sample_create_queue(): ) # Make the request - response = client.create_queue(request=request) + response = await client.create_queue(request=request) # Handle the response print(response) @@ -543,7 +556,12 @@ def sample_create_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -573,21 +591,20 @@ async def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_update_queue(): + async def sample_update_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.UpdateQueueRequest( ) # Make the request - response = client.update_queue(request=request) + response = await client.update_queue(request=request) # Handle the response print(response) @@ -673,7 +690,12 @@ def sample_update_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -700,14 +722,13 @@ async def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_delete_queue(): + async def sample_delete_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteQueueRequest( @@ -715,7 +736,7 @@ def sample_delete_queue(): ) # Make the request - client.delete_queue(request=request) + await client.delete_queue(request=request) Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]): @@ -777,7 +798,10 @@ def sample_delete_queue(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def purge_queue( @@ -796,14 +820,13 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_purge_queue(): + async def sample_purge_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.PurgeQueueRequest( @@ -811,7 +834,7 @@ def sample_purge_queue(): ) # Make the request - response = client.purge_queue(request=request) + response = await client.purge_queue(request=request) # Handle the response print(response) @@ -875,7 +898,12 @@ def sample_purge_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -898,14 +926,13 @@ async def pause_queue( paused if its [state][google.cloud.tasks.v2beta2.Queue.state] is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_pause_queue(): + async def sample_pause_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.PauseQueueRequest( @@ -913,7 +940,7 @@ def sample_pause_queue(): ) # Make the request - response = client.pause_queue(request=request) + response = await client.pause_queue(request=request) # Handle the response print(response) @@ -977,7 +1004,12 @@ def sample_pause_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1007,14 +1039,13 @@ async def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_resume_queue(): + async def sample_resume_queue(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ResumeQueueRequest( @@ -1022,7 +1053,7 @@ def sample_resume_queue(): ) # Make the request - response = client.resume_queue(request=request) + response = await client.resume_queue(request=request) # Handle the response print(response) @@ -1086,7 +1117,12 @@ def sample_resume_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1110,22 +1146,22 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -1151,21 +1187,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1180,17 +1221,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1201,11 +1242,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1223,7 +1265,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1250,7 +1294,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1278,22 +1327,22 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -1319,21 +1368,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1348,17 +1402,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1369,11 +1423,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1391,7 +1446,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1408,7 +1465,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1433,23 +1495,23 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) @@ -1502,7 +1564,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1530,7 +1593,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1555,14 +1623,13 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_list_tasks(): + async def sample_list_tasks(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.ListTasksRequest( @@ -1573,7 +1640,7 @@ def sample_list_tasks(): page_result = client.list_tasks(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1645,12 +1712,20 @@ def sample_list_tasks(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTasksAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1671,9 +1746,9 @@ async def get_task( from google.cloud import tasks_v2beta2 - def sample_get_task(): + async def sample_get_task(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.GetTaskRequest( @@ -1681,7 +1756,7 @@ def sample_get_task(): ) # Make the request - response = client.get_task(request=request) + response = await client.get_task(request=request) # Handle the response print(response) @@ -1750,7 +1825,12 @@ def sample_get_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1776,14 +1856,13 @@ async def create_task( - For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_create_task(): + async def sample_create_task(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CreateTaskRequest( @@ -1791,7 +1870,7 @@ def sample_create_task(): ) # Make the request - response = client.create_task(request=request) + response = await client.create_task(request=request) # Handle the response print(response) @@ -1899,7 +1978,12 @@ def sample_create_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1918,14 +2002,13 @@ async def delete_task( A task cannot be deleted if it has completed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_delete_task(): + async def sample_delete_task(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.DeleteTaskRequest( @@ -1933,7 +2016,7 @@ def sample_delete_task(): ) # Make the request - client.delete_task(request=request) + await client.delete_task(request=request) Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]): @@ -1996,7 +2079,10 @@ def sample_delete_task(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def lease_tasks( @@ -2034,14 +2120,13 @@ async def lease_tasks( [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_lease_tasks(): + async def sample_lease_tasks(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.LeaseTasksRequest( @@ -2049,7 +2134,7 @@ def sample_lease_tasks(): ) # Make the request - response = client.lease_tasks(request=request) + response = await client.lease_tasks(request=request) # Handle the response print(response) @@ -2142,7 +2227,12 @@ def sample_lease_tasks(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2173,14 +2263,13 @@ async def acknowledge_task( [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_acknowledge_task(): + async def sample_acknowledge_task(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.AcknowledgeTaskRequest( @@ -2188,7 +2277,7 @@ def sample_acknowledge_task(): ) # Make the request - client.acknowledge_task(request=request) + await client.acknowledge_task(request=request) Args: request (Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]): @@ -2257,7 +2346,10 @@ def sample_acknowledge_task(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def renew_lease( @@ -2278,14 +2370,13 @@ async def renew_lease( in the task's [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_renew_lease(): + async def sample_renew_lease(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.RenewLeaseRequest( @@ -2293,7 +2384,7 @@ def sample_renew_lease(): ) # Make the request - response = client.renew_lease(request=request) + response = await client.renew_lease(request=request) # Handle the response print(response) @@ -2380,7 +2471,12 @@ def sample_renew_lease(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2404,14 +2500,13 @@ async def cancel_lease( next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_cancel_lease(): + async def sample_cancel_lease(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.CancelLeaseRequest( @@ -2419,7 +2514,7 @@ def sample_cancel_lease(): ) # Make the request - response = client.cancel_lease(request=request) + response = await client.cancel_lease(request=request) # Handle the response print(response) @@ -2494,7 +2589,12 @@ def sample_cancel_lease(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2542,14 +2642,13 @@ async def run_task( be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage]. - .. code-block:: python from google.cloud import tasks_v2beta2 - def sample_run_task(): + async def sample_run_task(): # Create a client - client = tasks_v2beta2.CloudTasksClient() + client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta2.RunTaskRequest( @@ -2557,7 +2656,7 @@ def sample_run_task(): ) # Make the request - response = client.run_task(request=request) + response = await client.run_task(request=request) # Handle the response print(response) @@ -2616,7 +2715,12 @@ def sample_run_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2630,7 +2734,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py index 1f94e6a4..5bfe815a 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py @@ -16,24 +16,30 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue @@ -41,12 +47,8 @@ from google.cloud.tasks_v2beta2.types import target from google.cloud.tasks_v2beta2.types import task from google.cloud.tasks_v2beta2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc import CloudTasksGrpcTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport @@ -63,7 +65,10 @@ class CloudTasksClientMeta(type): _transport_registry["grpc"] = CloudTasksGrpcTransport _transport_registry["grpc_asyncio"] = CloudTasksGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudTasksTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudTasksTransport]: """Returns an appropriate transport class. Args: @@ -170,10 +175,16 @@ def transport(self) -> CloudTasksTransport: return self._transport @staticmethod - def queue_path(project: str, location: str, queue: str,) -> str: + def queue_path( + project: str, + location: str, + queue: str, + ) -> str: """Returns a fully-qualified queue string.""" return "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) @staticmethod @@ -186,10 +197,18 @@ def parse_queue_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def task_path(project: str, location: str, queue: str, task: str,) -> str: + def task_path( + project: str, + location: str, + queue: str, + task: str, + ) -> str: """Returns a fully-qualified task string.""" return "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + project=project, + location=location, + queue=queue, + task=task, ) @staticmethod @@ -202,7 +221,9 @@ def parse_task_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -215,9 +236,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -226,9 +251,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -237,9 +266,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -248,10 +281,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -437,7 +474,6 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -516,12 +552,20 @@ def sample_list_queues(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQueuesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -616,7 +660,12 @@ def sample_get_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -643,7 +692,6 @@ def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -738,7 +786,12 @@ def sample_create_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -768,7 +821,6 @@ def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -868,7 +920,12 @@ def sample_update_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -895,7 +952,6 @@ def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -962,7 +1018,10 @@ def sample_delete_queue(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def purge_queue( @@ -981,7 +1040,6 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -1060,7 +1118,12 @@ def sample_purge_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1083,7 +1146,6 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2beta2.Queue.state] is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -1162,7 +1224,12 @@ def sample_pause_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1192,7 +1259,6 @@ def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -1271,7 +1337,12 @@ def sample_resume_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1295,17 +1366,17 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1336,21 +1407,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1365,17 +1441,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1386,11 +1462,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1424,7 +1501,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1452,17 +1534,17 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1493,21 +1575,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1522,17 +1609,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1543,11 +1630,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1581,7 +1669,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1606,17 +1699,17 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2beta2 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -1692,7 +1785,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1717,7 +1815,6 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -1797,12 +1894,20 @@ def sample_list_tasks(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTasksPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1892,7 +1997,12 @@ def sample_get_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1918,7 +2028,6 @@ def create_task( - For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2041,7 +2150,12 @@ def sample_create_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2060,7 +2174,6 @@ def delete_task( A task cannot be deleted if it has completed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2128,7 +2241,10 @@ def sample_delete_task(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def lease_tasks( @@ -2166,7 +2282,6 @@ def lease_tasks( [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2274,7 +2389,12 @@ def sample_lease_tasks(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2305,7 +2425,6 @@ def acknowledge_task( [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2389,7 +2508,10 @@ def sample_acknowledge_task(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def renew_lease( @@ -2410,7 +2532,6 @@ def renew_lease( in the task's [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2512,7 +2633,12 @@ def sample_renew_lease(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2536,7 +2662,6 @@ def cancel_lease( next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2626,7 +2751,12 @@ def sample_cancel_lease(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2674,7 +2804,6 @@ def run_task( be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage]. - .. code-block:: python from google.cloud import tasks_v2beta2 @@ -2748,7 +2877,12 @@ def sample_run_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2769,7 +2903,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py index 54228367..77ea57fc 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/pagers.py @@ -18,15 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.tasks_v2beta2.types import cloudtasks -from google.cloud.tasks_v2beta2.types import queue -from google.cloud.tasks_v2beta2.types import task +from google.cloud.tasks_v2beta2.types import cloudtasks, queue, task class ListQueuesPager: diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/__init__.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/__init__.py index ec04b44d..dd95e460 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/__init__.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import CloudTasksGrpcTransport from .grpc_asyncio import CloudTasksGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[CloudTasksTransport]] _transport_registry["grpc"] = CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py index 4d608810..15df103e 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/base.py @@ -15,28 +15,30 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +from google.protobuf import empty_pb2 # type: ignore +import pkg_resources from google.cloud.tasks_v2beta2.types import cloudtasks from google.cloud.tasks_v2beta2.types import queue from google.cloud.tasks_v2beta2.types import queue as gct_queue from google.cloud.tasks_v2beta2.types import task from google.cloud.tasks_v2beta2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -85,6 +87,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -156,10 +159,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_queue: gapic_v1.method.wrap_method( - self.create_queue, default_timeout=20.0, client_info=client_info, + self.create_queue, + default_timeout=20.0, + client_info=client_info, ), self.update_queue: gapic_v1.method.wrap_method( - self.update_queue, default_timeout=20.0, client_info=client_info, + self.update_queue, + default_timeout=20.0, + client_info=client_info, ), self.delete_queue: gapic_v1.method.wrap_method( self.delete_queue, @@ -177,13 +184,19 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.purge_queue: gapic_v1.method.wrap_method( - self.purge_queue, default_timeout=20.0, client_info=client_info, + self.purge_queue, + default_timeout=20.0, + client_info=client_info, ), self.pause_queue: gapic_v1.method.wrap_method( - self.pause_queue, default_timeout=20.0, client_info=client_info, + self.pause_queue, + default_timeout=20.0, + client_info=client_info, ), self.resume_queue: gapic_v1.method.wrap_method( - self.resume_queue, default_timeout=20.0, client_info=client_info, + self.resume_queue, + default_timeout=20.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -201,7 +214,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=20.0, client_info=client_info, + self.set_iam_policy, + default_timeout=20.0, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, @@ -249,7 +264,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_task: gapic_v1.method.wrap_method( - self.create_task, default_timeout=20.0, client_info=client_info, + self.create_task, + default_timeout=20.0, + client_info=client_info, ), self.delete_task: gapic_v1.method.wrap_method( self.delete_task, @@ -267,28 +284,38 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.lease_tasks: gapic_v1.method.wrap_method( - self.lease_tasks, default_timeout=20.0, client_info=client_info, + self.lease_tasks, + default_timeout=20.0, + client_info=client_info, ), self.acknowledge_task: gapic_v1.method.wrap_method( - self.acknowledge_task, default_timeout=20.0, client_info=client_info, + self.acknowledge_task, + default_timeout=20.0, + client_info=client_info, ), self.renew_lease: gapic_v1.method.wrap_method( - self.renew_lease, default_timeout=20.0, client_info=client_info, + self.renew_lease, + default_timeout=20.0, + client_info=client_info, ), self.cancel_lease: gapic_v1.method.wrap_method( - self.cancel_lease, default_timeout=20.0, client_info=client_info, + self.cancel_lease, + default_timeout=20.0, + client_info=client_info, ), self.run_task: gapic_v1.method.wrap_method( - self.run_task, default_timeout=20.0, client_info=client_info, + self.run_task, + default_timeout=20.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -462,5 +489,9 @@ def run_task( ) -> Callable[[cloudtasks.RunTaskRequest], Union[task.Task, Awaitable[task.Task]]]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("CloudTasksTransport",) diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py index bdefcda1..0d65c14a 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py @@ -13,15 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from google.cloud.tasks_v2beta2.types import cloudtasks @@ -29,10 +30,8 @@ from google.cloud.tasks_v2beta2.types import queue as gct_queue from google.cloud.tasks_v2beta2.types import task from google.cloud.tasks_v2beta2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport class CloudTasksGrpcTransport(CloudTasksTransport): @@ -232,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -933,5 +931,9 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("CloudTasksGrpcTransport",) diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py index c9f4bee1..30cbc0c3 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc_asyncio.py @@ -13,14 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -29,10 +30,8 @@ from google.cloud.tasks_v2beta2.types import queue as gct_queue from google.cloud.tasks_v2beta2.types import task from google.cloud.tasks_v2beta2.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2beta2/types/__init__.py b/google/cloud/tasks_v2beta2/types/__init__.py index b198074d..1ae3c727 100644 --- a/google/cloud/tasks_v2beta2/types/__init__.py +++ b/google/cloud/tasks_v2beta2/types/__init__.py @@ -35,25 +35,16 @@ RunTaskRequest, UpdateQueueRequest, ) -from .queue import ( - Queue, - QueueStats, - RateLimits, - RetryConfig, -) +from .queue import Queue, QueueStats, RateLimits, RetryConfig from .target import ( AppEngineHttpRequest, AppEngineHttpTarget, AppEngineRouting, + HttpMethod, PullMessage, PullTarget, - HttpMethod, -) -from .task import ( - AttemptStatus, - Task, - TaskStatus, ) +from .task import AttemptStatus, Task, TaskStatus __all__ = ( "AcknowledgeTaskRequest", diff --git a/google/cloud/tasks_v2beta2/types/cloudtasks.py b/google/cloud/tasks_v2beta2/types/cloudtasks.py index 2c22e59c..c10244f7 100644 --- a/google/cloud/tasks_v2beta2/types/cloudtasks.py +++ b/google/cloud/tasks_v2beta2/types/cloudtasks.py @@ -13,14 +13,13 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2beta2.types import queue as gct_queue -from google.cloud.tasks_v2beta2.types import task as gct_task from google.protobuf import duration_pb2 # type: ignore from google.protobuf import field_mask_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2beta2.types import queue as gct_queue +from google.cloud.tasks_v2beta2.types import task as gct_task __protobuf__ = proto.module( package="google.cloud.tasks.v2beta2", @@ -96,11 +95,27 @@ class ListQueuesRequest(proto.Message): returned only if it was explicitly specified in the mask. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=5, + message=field_mask_pb2.FieldMask, + ) class ListQueuesResponse(proto.Message): @@ -127,8 +142,15 @@ class ListQueuesResponse(proto.Message): def raw_page(self): return self - queues = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_queue.Queue,) - next_page_token = proto.Field(proto.STRING, number=2,) + queues = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetQueueRequest(proto.Message): @@ -146,8 +168,15 @@ class GetQueueRequest(proto.Message): returned only if it was explicitly specified in the mask. """ - name = proto.Field(proto.STRING, number=1,) - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) + name = proto.Field( + proto.STRING, + number=1, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) class CreateQueueRequest(proto.Message): @@ -170,8 +199,15 @@ class CreateQueueRequest(proto.Message): be the same as an existing queue. """ - parent = proto.Field(proto.STRING, number=1,) - queue = proto.Field(proto.MESSAGE, number=2, message=gct_queue.Queue,) + parent = proto.Field( + proto.STRING, + number=1, + ) + queue = proto.Field( + proto.MESSAGE, + number=2, + message=gct_queue.Queue, + ) class UpdateQueueRequest(proto.Message): @@ -195,9 +231,15 @@ class UpdateQueueRequest(proto.Message): If empty, then all fields will be updated. """ - queue = proto.Field(proto.MESSAGE, number=1, message=gct_queue.Queue,) + queue = proto.Field( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -211,7 +253,10 @@ class DeleteQueueRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PurgeQueueRequest(proto.Message): @@ -224,7 +269,10 @@ class PurgeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PauseQueueRequest(proto.Message): @@ -237,7 +285,10 @@ class PauseQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ResumeQueueRequest(proto.Message): @@ -250,7 +301,10 @@ class ResumeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListTasksRequest(proto.Message): @@ -301,10 +355,23 @@ class ListTasksRequest(proto.Message): The page token is valid for only 2 hours. """ - parent = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) - page_size = proto.Field(proto.INT32, number=4,) - page_token = proto.Field(proto.STRING, number=5,) + parent = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) + page_size = proto.Field( + proto.INT32, + number=4, + ) + page_token = proto.Field( + proto.STRING, + number=5, + ) class ListTasksResponse(proto.Message): @@ -329,8 +396,15 @@ class ListTasksResponse(proto.Message): def raw_page(self): return self - tasks = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_task.Task,) - next_page_token = proto.Field(proto.STRING, number=2,) + tasks = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_task.Task, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetTaskRequest(proto.Message): @@ -359,8 +433,15 @@ class GetTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) class CreateTaskRequest(proto.Message): @@ -432,9 +513,20 @@ class CreateTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta2.Task] resource. """ - parent = proto.Field(proto.STRING, number=1,) - task = proto.Field(proto.MESSAGE, number=2, message=gct_task.Task,) - response_view = proto.Field(proto.ENUM, number=3, enum=gct_task.Task.View,) + parent = proto.Field( + proto.STRING, + number=1, + ) + task = proto.Field( + proto.MESSAGE, + number=2, + message=gct_task.Task, + ) + response_view = proto.Field( + proto.ENUM, + number=3, + enum=gct_task.Task.View, + ) class DeleteTaskRequest(proto.Message): @@ -447,7 +539,10 @@ class DeleteTaskRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class LeaseTasksRequest(proto.Message): @@ -551,13 +646,28 @@ class LeaseTasksRequest(proto.Message): displayed as empty in Cloud Tasks. """ - parent = proto.Field(proto.STRING, number=1,) - max_tasks = proto.Field(proto.INT32, number=2,) + parent = proto.Field( + proto.STRING, + number=1, + ) + max_tasks = proto.Field( + proto.INT32, + number=2, + ) lease_duration = proto.Field( - proto.MESSAGE, number=3, message=duration_pb2.Duration, + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + response_view = proto.Field( + proto.ENUM, + number=4, + enum=gct_task.Task.View, + ) + filter = proto.Field( + proto.STRING, + number=5, ) - response_view = proto.Field(proto.ENUM, number=4, enum=gct_task.Task.View,) - filter = proto.Field(proto.STRING, number=5,) class LeaseTasksResponse(proto.Message): @@ -569,7 +679,11 @@ class LeaseTasksResponse(proto.Message): The leased tasks. """ - tasks = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_task.Task,) + tasks = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_task.Task, + ) class AcknowledgeTaskRequest(proto.Message): @@ -591,9 +705,14 @@ class AcknowledgeTaskRequest(proto.Message): currently holds the lease. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) schedule_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) @@ -637,14 +756,25 @@ class RenewLeaseRequest(proto.Message): [Task][google.cloud.tasks.v2beta2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) schedule_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) lease_duration = proto.Field( - proto.MESSAGE, number=3, message=duration_pb2.Duration, + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + response_view = proto.Field( + proto.ENUM, + number=4, + enum=gct_task.Task.View, ) - response_view = proto.Field(proto.ENUM, number=4, enum=gct_task.Task.View,) class CancelLeaseRequest(proto.Message): @@ -682,11 +812,20 @@ class CancelLeaseRequest(proto.Message): [Task][google.cloud.tasks.v2beta2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) schedule_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + response_view = proto.Field( + proto.ENUM, + number=3, + enum=gct_task.Task.View, ) - response_view = proto.Field(proto.ENUM, number=3, enum=gct_task.Task.View,) class RunTaskRequest(proto.Message): @@ -715,8 +854,15 @@ class RunTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta2.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta2/types/queue.py b/google/cloud/tasks_v2beta2/types/queue.py index 59db08cc..717f9ac3 100644 --- a/google/cloud/tasks_v2beta2/types/queue.py +++ b/google/cloud/tasks_v2beta2/types/queue.py @@ -13,16 +13,20 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2beta2.types import target from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2beta2.types import target __protobuf__ = proto.module( package="google.cloud.tasks.v2beta2", - manifest={"Queue", "RateLimits", "RetryConfig", "QueueStats",}, + manifest={ + "Queue", + "RateLimits", + "RetryConfig", + "QueueStats", + }, ) @@ -175,7 +179,10 @@ class State(proto.Enum): PAUSED = 2 DISABLED = 3 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_http_target = proto.Field( proto.MESSAGE, number=3, @@ -183,17 +190,46 @@ class State(proto.Enum): message=target.AppEngineHttpTarget, ) pull_target = proto.Field( - proto.MESSAGE, number=4, oneof="target_type", message=target.PullTarget, + proto.MESSAGE, + number=4, + oneof="target_type", + message=target.PullTarget, + ) + rate_limits = proto.Field( + proto.MESSAGE, + number=5, + message="RateLimits", + ) + retry_config = proto.Field( + proto.MESSAGE, + number=6, + message="RetryConfig", + ) + state = proto.Field( + proto.ENUM, + number=7, + enum=State, + ) + purge_time = proto.Field( + proto.MESSAGE, + number=8, + message=timestamp_pb2.Timestamp, + ) + task_ttl = proto.Field( + proto.MESSAGE, + number=9, + message=duration_pb2.Duration, ) - rate_limits = proto.Field(proto.MESSAGE, number=5, message="RateLimits",) - retry_config = proto.Field(proto.MESSAGE, number=6, message="RetryConfig",) - state = proto.Field(proto.ENUM, number=7, enum=State,) - purge_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) - task_ttl = proto.Field(proto.MESSAGE, number=9, message=duration_pb2.Duration,) tombstone_ttl = proto.Field( - proto.MESSAGE, number=10, message=duration_pb2.Duration, + proto.MESSAGE, + number=10, + message=duration_pb2.Duration, + ) + stats = proto.Field( + proto.MESSAGE, + number=16, + message="QueueStats", ) - stats = proto.Field(proto.MESSAGE, number=16, message="QueueStats",) class RateLimits(proto.Message): @@ -287,9 +323,18 @@ class RateLimits(proto.Message): queue.yaml/xml `__. """ - max_tasks_dispatched_per_second = proto.Field(proto.DOUBLE, number=1,) - max_burst_size = proto.Field(proto.INT32, number=2,) - max_concurrent_tasks = proto.Field(proto.INT32, number=3,) + max_tasks_dispatched_per_second = proto.Field( + proto.DOUBLE, + number=1, + ) + max_burst_size = proto.Field( + proto.INT32, + number=2, + ) + max_concurrent_tasks = proto.Field( + proto.INT32, + number=3, + ) class RetryConfig(proto.Message): @@ -418,14 +463,35 @@ class RetryConfig(proto.Message): queue.yaml/xml `__. """ - max_attempts = proto.Field(proto.INT32, number=1, oneof="num_attempts",) - unlimited_attempts = proto.Field(proto.BOOL, number=2, oneof="num_attempts",) + max_attempts = proto.Field( + proto.INT32, + number=1, + oneof="num_attempts", + ) + unlimited_attempts = proto.Field( + proto.BOOL, + number=2, + oneof="num_attempts", + ) max_retry_duration = proto.Field( - proto.MESSAGE, number=3, message=duration_pb2.Duration, + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + min_backoff = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + max_backoff = proto.Field( + proto.MESSAGE, + number=5, + message=duration_pb2.Duration, + ) + max_doublings = proto.Field( + proto.INT32, + number=6, ) - min_backoff = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) - max_backoff = proto.Field(proto.MESSAGE, number=5, message=duration_pb2.Duration,) - max_doublings = proto.Field(proto.INT32, number=6,) class QueueStats(proto.Message): @@ -461,13 +527,27 @@ class QueueStats(proto.Message): tasks in the queue are targeting. """ - tasks_count = proto.Field(proto.INT64, number=1,) + tasks_count = proto.Field( + proto.INT64, + number=1, + ) oldest_estimated_arrival_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + executed_last_minute_count = proto.Field( + proto.INT64, + number=3, + ) + concurrent_dispatches_count = proto.Field( + proto.INT64, + number=4, + ) + effective_execution_rate = proto.Field( + proto.DOUBLE, + number=5, ) - executed_last_minute_count = proto.Field(proto.INT64, number=3,) - concurrent_dispatches_count = proto.Field(proto.INT64, number=4,) - effective_execution_rate = proto.Field(proto.DOUBLE, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta2/types/target.py b/google/cloud/tasks_v2beta2/types/target.py index 73ffa97c..95b5991b 100644 --- a/google/cloud/tasks_v2beta2/types/target.py +++ b/google/cloud/tasks_v2beta2/types/target.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.tasks.v2beta2", manifest={ @@ -40,8 +39,7 @@ class HttpMethod(proto.Enum): class PullTarget(proto.Message): - r"""Pull target. - """ + r"""Pull target.""" class PullMessage(proto.Message): @@ -81,8 +79,14 @@ class PullMessage(proto.Message): returned by Cloud Tasks. """ - payload = proto.Field(proto.BYTES, number=1,) - tag = proto.Field(proto.STRING, number=2,) + payload = proto.Field( + proto.BYTES, + number=1, + ) + tag = proto.Field( + proto.STRING, + number=2, + ) class AppEngineHttpTarget(proto.Message): @@ -117,7 +121,9 @@ class AppEngineHttpTarget(proto.Message): """ app_engine_routing_override = proto.Field( - proto.MESSAGE, number=1, message="AppEngineRouting", + proto.MESSAGE, + number=1, + message="AppEngineRouting", ) @@ -217,7 +223,7 @@ class AppEngineHttpRequest(proto.Message): is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters. - headers (Sequence[google.cloud.tasks_v2beta2.types.AppEngineHttpRequest.HeadersEntry]): + headers (Mapping[str, str]): HTTP request headers. This map contains the header field names and values. Headers @@ -278,13 +284,29 @@ class AppEngineHttpRequest(proto.Message): [HttpMethod][google.cloud.tasks.v2beta2.HttpMethod]. """ - http_method = proto.Field(proto.ENUM, number=1, enum="HttpMethod",) + http_method = proto.Field( + proto.ENUM, + number=1, + enum="HttpMethod", + ) app_engine_routing = proto.Field( - proto.MESSAGE, number=2, message="AppEngineRouting", + proto.MESSAGE, + number=2, + message="AppEngineRouting", + ) + relative_url = proto.Field( + proto.STRING, + number=3, + ) + headers = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + payload = proto.Field( + proto.BYTES, + number=5, ) - relative_url = proto.Field(proto.STRING, number=3,) - headers = proto.MapField(proto.STRING, proto.STRING, number=4,) - payload = proto.Field(proto.BYTES, number=5,) class AppEngineRouting(proto.Message): @@ -443,10 +465,22 @@ class AppEngineRouting(proto.Message): version of the default service when the task is attempted. """ - service = proto.Field(proto.STRING, number=1,) - version = proto.Field(proto.STRING, number=2,) - instance = proto.Field(proto.STRING, number=3,) - host = proto.Field(proto.STRING, number=4,) + service = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + instance = proto.Field( + proto.STRING, + number=3, + ) + host = proto.Field( + proto.STRING, + number=4, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta2/types/task.py b/google/cloud/tasks_v2beta2/types/task.py index 8751b5a2..af1b2df5 100644 --- a/google/cloud/tasks_v2beta2/types/task.py +++ b/google/cloud/tasks_v2beta2/types/task.py @@ -13,16 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2beta2.types import target from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2beta2.types import target __protobuf__ = proto.module( package="google.cloud.tasks.v2beta2", - manifest={"Task", "TaskStatus", "AttemptStatus",}, + manifest={ + "Task", + "TaskStatus", + "AttemptStatus", + }, ) @@ -121,7 +124,10 @@ class View(proto.Enum): BASIC = 1 FULL = 2 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_http_request = proto.Field( proto.MESSAGE, number=3, @@ -129,14 +135,31 @@ class View(proto.Enum): message=target.AppEngineHttpRequest, ) pull_message = proto.Field( - proto.MESSAGE, number=4, oneof="payload_type", message=target.PullMessage, + proto.MESSAGE, + number=4, + oneof="payload_type", + message=target.PullMessage, ) schedule_time = proto.Field( - proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + create_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + status = proto.Field( + proto.MESSAGE, + number=7, + message="TaskStatus", + ) + view = proto.Field( + proto.ENUM, + number=8, + enum=View, ) - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) - status = proto.Field(proto.MESSAGE, number=7, message="TaskStatus",) - view = proto.Field(proto.ENUM, number=8, enum=View,) class TaskStatus(proto.Message): @@ -172,12 +195,24 @@ class TaskStatus(proto.Message): tasks][google.cloud.tasks.v2beta2.PullMessage]. """ - attempt_dispatch_count = proto.Field(proto.INT32, number=1,) - attempt_response_count = proto.Field(proto.INT32, number=2,) + attempt_dispatch_count = proto.Field( + proto.INT32, + number=1, + ) + attempt_response_count = proto.Field( + proto.INT32, + number=2, + ) first_attempt_status = proto.Field( - proto.MESSAGE, number=3, message="AttemptStatus", + proto.MESSAGE, + number=3, + message="AttemptStatus", + ) + last_attempt_status = proto.Field( + proto.MESSAGE, + number=4, + message="AttemptStatus", ) - last_attempt_status = proto.Field(proto.MESSAGE, number=4, message="AttemptStatus",) class AttemptStatus(proto.Message): @@ -209,15 +244,25 @@ class AttemptStatus(proto.Message): """ schedule_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) dispatch_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) response_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + response_status = proto.Field( + proto.MESSAGE, + number=4, + message=status_pb2.Status, ) - response_status = proto.Field(proto.MESSAGE, number=4, message=status_pb2.Status,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta3/__init__.py b/google/cloud/tasks_v2beta3/__init__.py index aacbca5f..87f47f7c 100644 --- a/google/cloud/tasks_v2beta3/__init__.py +++ b/google/cloud/tasks_v2beta3/__init__.py @@ -14,39 +14,42 @@ # limitations under the License. # -from .services.cloud_tasks import CloudTasksClient -from .services.cloud_tasks import CloudTasksAsyncClient - -from .types.cloudtasks import CreateQueueRequest -from .types.cloudtasks import CreateTaskRequest -from .types.cloudtasks import DeleteQueueRequest -from .types.cloudtasks import DeleteTaskRequest -from .types.cloudtasks import GetQueueRequest -from .types.cloudtasks import GetTaskRequest -from .types.cloudtasks import ListQueuesRequest -from .types.cloudtasks import ListQueuesResponse -from .types.cloudtasks import ListTasksRequest -from .types.cloudtasks import ListTasksResponse -from .types.cloudtasks import PauseQueueRequest -from .types.cloudtasks import PurgeQueueRequest -from .types.cloudtasks import ResumeQueueRequest -from .types.cloudtasks import RunTaskRequest -from .types.cloudtasks import UpdateQueueRequest -from .types.queue import Queue -from .types.queue import QueueStats -from .types.queue import RateLimits -from .types.queue import RetryConfig -from .types.queue import StackdriverLoggingConfig -from .types.target import AppEngineHttpQueue -from .types.target import AppEngineHttpRequest -from .types.target import AppEngineRouting -from .types.target import HttpRequest -from .types.target import OAuthToken -from .types.target import OidcToken -from .types.target import PullMessage -from .types.target import HttpMethod -from .types.task import Attempt -from .types.task import Task +from .services.cloud_tasks import CloudTasksAsyncClient, CloudTasksClient +from .types.cloudtasks import ( + CreateQueueRequest, + CreateTaskRequest, + DeleteQueueRequest, + DeleteTaskRequest, + GetQueueRequest, + GetTaskRequest, + ListQueuesRequest, + ListQueuesResponse, + ListTasksRequest, + ListTasksResponse, + PauseQueueRequest, + PurgeQueueRequest, + ResumeQueueRequest, + RunTaskRequest, + UpdateQueueRequest, +) +from .types.queue import ( + Queue, + QueueStats, + RateLimits, + RetryConfig, + StackdriverLoggingConfig, +) +from .types.target import ( + AppEngineHttpQueue, + AppEngineHttpRequest, + AppEngineRouting, + HttpMethod, + HttpRequest, + OAuthToken, + OidcToken, + PullMessage, +) +from .types.task import Attempt, Task __all__ = ( "CloudTasksAsyncClient", diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/__init__.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/__init__.py index aedb130d..b47f3823 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/__init__.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/__init__.py @@ -13,8 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. # -from .client import CloudTasksClient from .async_client import CloudTasksAsyncClient +from .client import CloudTasksClient __all__ = ( "CloudTasksClient", diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py index 29b6688a..06196ba9 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py @@ -16,21 +16,27 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union -from google.api_core.client_options import ClientOptions from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +from google.api_core.client_options import ClientOptions from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -38,14 +44,10 @@ from google.cloud.tasks_v2beta3.types import target from google.cloud.tasks_v2beta3.types import task from google.cloud.tasks_v2beta3.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO -from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport + from .client import CloudTasksClient +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport +from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport class CloudTasksAsyncClient: @@ -222,14 +224,13 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_list_queues(): + async def sample_list_queues(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.ListQueuesRequest( @@ -240,7 +241,7 @@ def sample_list_queues(): page_result = client.list_queues(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -311,12 +312,20 @@ def sample_list_queues(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListQueuesAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -337,9 +346,9 @@ async def get_queue( from google.cloud import tasks_v2beta3 - def sample_get_queue(): + async def sample_get_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.GetQueueRequest( @@ -347,7 +356,7 @@ def sample_get_queue(): ) # Make the request - response = client.get_queue(request=request) + response = await client.get_queue(request=request) # Handle the response print(response) @@ -421,7 +430,12 @@ def sample_get_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -448,14 +462,13 @@ async def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_create_queue(): + async def sample_create_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.CreateQueueRequest( @@ -463,7 +476,7 @@ def sample_create_queue(): ) # Make the request - response = client.create_queue(request=request) + response = await client.create_queue(request=request) # Handle the response print(response) @@ -543,7 +556,12 @@ def sample_create_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -573,21 +591,20 @@ async def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_update_queue(): + async def sample_update_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.UpdateQueueRequest( ) # Make the request - response = client.update_queue(request=request) + response = await client.update_queue(request=request) # Handle the response print(response) @@ -673,7 +690,12 @@ def sample_update_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -700,14 +722,13 @@ async def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_delete_queue(): + async def sample_delete_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.DeleteQueueRequest( @@ -715,7 +736,7 @@ def sample_delete_queue(): ) # Make the request - client.delete_queue(request=request) + await client.delete_queue(request=request) Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteQueueRequest, dict]): @@ -777,7 +798,10 @@ def sample_delete_queue(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def purge_queue( @@ -796,14 +820,13 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_purge_queue(): + async def sample_purge_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.PurgeQueueRequest( @@ -811,7 +834,7 @@ def sample_purge_queue(): ) # Make the request - response = client.purge_queue(request=request) + response = await client.purge_queue(request=request) # Handle the response print(response) @@ -875,7 +898,12 @@ def sample_purge_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -898,14 +926,13 @@ async def pause_queue( paused if its [state][google.cloud.tasks.v2beta3.Queue.state] is [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_pause_queue(): + async def sample_pause_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.PauseQueueRequest( @@ -913,7 +940,7 @@ def sample_pause_queue(): ) # Make the request - response = client.pause_queue(request=request) + response = await client.pause_queue(request=request) # Handle the response print(response) @@ -977,7 +1004,12 @@ def sample_pause_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1007,14 +1039,13 @@ async def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_resume_queue(): + async def sample_resume_queue(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.ResumeQueueRequest( @@ -1022,7 +1053,7 @@ def sample_resume_queue(): ) # Make the request - response = client.resume_queue(request=request) + response = await client.resume_queue(request=request) # Handle the response print(response) @@ -1086,7 +1117,12 @@ def sample_resume_queue(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1110,22 +1146,22 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_get_iam_policy(): + async def sample_get_iam_policy(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.get_iam_policy(request=request) + response = await client.get_iam_policy(request=request) # Handle the response print(response) @@ -1151,21 +1187,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1180,17 +1221,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1201,11 +1242,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1223,7 +1265,9 @@ def sample_get_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.GetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.GetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.GetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1250,7 +1294,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1278,22 +1327,22 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_set_iam_policy(): + async def sample_set_iam_policy(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) # Make the request - response = client.set_iam_policy(request=request) + response = await client.set_iam_policy(request=request) # Handle the response print(response) @@ -1319,21 +1368,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1348,17 +1402,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1369,11 +1423,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1391,7 +1446,9 @@ def sample_set_iam_policy(): if isinstance(request, dict): request = iam_policy_pb2.SetIamPolicyRequest(**request) elif not request: - request = iam_policy_pb2.SetIamPolicyRequest(resource=resource,) + request = iam_policy_pb2.SetIamPolicyRequest( + resource=resource, + ) # Wrap the RPC method; this adds retry and timeout information, # and friendly error handling. @@ -1408,7 +1465,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1433,23 +1495,23 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore - def sample_test_iam_permissions(): + async def sample_test_iam_permissions(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) # Make the request - response = client.test_iam_permissions(request=request) + response = await client.test_iam_permissions(request=request) # Handle the response print(response) @@ -1502,7 +1564,8 @@ def sample_test_iam_permissions(): request = iam_policy_pb2.TestIamPermissionsRequest(**request) elif not request: request = iam_policy_pb2.TestIamPermissionsRequest( - resource=resource, permissions=permissions, + resource=resource, + permissions=permissions, ) # Wrap the RPC method; this adds retry and timeout information, @@ -1530,7 +1593,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1555,14 +1623,13 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_list_tasks(): + async def sample_list_tasks(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.ListTasksRequest( @@ -1573,7 +1640,7 @@ def sample_list_tasks(): page_result = client.list_tasks(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1645,12 +1712,20 @@ def sample_list_tasks(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListTasksAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1671,9 +1746,9 @@ async def get_task( from google.cloud import tasks_v2beta3 - def sample_get_task(): + async def sample_get_task(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.GetTaskRequest( @@ -1681,7 +1756,7 @@ def sample_get_task(): ) # Make the request - response = client.get_task(request=request) + response = await client.get_task(request=request) # Handle the response print(response) @@ -1750,7 +1825,12 @@ def sample_get_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1772,14 +1852,13 @@ async def create_task( - The maximum task size is 100KB. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_create_task(): + async def sample_create_task(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.CreateTaskRequest( @@ -1787,7 +1866,7 @@ def sample_create_task(): ) # Make the request - response = client.create_task(request=request) + response = await client.create_task(request=request) # Handle the response print(response) @@ -1895,7 +1974,12 @@ def sample_create_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1914,14 +1998,13 @@ async def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_delete_task(): + async def sample_delete_task(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.DeleteTaskRequest( @@ -1929,7 +2012,7 @@ def sample_delete_task(): ) # Make the request - client.delete_task(request=request) + await client.delete_task(request=request) Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteTaskRequest, dict]): @@ -1992,7 +2075,10 @@ def sample_delete_task(): # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def run_task( @@ -2033,14 +2119,13 @@ async def run_task( [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta3 - def sample_run_task(): + async def sample_run_task(): # Create a client - client = tasks_v2beta3.CloudTasksClient() + client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) request = tasks_v2beta3.RunTaskRequest( @@ -2048,7 +2133,7 @@ def sample_run_task(): ) # Make the request - response = client.run_task(request=request) + response = await client.run_task(request=request) # Handle the response print(response) @@ -2107,7 +2192,12 @@ def sample_run_task(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2121,7 +2211,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py index 6898e9f1..9f2b1686 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py @@ -16,24 +16,30 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union -import pkg_resources +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union from google.api_core import client_options as client_options_lib from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore +from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore -from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore +import pkg_resources try: OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] except AttributeError: # pragma: NO COVER OptionalRetry = Union[retries.Retry, object] # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import field_mask_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore + from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue @@ -41,12 +47,8 @@ from google.cloud.tasks_v2beta3.types import target from google.cloud.tasks_v2beta3.types import task from google.cloud.tasks_v2beta3.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import duration_pb2 # type: ignore -from google.protobuf import field_mask_pb2 # type: ignore -from google.protobuf import timestamp_pb2 # type: ignore -from .transports.base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .transports.base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .transports.grpc import CloudTasksGrpcTransport from .transports.grpc_asyncio import CloudTasksGrpcAsyncIOTransport @@ -63,7 +65,10 @@ class CloudTasksClientMeta(type): _transport_registry["grpc"] = CloudTasksGrpcTransport _transport_registry["grpc_asyncio"] = CloudTasksGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudTasksTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudTasksTransport]: """Returns an appropriate transport class. Args: @@ -170,10 +175,16 @@ def transport(self) -> CloudTasksTransport: return self._transport @staticmethod - def queue_path(project: str, location: str, queue: str,) -> str: + def queue_path( + project: str, + location: str, + queue: str, + ) -> str: """Returns a fully-qualified queue string.""" return "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) @staticmethod @@ -186,10 +197,18 @@ def parse_queue_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def task_path(project: str, location: str, queue: str, task: str,) -> str: + def task_path( + project: str, + location: str, + queue: str, + task: str, + ) -> str: """Returns a fully-qualified task string.""" return "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + project=project, + location=location, + queue=queue, + task=task, ) @staticmethod @@ -202,7 +221,9 @@ def parse_task_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -215,9 +236,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -226,9 +251,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -237,9 +266,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -248,10 +281,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -437,7 +474,6 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -516,12 +552,20 @@ def sample_list_queues(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListQueuesPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -616,7 +660,12 @@ def sample_get_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -643,7 +692,6 @@ def create_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -738,7 +786,12 @@ def sample_create_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -768,7 +821,6 @@ def update_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -868,7 +920,12 @@ def sample_update_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -895,7 +952,6 @@ def delete_queue( queue.yaml `__ before using this method. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -962,7 +1018,10 @@ def sample_delete_queue(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def purge_queue( @@ -981,7 +1040,6 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -1060,7 +1118,12 @@ def sample_purge_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1083,7 +1146,6 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2beta3.Queue.state] is [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -1162,7 +1224,12 @@ def sample_pause_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1192,7 +1259,6 @@ def resume_queue( Scaling Risks `__. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -1271,7 +1337,12 @@ def sample_resume_queue(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1295,17 +1366,17 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): # Create a client client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) @@ -1336,21 +1407,26 @@ def sample_get_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1365,17 +1441,17 @@ def sample_get_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1386,11 +1462,12 @@ def sample_get_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1424,7 +1501,12 @@ def sample_get_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1452,17 +1534,17 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): # Create a client client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) @@ -1493,21 +1575,26 @@ def sample_set_iam_policy(): Returns: google.iam.v1.policy_pb2.Policy: - Defines an Identity and Access Management (IAM) policy. It is used to - specify access control policies for Cloud Platform - resources. + An Identity and Access Management (IAM) policy, which specifies access + controls for Google Cloud resources. A Policy is a collection of bindings. A binding binds - one or more members to a single role. Members can be - user accounts, service accounts, Google groups, and - domains (such as G Suite). A role is a named list of - permissions (defined by IAM or configured by users). - A binding can optionally specify a condition, which - is a logic expression that further constrains the - role binding based on attributes about the request - and/or target resource. - - **JSON Example** + one or more members, or principals, to a single role. + Principals can be user accounts, service accounts, + Google groups, and domains (such as G Suite). A role + is a named list of permissions; each role can be an + IAM predefined role or a user-created custom role. + + For some types of Google Cloud resources, a binding + can also specify a condition, which is a logical + expression that allows access to a resource only if + the expression evaluates to true. A condition can add + constraints based on attributes of the request, the + resource, or both. To learn which resources support + conditions in their IAM policies, see the [IAM + documentation](\ https://cloud.google.com/iam/help/conditions/resource-policies). + + **JSON example:** { "bindings": [ @@ -1522,17 +1609,17 @@ def sample_set_iam_policy(): }, { "role": "roles/resourcemanager.organizationViewer", - "members": ["user:eve@example.com"], + "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } - ] + ], "etag": "BwWWja0YfJA=", "version": 3 } - **YAML Example** + **YAML example:** bindings: - members: - user:\ mike@example.com - group:\ admins@example.com - domain:google.com - @@ -1543,11 +1630,12 @@ def sample_set_iam_policy(): condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < - timestamp('2020-10-01T00:00:00.000Z') + timestamp('2020-10-01T00:00:00.000Z') etag: + BwWWja0YfJA= version: 3 For a description of IAM and its features, see the - [IAM developer's - guide](\ https://cloud.google.com/iam/docs). + [IAM + documentation](\ https://cloud.google.com/iam/docs/). """ # Create or coerce a protobuf request object. @@ -1581,7 +1669,12 @@ def sample_set_iam_policy(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1606,17 +1699,17 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. - .. code-block:: python from google.cloud import tasks_v2beta3 + from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): # Create a client client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) @@ -1692,7 +1785,12 @@ def sample_test_iam_permissions(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1717,7 +1815,6 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -1797,12 +1894,20 @@ def sample_list_tasks(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListTasksPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1892,7 +1997,12 @@ def sample_get_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1914,7 +2024,6 @@ def create_task( - The maximum task size is 100KB. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -2037,7 +2146,12 @@ def sample_create_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2056,7 +2170,6 @@ def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -2124,7 +2237,10 @@ def sample_delete_task(): # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def run_task( @@ -2165,7 +2281,6 @@ def run_task( [NOT_FOUND][google.rpc.Code.NOT_FOUND] when it is called on a task that has already succeeded or permanently failed. - .. code-block:: python from google.cloud import tasks_v2beta3 @@ -2239,7 +2354,12 @@ def sample_run_task(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2260,7 +2380,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py index 6d34e80c..7efe01c3 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/pagers.py @@ -18,15 +18,13 @@ AsyncIterator, Awaitable, Callable, + Iterator, + Optional, Sequence, Tuple, - Optional, - Iterator, ) -from google.cloud.tasks_v2beta3.types import cloudtasks -from google.cloud.tasks_v2beta3.types import queue -from google.cloud.tasks_v2beta3.types import task +from google.cloud.tasks_v2beta3.types import cloudtasks, queue, task class ListQueuesPager: diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/__init__.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/__init__.py index ec04b44d..dd95e460 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/__init__.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/__init__.py @@ -20,7 +20,6 @@ from .grpc import CloudTasksGrpcTransport from .grpc_asyncio import CloudTasksGrpcAsyncIOTransport - # Compile a registry of transports. _transport_registry = OrderedDict() # type: Dict[str, Type[CloudTasksTransport]] _transport_registry["grpc"] = CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py index 6924af75..174e108b 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/base.py @@ -15,28 +15,30 @@ # import abc from typing import Awaitable, Callable, Dict, Optional, Sequence, Union -import pkg_resources -import google.auth # type: ignore import google.api_core from google.api_core import exceptions as core_exceptions from google.api_core import gapic_v1 from google.api_core import retry as retries +import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore from google.oauth2 import service_account # type: ignore +from google.protobuf import empty_pb2 # type: ignore +import pkg_resources from google.cloud.tasks_v2beta3.types import cloudtasks from google.cloud.tasks_v2beta3.types import queue from google.cloud.tasks_v2beta3.types import queue as gct_queue from google.cloud.tasks_v2beta3.types import task from google.cloud.tasks_v2beta3.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-tasks",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-tasks", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -85,6 +87,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -156,10 +159,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_queue: gapic_v1.method.wrap_method( - self.create_queue, default_timeout=20.0, client_info=client_info, + self.create_queue, + default_timeout=20.0, + client_info=client_info, ), self.update_queue: gapic_v1.method.wrap_method( - self.update_queue, default_timeout=20.0, client_info=client_info, + self.update_queue, + default_timeout=20.0, + client_info=client_info, ), self.delete_queue: gapic_v1.method.wrap_method( self.delete_queue, @@ -177,13 +184,19 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.purge_queue: gapic_v1.method.wrap_method( - self.purge_queue, default_timeout=20.0, client_info=client_info, + self.purge_queue, + default_timeout=20.0, + client_info=client_info, ), self.pause_queue: gapic_v1.method.wrap_method( - self.pause_queue, default_timeout=20.0, client_info=client_info, + self.pause_queue, + default_timeout=20.0, + client_info=client_info, ), self.resume_queue: gapic_v1.method.wrap_method( - self.resume_queue, default_timeout=20.0, client_info=client_info, + self.resume_queue, + default_timeout=20.0, + client_info=client_info, ), self.get_iam_policy: gapic_v1.method.wrap_method( self.get_iam_policy, @@ -201,7 +214,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.set_iam_policy: gapic_v1.method.wrap_method( - self.set_iam_policy, default_timeout=20.0, client_info=client_info, + self.set_iam_policy, + default_timeout=20.0, + client_info=client_info, ), self.test_iam_permissions: gapic_v1.method.wrap_method( self.test_iam_permissions, @@ -249,7 +264,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_task: gapic_v1.method.wrap_method( - self.create_task, default_timeout=20.0, client_info=client_info, + self.create_task, + default_timeout=20.0, + client_info=client_info, ), self.delete_task: gapic_v1.method.wrap_method( self.delete_task, @@ -267,16 +284,18 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.run_task: gapic_v1.method.wrap_method( - self.run_task, default_timeout=20.0, client_info=client_info, + self.run_task, + default_timeout=20.0, + client_info=client_info, ), } def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -416,5 +435,9 @@ def run_task( ) -> Callable[[cloudtasks.RunTaskRequest], Union[task.Task, Awaitable[task.Task]]]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("CloudTasksTransport",) diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py index 712d8d9b..a9b2ac0b 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py @@ -13,15 +13,16 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import grpc_helpers -from google.api_core import gapic_v1 +from google.api_core import gapic_v1, grpc_helpers import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from google.cloud.tasks_v2beta3.types import cloudtasks @@ -29,10 +30,8 @@ from google.cloud.tasks_v2beta3.types import queue as gct_queue from google.cloud.tasks_v2beta3.types import task from google.cloud.tasks_v2beta3.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport class CloudTasksGrpcTransport(CloudTasksTransport): @@ -232,8 +231,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -775,5 +773,9 @@ def run_task(self) -> Callable[[cloudtasks.RunTaskRequest], task.Task]: def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("CloudTasksGrpcTransport",) diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py index 2531ad03..be558793 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc_asyncio.py @@ -13,14 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union +import warnings -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers_async +from google.api_core import gapic_v1, grpc_helpers_async from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore - +from google.iam.v1 import iam_policy_pb2 # type: ignore +from google.iam.v1 import policy_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore import grpc # type: ignore from grpc.experimental import aio # type: ignore @@ -29,10 +30,8 @@ from google.cloud.tasks_v2beta3.types import queue as gct_queue from google.cloud.tasks_v2beta3.types import task from google.cloud.tasks_v2beta3.types import task as gct_task -from google.iam.v1 import iam_policy_pb2 # type: ignore -from google.iam.v1 import policy_pb2 # type: ignore -from google.protobuf import empty_pb2 # type: ignore -from .base import CloudTasksTransport, DEFAULT_CLIENT_INFO + +from .base import DEFAULT_CLIENT_INFO, CloudTasksTransport from .grpc import CloudTasksGrpcTransport diff --git a/google/cloud/tasks_v2beta3/types/__init__.py b/google/cloud/tasks_v2beta3/types/__init__.py index fd8d5813..66f3e0ab 100644 --- a/google/cloud/tasks_v2beta3/types/__init__.py +++ b/google/cloud/tasks_v2beta3/types/__init__.py @@ -30,27 +30,18 @@ RunTaskRequest, UpdateQueueRequest, ) -from .queue import ( - Queue, - QueueStats, - RateLimits, - RetryConfig, - StackdriverLoggingConfig, -) +from .queue import Queue, QueueStats, RateLimits, RetryConfig, StackdriverLoggingConfig from .target import ( AppEngineHttpQueue, AppEngineHttpRequest, AppEngineRouting, + HttpMethod, HttpRequest, OAuthToken, OidcToken, PullMessage, - HttpMethod, -) -from .task import ( - Attempt, - Task, ) +from .task import Attempt, Task __all__ = ( "CreateQueueRequest", diff --git a/google/cloud/tasks_v2beta3/types/cloudtasks.py b/google/cloud/tasks_v2beta3/types/cloudtasks.py index 90504fec..663e2124 100644 --- a/google/cloud/tasks_v2beta3/types/cloudtasks.py +++ b/google/cloud/tasks_v2beta3/types/cloudtasks.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # +from google.protobuf import field_mask_pb2 # type: ignore import proto # type: ignore from google.cloud.tasks_v2beta3.types import queue as gct_queue from google.cloud.tasks_v2beta3.types import task as gct_task -from google.protobuf import field_mask_pb2 # type: ignore - __protobuf__ = proto.module( package="google.cloud.tasks.v2beta3", @@ -89,11 +88,27 @@ class ListQueuesRequest(proto.Message): returned only if it was explicitly specified in the mask. """ - parent = proto.Field(proto.STRING, number=1,) - filter = proto.Field(proto.STRING, number=2,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) - read_mask = proto.Field(proto.MESSAGE, number=5, message=field_mask_pb2.FieldMask,) + parent = proto.Field( + proto.STRING, + number=1, + ) + filter = proto.Field( + proto.STRING, + number=2, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=5, + message=field_mask_pb2.FieldMask, + ) class ListQueuesResponse(proto.Message): @@ -120,8 +135,15 @@ class ListQueuesResponse(proto.Message): def raw_page(self): return self - queues = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_queue.Queue,) - next_page_token = proto.Field(proto.STRING, number=2,) + queues = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetQueueRequest(proto.Message): @@ -139,8 +161,15 @@ class GetQueueRequest(proto.Message): returned only if it was explicitly specified in the mask. """ - name = proto.Field(proto.STRING, number=1,) - read_mask = proto.Field(proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask,) + name = proto.Field( + proto.STRING, + number=1, + ) + read_mask = proto.Field( + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) class CreateQueueRequest(proto.Message): @@ -163,8 +192,15 @@ class CreateQueueRequest(proto.Message): be the same as an existing queue. """ - parent = proto.Field(proto.STRING, number=1,) - queue = proto.Field(proto.MESSAGE, number=2, message=gct_queue.Queue,) + parent = proto.Field( + proto.STRING, + number=1, + ) + queue = proto.Field( + proto.MESSAGE, + number=2, + message=gct_queue.Queue, + ) class UpdateQueueRequest(proto.Message): @@ -188,9 +224,15 @@ class UpdateQueueRequest(proto.Message): If empty, then all fields will be updated. """ - queue = proto.Field(proto.MESSAGE, number=1, message=gct_queue.Queue,) + queue = proto.Field( + proto.MESSAGE, + number=1, + message=gct_queue.Queue, + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, ) @@ -204,7 +246,10 @@ class DeleteQueueRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PurgeQueueRequest(proto.Message): @@ -217,7 +262,10 @@ class PurgeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class PauseQueueRequest(proto.Message): @@ -230,7 +278,10 @@ class PauseQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ResumeQueueRequest(proto.Message): @@ -243,7 +294,10 @@ class ResumeQueueRequest(proto.Message): ``projects/PROJECT_ID/location/LOCATION_ID/queues/QUEUE_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class ListTasksRequest(proto.Message): @@ -294,10 +348,23 @@ class ListTasksRequest(proto.Message): The page token is valid for only 2 hours. """ - parent = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) - page_size = proto.Field(proto.INT32, number=3,) - page_token = proto.Field(proto.STRING, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) + page_size = proto.Field( + proto.INT32, + number=3, + ) + page_token = proto.Field( + proto.STRING, + number=4, + ) class ListTasksResponse(proto.Message): @@ -322,8 +389,15 @@ class ListTasksResponse(proto.Message): def raw_page(self): return self - tasks = proto.RepeatedField(proto.MESSAGE, number=1, message=gct_task.Task,) - next_page_token = proto.Field(proto.STRING, number=2,) + tasks = proto.RepeatedField( + proto.MESSAGE, + number=1, + message=gct_task.Task, + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class GetTaskRequest(proto.Message): @@ -352,8 +426,15 @@ class GetTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta3.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) class CreateTaskRequest(proto.Message): @@ -425,9 +506,20 @@ class CreateTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta3.Task] resource. """ - parent = proto.Field(proto.STRING, number=1,) - task = proto.Field(proto.MESSAGE, number=2, message=gct_task.Task,) - response_view = proto.Field(proto.ENUM, number=3, enum=gct_task.Task.View,) + parent = proto.Field( + proto.STRING, + number=1, + ) + task = proto.Field( + proto.MESSAGE, + number=2, + message=gct_task.Task, + ) + response_view = proto.Field( + proto.ENUM, + number=3, + enum=gct_task.Task.View, + ) class DeleteTaskRequest(proto.Message): @@ -440,7 +532,10 @@ class DeleteTaskRequest(proto.Message): ``projects/PROJECT_ID/locations/LOCATION_ID/queues/QUEUE_ID/tasks/TASK_ID`` """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class RunTaskRequest(proto.Message): @@ -469,8 +564,15 @@ class RunTaskRequest(proto.Message): [Task][google.cloud.tasks.v2beta3.Task] resource. """ - name = proto.Field(proto.STRING, number=1,) - response_view = proto.Field(proto.ENUM, number=2, enum=gct_task.Task.View,) + name = proto.Field( + proto.STRING, + number=1, + ) + response_view = proto.Field( + proto.ENUM, + number=2, + enum=gct_task.Task.View, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta3/types/queue.py b/google/cloud/tasks_v2beta3/types/queue.py index 291902ca..f2aed3c0 100644 --- a/google/cloud/tasks_v2beta3/types/queue.py +++ b/google/cloud/tasks_v2beta3/types/queue.py @@ -13,12 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2beta3.types import target from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2beta3.types import target __protobuf__ = proto.module( package="google.cloud.tasks.v2beta3", @@ -201,21 +200,61 @@ class Type(proto.Enum): PULL = 1 PUSH = 2 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_http_queue = proto.Field( - proto.MESSAGE, number=3, oneof="queue_type", message=target.AppEngineHttpQueue, + proto.MESSAGE, + number=3, + oneof="queue_type", + message=target.AppEngineHttpQueue, + ) + rate_limits = proto.Field( + proto.MESSAGE, + number=4, + message="RateLimits", + ) + retry_config = proto.Field( + proto.MESSAGE, + number=5, + message="RetryConfig", + ) + state = proto.Field( + proto.ENUM, + number=6, + enum=State, + ) + purge_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + task_ttl = proto.Field( + proto.MESSAGE, + number=8, + message=duration_pb2.Duration, + ) + tombstone_ttl = proto.Field( + proto.MESSAGE, + number=9, + message=duration_pb2.Duration, ) - rate_limits = proto.Field(proto.MESSAGE, number=4, message="RateLimits",) - retry_config = proto.Field(proto.MESSAGE, number=5, message="RetryConfig",) - state = proto.Field(proto.ENUM, number=6, enum=State,) - purge_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) - task_ttl = proto.Field(proto.MESSAGE, number=8, message=duration_pb2.Duration,) - tombstone_ttl = proto.Field(proto.MESSAGE, number=9, message=duration_pb2.Duration,) stackdriver_logging_config = proto.Field( - proto.MESSAGE, number=10, message="StackdriverLoggingConfig", + proto.MESSAGE, + number=10, + message="StackdriverLoggingConfig", + ) + type_ = proto.Field( + proto.ENUM, + number=11, + enum=Type, + ) + stats = proto.Field( + proto.MESSAGE, + number=12, + message="QueueStats", ) - type_ = proto.Field(proto.ENUM, number=11, enum=Type,) - stats = proto.Field(proto.MESSAGE, number=12, message="QueueStats",) class RateLimits(proto.Message): @@ -298,9 +337,18 @@ class RateLimits(proto.Message): queue.yaml/xml `__. """ - max_dispatches_per_second = proto.Field(proto.DOUBLE, number=1,) - max_burst_size = proto.Field(proto.INT32, number=2,) - max_concurrent_dispatches = proto.Field(proto.INT32, number=3,) + max_dispatches_per_second = proto.Field( + proto.DOUBLE, + number=1, + ) + max_burst_size = proto.Field( + proto.INT32, + number=2, + ) + max_concurrent_dispatches = proto.Field( + proto.INT32, + number=3, + ) class RetryConfig(proto.Message): @@ -411,13 +459,29 @@ class RetryConfig(proto.Message): queue.yaml/xml `__. """ - max_attempts = proto.Field(proto.INT32, number=1,) + max_attempts = proto.Field( + proto.INT32, + number=1, + ) max_retry_duration = proto.Field( - proto.MESSAGE, number=2, message=duration_pb2.Duration, + proto.MESSAGE, + number=2, + message=duration_pb2.Duration, + ) + min_backoff = proto.Field( + proto.MESSAGE, + number=3, + message=duration_pb2.Duration, + ) + max_backoff = proto.Field( + proto.MESSAGE, + number=4, + message=duration_pb2.Duration, + ) + max_doublings = proto.Field( + proto.INT32, + number=5, ) - min_backoff = proto.Field(proto.MESSAGE, number=3, message=duration_pb2.Duration,) - max_backoff = proto.Field(proto.MESSAGE, number=4, message=duration_pb2.Duration,) - max_doublings = proto.Field(proto.INT32, number=5,) class StackdriverLoggingConfig(proto.Message): @@ -433,7 +497,10 @@ class StackdriverLoggingConfig(proto.Message): 0.0 is the default and means that no operations are logged. """ - sampling_ratio = proto.Field(proto.DOUBLE, number=1,) + sampling_ratio = proto.Field( + proto.DOUBLE, + number=1, + ) class QueueStats(proto.Message): @@ -469,13 +536,27 @@ class QueueStats(proto.Message): tasks in the queue are targeting. """ - tasks_count = proto.Field(proto.INT64, number=1,) + tasks_count = proto.Field( + proto.INT64, + number=1, + ) oldest_estimated_arrival_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) + executed_last_minute_count = proto.Field( + proto.INT64, + number=3, + ) + concurrent_dispatches_count = proto.Field( + proto.INT64, + number=4, + ) + effective_execution_rate = proto.Field( + proto.DOUBLE, + number=5, ) - executed_last_minute_count = proto.Field(proto.INT64, number=3,) - concurrent_dispatches_count = proto.Field(proto.INT64, number=4,) - effective_execution_rate = proto.Field(proto.DOUBLE, number=5,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta3/types/target.py b/google/cloud/tasks_v2beta3/types/target.py index 365f6016..0268791f 100644 --- a/google/cloud/tasks_v2beta3/types/target.py +++ b/google/cloud/tasks_v2beta3/types/target.py @@ -15,7 +15,6 @@ # import proto # type: ignore - __protobuf__ = proto.module( package="google.cloud.tasks.v2beta3", manifest={ @@ -71,8 +70,14 @@ class PullMessage(proto.Message): returned by Cloud Tasks. """ - payload = proto.Field(proto.BYTES, number=1,) - tag = proto.Field(proto.STRING, number=2,) + payload = proto.Field( + proto.BYTES, + number=1, + ) + tag = proto.Field( + proto.STRING, + number=2, + ) class HttpRequest(proto.Message): @@ -135,7 +140,7 @@ class HttpRequest(proto.Message): http_method (google.cloud.tasks_v2beta3.types.HttpMethod): The HTTP method to use for the request. The default is POST. - headers (Sequence[google.cloud.tasks_v2beta3.types.HttpRequest.HeadersEntry]): + headers (Mapping[str, str]): HTTP request headers. This map contains the header field names and values. Headers @@ -199,15 +204,35 @@ class HttpRequest(proto.Message): This field is a member of `oneof`_ ``authorization_header``. """ - url = proto.Field(proto.STRING, number=1,) - http_method = proto.Field(proto.ENUM, number=2, enum="HttpMethod",) - headers = proto.MapField(proto.STRING, proto.STRING, number=3,) - body = proto.Field(proto.BYTES, number=4,) + url = proto.Field( + proto.STRING, + number=1, + ) + http_method = proto.Field( + proto.ENUM, + number=2, + enum="HttpMethod", + ) + headers = proto.MapField( + proto.STRING, + proto.STRING, + number=3, + ) + body = proto.Field( + proto.BYTES, + number=4, + ) oauth_token = proto.Field( - proto.MESSAGE, number=5, oneof="authorization_header", message="OAuthToken", + proto.MESSAGE, + number=5, + oneof="authorization_header", + message="OAuthToken", ) oidc_token = proto.Field( - proto.MESSAGE, number=6, oneof="authorization_header", message="OidcToken", + proto.MESSAGE, + number=6, + oneof="authorization_header", + message="OidcToken", ) @@ -243,7 +268,9 @@ class AppEngineHttpQueue(proto.Message): """ app_engine_routing_override = proto.Field( - proto.MESSAGE, number=1, message="AppEngineRouting", + proto.MESSAGE, + number=1, + message="AppEngineRouting", ) @@ -339,7 +366,7 @@ class AppEngineHttpRequest(proto.Message): is empty, then the root path "/" will be used. No spaces are allowed, and the maximum length allowed is 2083 characters. - headers (Sequence[google.cloud.tasks_v2beta3.types.AppEngineHttpRequest.HeadersEntry]): + headers (Mapping[str, str]): HTTP request headers. This map contains the header field names and values. Headers @@ -399,13 +426,29 @@ class AppEngineHttpRequest(proto.Message): [HttpMethod][google.cloud.tasks.v2beta3.HttpMethod]. """ - http_method = proto.Field(proto.ENUM, number=1, enum="HttpMethod",) + http_method = proto.Field( + proto.ENUM, + number=1, + enum="HttpMethod", + ) app_engine_routing = proto.Field( - proto.MESSAGE, number=2, message="AppEngineRouting", + proto.MESSAGE, + number=2, + message="AppEngineRouting", + ) + relative_uri = proto.Field( + proto.STRING, + number=3, + ) + headers = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + body = proto.Field( + proto.BYTES, + number=5, ) - relative_uri = proto.Field(proto.STRING, number=3,) - headers = proto.MapField(proto.STRING, proto.STRING, number=4,) - body = proto.Field(proto.BYTES, number=5,) class AppEngineRouting(proto.Message): @@ -504,10 +547,22 @@ class AppEngineRouting(proto.Message): Routed `__. """ - service = proto.Field(proto.STRING, number=1,) - version = proto.Field(proto.STRING, number=2,) - instance = proto.Field(proto.STRING, number=3,) - host = proto.Field(proto.STRING, number=4,) + service = proto.Field( + proto.STRING, + number=1, + ) + version = proto.Field( + proto.STRING, + number=2, + ) + instance = proto.Field( + proto.STRING, + number=3, + ) + host = proto.Field( + proto.STRING, + number=4, + ) class OAuthToken(proto.Message): @@ -531,8 +586,14 @@ class OAuthToken(proto.Message): will be used. """ - service_account_email = proto.Field(proto.STRING, number=1,) - scope = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field( + proto.STRING, + number=1, + ) + scope = proto.Field( + proto.STRING, + number=2, + ) class OidcToken(proto.Message): @@ -556,8 +617,14 @@ class OidcToken(proto.Message): target will be used. """ - service_account_email = proto.Field(proto.STRING, number=1,) - audience = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field( + proto.STRING, + number=1, + ) + audience = proto.Field( + proto.STRING, + number=2, + ) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/google/cloud/tasks_v2beta3/types/task.py b/google/cloud/tasks_v2beta3/types/task.py index d5edc2e1..6f651136 100644 --- a/google/cloud/tasks_v2beta3/types/task.py +++ b/google/cloud/tasks_v2beta3/types/task.py @@ -13,16 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import proto # type: ignore - -from google.cloud.tasks_v2beta3.types import target from google.protobuf import duration_pb2 # type: ignore from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore +import proto # type: ignore +from google.cloud.tasks_v2beta3.types import target __protobuf__ = proto.module( - package="google.cloud.tasks.v2beta3", manifest={"Task", "Attempt",}, + package="google.cloud.tasks.v2beta3", + manifest={ + "Task", + "Attempt", + }, ) @@ -177,7 +180,10 @@ class View(proto.Enum): BASIC = 1 FULL = 2 - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) app_engine_http_request = proto.Field( proto.MESSAGE, number=3, @@ -185,23 +191,55 @@ class View(proto.Enum): message=target.AppEngineHttpRequest, ) http_request = proto.Field( - proto.MESSAGE, number=11, oneof="payload_type", message=target.HttpRequest, + proto.MESSAGE, + number=11, + oneof="payload_type", + message=target.HttpRequest, ) pull_message = proto.Field( - proto.MESSAGE, number=13, oneof="payload_type", message=target.PullMessage, + proto.MESSAGE, + number=13, + oneof="payload_type", + message=target.PullMessage, ) schedule_time = proto.Field( - proto.MESSAGE, number=4, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=4, + message=timestamp_pb2.Timestamp, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, ) - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) dispatch_deadline = proto.Field( - proto.MESSAGE, number=12, message=duration_pb2.Duration, + proto.MESSAGE, + number=12, + message=duration_pb2.Duration, + ) + dispatch_count = proto.Field( + proto.INT32, + number=6, + ) + response_count = proto.Field( + proto.INT32, + number=7, + ) + first_attempt = proto.Field( + proto.MESSAGE, + number=8, + message="Attempt", + ) + last_attempt = proto.Field( + proto.MESSAGE, + number=9, + message="Attempt", + ) + view = proto.Field( + proto.ENUM, + number=10, + enum=View, ) - dispatch_count = proto.Field(proto.INT32, number=6,) - response_count = proto.Field(proto.INT32, number=7,) - first_attempt = proto.Field(proto.MESSAGE, number=8, message="Attempt",) - last_attempt = proto.Field(proto.MESSAGE, number=9, message="Attempt",) - view = proto.Field(proto.ENUM, number=10, enum=View,) class Attempt(proto.Message): @@ -233,15 +271,25 @@ class Attempt(proto.Message): """ schedule_time = proto.Field( - proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=1, + message=timestamp_pb2.Timestamp, ) dispatch_time = proto.Field( - proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, ) response_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + response_status = proto.Field( + proto.MESSAGE, + number=4, + message=status_pb2.Status, ) - response_status = proto.Field(proto.MESSAGE, number=4, message=status_pb2.Status,) __all__ = tuple(sorted(__protobuf__.manifest)) diff --git a/noxfile.py b/noxfile.py index 2a2001c4..7c1742d2 100644 --- a/noxfile.py +++ b/noxfile.py @@ -17,19 +17,45 @@ # Generated by synthtool. DO NOT EDIT! from __future__ import absolute_import + import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +83,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +95,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +127,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +185,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +236,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py index 1306d56f..a84db3d1 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py index 99b5f34f..c49cbd2b 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_GetIamPolicy_sync] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py index d6108a83..c52d4875 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py index 5373e5b6..330daba0 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_SetIamPolicy_sync] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py index 1f273ebb..8409351e 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = tasks_v2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py index 099c4f92..fcc97338 100644 --- a/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py +++ b/samples/generated_samples/cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2_generated_CloudTasks_TestIamPermissions_sync] from google.cloud import tasks_v2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = tasks_v2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py index 6a384194..5ae916f5 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py index 1524945b..62830712 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_sync] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py index d803ce86..e34d6d29 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py index e8005a23..e29f43e7 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_sync] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py index 73eb0ff1..45e195d9 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = tasks_v2beta2.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py index 0661f4e2..7190f75d 100644 --- a/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_sync] from google.cloud import tasks_v2beta2 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = tasks_v2beta2.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta2.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py index d435519e..db9eac0c 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_get_iam_policy(): @@ -32,7 +33,7 @@ async def sample_get_iam_policy(): client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py index f4e7df71..d968e9e7 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_sync] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_get_iam_policy(): @@ -32,7 +33,7 @@ def sample_get_iam_policy(): client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.GetIamPolicyRequest( + request = iam_policy_pb2.GetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py index 5ce31320..823611fe 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_set_iam_policy(): @@ -32,7 +33,7 @@ async def sample_set_iam_policy(): client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py index 5c1fccd2..606c9ef5 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_sync] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_set_iam_policy(): @@ -32,7 +33,7 @@ def sample_set_iam_policy(): client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.SetIamPolicyRequest( + request = iam_policy_pb2.SetIamPolicyRequest( resource="resource_value", ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py index ec24330c..b75d922e 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore async def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ async def sample_test_iam_permissions(): client = tasks_v2beta3.CloudTasksAsyncClient() # Initialize request argument(s) - request = tasks_v2beta3.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py index c56bce7c..a6858325 100644 --- a/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py +++ b/samples/generated_samples/cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py @@ -25,6 +25,7 @@ # [START cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_sync] from google.cloud import tasks_v2beta3 +from google.iam.v1 import iam_policy_pb2 # type: ignore def sample_test_iam_permissions(): @@ -32,7 +33,7 @@ def sample_test_iam_permissions(): client = tasks_v2beta3.CloudTasksClient() # Initialize request argument(s) - request = tasks_v2beta3.TestIamPermissionsRequest( + request = iam_policy_pb2.TestIamPermissionsRequest( resource="resource_value", permissions=['permissions_value_1', 'permissions_value_2'], ) diff --git a/samples/generated_samples/snippet_metadata_tasks_v2.json b/samples/generated_samples/snippet_metadata_tasks_v2.json index 28db6c6f..e18f50b8 100644 --- a/samples/generated_samples/snippet_metadata_tasks_v2.json +++ b/samples/generated_samples/snippet_metadata_tasks_v2.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2", + "version": "v2" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateQueue_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_create_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateQueue_sync", "segments": [ { @@ -87,19 +176,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_create_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateTask_async", "segments": [ { @@ -132,18 +261,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_create_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_CreateTask_sync", "segments": [ { @@ -176,19 +345,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_create_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteQueue_async", "segments": [ { @@ -219,18 +423,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteQueue_sync", "segments": [ { @@ -261,19 +500,54 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteTask_async", "segments": [ { @@ -304,18 +578,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_DeleteTask_sync", "segments": [ { @@ -346,108 +655,216 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_delete_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetQueue_async", "segments": [ { @@ -480,18 +897,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetQueue_sync", "segments": [ { @@ -524,19 +977,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetTask_async", "segments": [ { @@ -569,18 +1058,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_GetTask_sync", "segments": [ { @@ -613,19 +1138,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_get_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ListQueues_async", "segments": [ { @@ -658,18 +1219,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_list_queues_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ListQueues_sync", "segments": [ { @@ -702,19 +1299,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_list_queues_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ListTasks_async", "segments": [ { @@ -747,18 +1380,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_list_tasks_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ListTasks_sync", "segments": [ { @@ -791,19 +1460,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_list_tasks_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_PauseQueue_async", "segments": [ { @@ -836,18 +1541,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_pause_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_PauseQueue_sync", "segments": [ { @@ -880,19 +1621,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_pause_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_PurgeQueue_async", "segments": [ { @@ -925,18 +1702,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_purge_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_PurgeQueue_sync", "segments": [ { @@ -969,19 +1782,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_purge_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ResumeQueue_async", "segments": [ { @@ -1014,18 +1863,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_resume_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_ResumeQueue_sync", "segments": [ { @@ -1058,19 +1943,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_resume_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_RunTask_async", "segments": [ { @@ -1103,18 +2024,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_run_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_RunTask_sync", "segments": [ { @@ -1147,197 +2104,389 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_run_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksAsyncClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_UpdateQueue_async", "segments": [ { @@ -1370,18 +2519,58 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_update_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2.CloudTasksClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2_generated_CloudTasks_UpdateQueue_sync", "segments": [ { @@ -1414,7 +2603,8 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2_generated_cloud_tasks_update_queue_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_tasks_v2beta2.json b/samples/generated_samples/snippet_metadata_tasks_v2beta2.json index 6a9ecff7..d10feda0 100644 --- a/samples/generated_samples/snippet_metadata_tasks_v2beta2.json +++ b/samples/generated_samples/snippet_metadata_tasks_v2beta2.json @@ -1,16 +1,64 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2beta2", + "version": "v2beta2" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.acknowledge_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "AcknowledgeTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "acknowledge_task" }, + "description": "Sample for AcknowledgeTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_async", "segments": [ { @@ -41,18 +89,57 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.acknowledge_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.AcknowledgeTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "AcknowledgeTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "acknowledge_task" }, + "description": "Sample for AcknowledgeTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_AcknowledgeTask_sync", "segments": [ { @@ -83,19 +170,59 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_acknowledge_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.cancel_lease", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CancelLease", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CancelLease" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CancelLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "cancel_lease" }, + "description": "Sample for CancelLease", "file": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CancelLease_async", "segments": [ { @@ -128,18 +255,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.cancel_lease", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CancelLease", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CancelLease" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CancelLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "cancel_lease" }, + "description": "Sample for CancelLease", "file": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CancelLease_sync", "segments": [ { @@ -172,19 +339,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_cancel_lease_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_async", "segments": [ { @@ -217,18 +424,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateQueue_sync", "segments": [ { @@ -261,19 +508,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_create_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateTask_async", "segments": [ { @@ -306,18 +593,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta2.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_CreateTask_sync", "segments": [ { @@ -350,19 +677,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_create_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_async", "segments": [ { @@ -393,18 +755,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteQueue_sync", "segments": [ { @@ -435,19 +832,54 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_async", "segments": [ { @@ -478,18 +910,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_DeleteTask_sync", "segments": [ { @@ -520,108 +987,216 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_delete_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetQueue_async", "segments": [ { @@ -654,18 +1229,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetQueue_sync", "segments": [ { @@ -698,19 +1309,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetTask_async", "segments": [ { @@ -743,18 +1390,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_GetTask_sync", "segments": [ { @@ -787,19 +1470,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_get_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.lease_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "LeaseTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.LeaseTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", + "shortName": "lease_tasks" }, + "description": "Sample for LeaseTasks", "file": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_async", "segments": [ { @@ -832,18 +1555,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.lease_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "LeaseTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.LeaseTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.LeaseTasksResponse", + "shortName": "lease_tasks" }, + "description": "Sample for LeaseTasks", "file": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_LeaseTasks_sync", "segments": [ { @@ -876,19 +1639,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_lease_tasks_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListQueues_async", "segments": [ { @@ -921,18 +1720,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListQueues_sync", "segments": [ { @@ -965,19 +1800,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_list_queues_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListTasks_async", "segments": [ { @@ -1010,18 +1881,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ListTasks_sync", "segments": [ { @@ -1054,19 +1961,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_list_tasks_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_async", "segments": [ { @@ -1099,18 +2042,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PauseQueue_sync", "segments": [ { @@ -1143,19 +2122,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_pause_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_async", "segments": [ { @@ -1188,18 +2203,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_PurgeQueue_sync", "segments": [ { @@ -1232,19 +2283,63 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_purge_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.renew_lease", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RenewLease", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RenewLease" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RenewLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "renew_lease" }, + "description": "Sample for RenewLease", "file": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RenewLease_async", "segments": [ { @@ -1277,18 +2372,62 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.renew_lease", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RenewLease", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RenewLease" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RenewLeaseRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "schedule_time", + "type": "google.protobuf.timestamp_pb2.Timestamp" + }, + { + "name": "lease_duration", + "type": "google.protobuf.duration_pb2.Duration" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "renew_lease" }, + "description": "Sample for RenewLease", "file": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RenewLease_sync", "segments": [ { @@ -1321,19 +2460,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_renew_lease_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_async", "segments": [ { @@ -1366,18 +2541,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_ResumeQueue_sync", "segments": [ { @@ -1410,19 +2621,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_resume_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RunTask_async", "segments": [ { @@ -1455,18 +2702,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_RunTask_sync", "segments": [ { @@ -1499,197 +2782,389 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_run_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksAsyncClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_async", "segments": [ { @@ -1722,18 +3197,58 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta2.CloudTasksClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta2.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta2.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta2.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta2.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta2_generated_CloudTasks_UpdateQueue_sync", "segments": [ { @@ -1766,7 +3281,8 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta2_generated_cloud_tasks_update_queue_sync.py" } ] } diff --git a/samples/generated_samples/snippet_metadata_tasks_v2beta3.json b/samples/generated_samples/snippet_metadata_tasks_v2beta3.json index bdf96c42..c84d1a51 100644 --- a/samples/generated_samples/snippet_metadata_tasks_v2beta3.json +++ b/samples/generated_samples/snippet_metadata_tasks_v2beta3.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.cloud.tasks.v2beta3", + "version": "v2beta3" + } + ], + "language": "PYTHON", + "name": "google-cloud-tasks" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.create_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateQueueRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "create_queue" }, + "description": "Sample for CreateQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateQueue_sync", "segments": [ { @@ -87,19 +176,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_create_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta3.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateTask_async", "segments": [ { @@ -132,18 +261,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.create_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.CreateTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "CreateTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.CreateTaskRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "task", + "type": "google.cloud.tasks_v2beta3.types.Task" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "create_task" }, + "description": "Sample for CreateTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_CreateTask_sync", "segments": [ { @@ -176,19 +345,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_create_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_async", "segments": [ { @@ -219,18 +423,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.delete_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_queue" }, + "description": "Sample for DeleteQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteQueue_sync", "segments": [ { @@ -261,19 +500,54 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_async", "segments": [ { @@ -304,18 +578,53 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.delete_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.DeleteTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "DeleteTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.DeleteTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_task" }, + "description": "Sample for DeleteTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_DeleteTask_sync", "segments": [ { @@ -346,108 +655,216 @@ "end": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_delete_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.GetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "get_iam_policy" }, + "description": "Sample for GetIamPolicy", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetQueue_async", "segments": [ { @@ -480,18 +897,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "get_queue" }, + "description": "Sample for GetQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetQueue_sync", "segments": [ { @@ -524,19 +977,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetTask_async", "segments": [ { @@ -569,18 +1058,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.get_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.GetTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "GetTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.GetTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "get_task" }, + "description": "Sample for GetTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_GetTask_sync", "segments": [ { @@ -613,19 +1138,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_get_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesAsyncPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListQueues_async", "segments": [ { @@ -658,18 +1219,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.list_queues", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListQueues", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListQueues" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListQueuesRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListQueuesPager", + "shortName": "list_queues" }, + "description": "Sample for ListQueues", "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListQueues_sync", "segments": [ { @@ -702,19 +1299,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_list_queues_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksAsyncPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListTasks_async", "segments": [ { @@ -747,18 +1380,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.list_tasks", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ListTasks", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ListTasks" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ListTasksRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.services.cloud_tasks.pagers.ListTasksPager", + "shortName": "list_tasks" }, + "description": "Sample for ListTasks", "file": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ListTasks_sync", "segments": [ { @@ -791,19 +1460,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_list_tasks_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_async", "segments": [ { @@ -836,18 +1541,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.pause_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PauseQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PauseQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PauseQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "pause_queue" }, + "description": "Sample for PauseQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PauseQueue_sync", "segments": [ { @@ -880,19 +1621,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_pause_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_async", "segments": [ { @@ -925,18 +1702,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.purge_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.PurgeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "PurgeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.PurgeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "purge_queue" }, + "description": "Sample for PurgeQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_PurgeQueue_sync", "segments": [ { @@ -969,19 +1782,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_purge_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_async", "segments": [ { @@ -1014,18 +1863,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.resume_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.ResumeQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "ResumeQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.ResumeQueueRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "resume_queue" }, + "description": "Sample for ResumeQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_ResumeQueue_sync", "segments": [ { @@ -1058,19 +1943,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_resume_queue_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_RunTask_async", "segments": [ { @@ -1103,18 +2024,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.run_task", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.RunTask", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "RunTask" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.RunTaskRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Task", + "shortName": "run_task" }, + "description": "Sample for RunTask", "file": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_RunTask_sync", "segments": [ { @@ -1147,197 +2104,389 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_run_task_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_async", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.set_iam_policy", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.SetIamPolicy", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "SetIamPolicy" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.SetIamPolicyRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.policy_pb2.Policy", + "shortName": "set_iam_policy" }, + "description": "Sample for SetIamPolicy", "file": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_SetIamPolicy_sync", "segments": [ { - "end": 44, + "end": 45, "start": 27, "type": "FULL" }, { - "end": 44, + "end": 45, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 38, - "start": 34, + "end": 39, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 41, - "start": 39, + "end": 42, + "start": 40, "type": "REQUEST_EXECUTION" }, { - "end": 45, - "start": 42, + "end": 46, + "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_set_iam_policy_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_async", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.test_iam_permissions", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.TestIamPermissions", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "TestIamPermissions" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest" + }, + { + "name": "resource", + "type": "str" + }, + { + "name": "permissions", + "type": "Sequence[str]" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.iam.v1.iam_policy_pb2.TestIamPermissionsResponse", + "shortName": "test_iam_permissions" }, + "description": "Sample for TestIamPermissions", "file": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_TestIamPermissions_sync", "segments": [ { - "end": 45, + "end": 46, "start": 27, "type": "FULL" }, { - "end": 45, + "end": 46, "start": 27, "type": "SHORT" }, { - "end": 33, - "start": 31, + "end": 34, + "start": 32, "type": "CLIENT_INITIALIZATION" }, { - "end": 39, - "start": 34, + "end": 40, + "start": 35, "type": "REQUEST_INITIALIZATION" }, { - "end": 42, - "start": 40, + "end": 43, + "start": 41, "type": "REQUEST_EXECUTION" }, { - "end": 46, - "start": 43, + "end": 47, + "start": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_test_iam_permissions_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient", + "shortName": "CloudTasksAsyncClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksAsyncClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_async", "segments": [ { @@ -1370,18 +2519,58 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient", + "shortName": "CloudTasksClient" + }, + "fullName": "google.cloud.tasks_v2beta3.CloudTasksClient.update_queue", "method": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks.UpdateQueue", "service": { + "fullName": "google.cloud.tasks.v2beta3.CloudTasks", "shortName": "CloudTasks" }, "shortName": "UpdateQueue" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.tasks_v2beta3.types.UpdateQueueRequest" + }, + { + "name": "queue", + "type": "google.cloud.tasks_v2beta3.types.Queue" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.tasks_v2beta3.types.Queue", + "shortName": "update_queue" }, + "description": "Sample for UpdateQueue", "file": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudtasks_v2beta3_generated_CloudTasks_UpdateQueue_sync", "segments": [ { @@ -1414,7 +2603,8 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudtasks_v2beta3_generated_cloud_tasks_update_queue_sync.py" } ] } diff --git a/samples/snippets/create_http_task.py b/samples/snippets/create_http_task.py index 40e735b3..13057fa8 100644 --- a/samples/snippets/create_http_task.py +++ b/samples/snippets/create_http_task.py @@ -30,11 +30,12 @@ def create_http_task( # [START cloud_tasks_create_http_task] """Create a task for a given queue with an arbitrary payload.""" - from google.cloud import tasks_v2 - from google.protobuf import timestamp_pb2, duration_pb2 import datetime import json + from google.cloud import tasks_v2 + from google.protobuf import duration_pb2, timestamp_pb2 + # Create a client. client = tasks_v2.CloudTasksClient() @@ -106,7 +107,9 @@ def create_http_task( ) parser.add_argument( - "--project", help="Project of the queue to add the task to.", required=True, + "--project", + help="Project of the queue to add the task to.", + required=True, ) parser.add_argument( @@ -116,7 +119,9 @@ def create_http_task( ) parser.add_argument( - "--location", help="Location of the queue to add the task to.", required=True, + "--location", + help="Location of the queue to add the task to.", + required=True, ) parser.add_argument( diff --git a/samples/snippets/create_http_task_with_token.py b/samples/snippets/create_http_task_with_token.py index 88888bcd..0e157eb9 100644 --- a/samples/snippets/create_http_task_with_token.py +++ b/samples/snippets/create_http_task_with_token.py @@ -16,7 +16,13 @@ def create_http_task( - project, queue, location, url, service_account_email, audience=None, payload=None, + project, + queue, + location, + url, + service_account_email, + audience=None, + payload=None, ): # [START cloud_tasks_create_http_task_with_token] """Create a task for a given queue with an arbitrary payload.""" diff --git a/samples/snippets/delete_queue_test.py b/samples/snippets/delete_queue_test.py index e814c910..0d1914e8 100644 --- a/samples/snippets/delete_queue_test.py +++ b/samples/snippets/delete_queue_test.py @@ -21,7 +21,6 @@ import delete_queue - TEST_PROJECT_ID = os.environ["GOOGLE_CLOUD_PROJECT"] TEST_LOCATION = os.getenv("TEST_QUEUE_LOCATION", "us-central1") TEST_QUEUE_NAME = f"my-queue-{uuid.uuid4().hex}" diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 85f5836d..3b3ffa5d 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -22,14 +22,14 @@ import nox - # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING # DO NOT EDIT THIS FILE EVER! # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +168,33 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # @@ -253,7 +274,7 @@ def py(session: nox.sessions.Session) -> None: def _get_repo_root() -> Optional[str]: - """ Returns the root folder of the project. """ + """Returns the root folder of the project.""" # Get root of this repository. Assume we don't have directories nested deeper than 10 items. p = Path(os.getcwd()) for i in range(10): diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index c2845bff..d00689e0 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.1 +pytest==7.1.2 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index d5240056..f2b4ae7f 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-tasks==2.8.0 +google-cloud-tasks==2.8.1 diff --git a/scripts/fixup_tasks_v2_keywords.py b/scripts/fixup_tasks_v2_keywords.py index feccd76d..f5b33f8c 100644 --- a/scripts/fixup_tasks_v2_keywords.py +++ b/scripts/fixup_tasks_v2_keywords.py @@ -52,7 +52,7 @@ class tasksCallTransformer(cst.CSTTransformer): 'purge_queue': ('name', ), 'resume_queue': ('name', ), 'run_task': ('name', 'response_view', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_queue': ('queue', 'update_mask', ), } diff --git a/scripts/fixup_tasks_v2beta2_keywords.py b/scripts/fixup_tasks_v2beta2_keywords.py index 40c04cdf..e13de3c1 100644 --- a/scripts/fixup_tasks_v2beta2_keywords.py +++ b/scripts/fixup_tasks_v2beta2_keywords.py @@ -56,7 +56,7 @@ class tasksCallTransformer(cst.CSTTransformer): 'renew_lease': ('name', 'schedule_time', 'lease_duration', 'response_view', ), 'resume_queue': ('name', ), 'run_task': ('name', 'response_view', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_queue': ('queue', 'update_mask', ), } diff --git a/scripts/fixup_tasks_v2beta3_keywords.py b/scripts/fixup_tasks_v2beta3_keywords.py index 174560db..a7bb30b7 100644 --- a/scripts/fixup_tasks_v2beta3_keywords.py +++ b/scripts/fixup_tasks_v2beta3_keywords.py @@ -52,7 +52,7 @@ class tasksCallTransformer(cst.CSTTransformer): 'purge_queue': ('name', ), 'resume_queue': ('name', ), 'run_task': ('name', 'response_view', ), - 'set_iam_policy': ('resource', 'policy', ), + 'set_iam_policy': ('resource', 'policy', 'update_mask', ), 'test_iam_permissions': ('resource', 'permissions', ), 'update_queue': ('queue', 'update_mask', ), } diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e9..91b59676 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index 2a967acc..a447bd0f 100644 --- a/setup.py +++ b/setup.py @@ -21,14 +21,14 @@ name = "google-cloud-tasks" description = "Cloud Tasks API API client library" -version = "2.8.1" +version = "2.9.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x # Until this issue is closed # https://github.com/googleapis/google-cloud-python/issues/10566 "google-api-core[grpc] >= 1.31.5, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.0", - "grpc-google-iam-v1 >= 0.12.3, < 0.13dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", "proto-plus >= 1.15.0", ] diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 3755c967..654ad19f 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -6,6 +6,6 @@ # e.g., if setup.py has "foo >= 1.14.0, < 2.0.0dev", # Then this file should have foo==1.14.0 google-api-core==1.31.5 -grpc-google-iam-v1==0.12.3 +grpc-google-iam-v1==0.12.4 proto-plus==1.15.0 libcst==0.2.5 diff --git a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py index b38f272d..35dda73e 100644 --- a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py @@ -13,34 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.tasks_v2.services.cloud_tasks import CloudTasksAsyncClient -from google.cloud.tasks_v2.services.cloud_tasks import CloudTasksClient -from google.cloud.tasks_v2.services.cloud_tasks import pagers -from google.cloud.tasks_v2.services.cloud_tasks import transports -from google.cloud.tasks_v2.types import cloudtasks -from google.cloud.tasks_v2.types import queue -from google.cloud.tasks_v2.types import queue as gct_queue -from google.cloud.tasks_v2.types import target -from google.cloud.tasks_v2.types import task -from google.cloud.tasks_v2.types import task as gct_task from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -51,7 +32,24 @@ from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.type import expr_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.tasks_v2.services.cloud_tasks import ( + CloudTasksAsyncClient, + CloudTasksClient, + pagers, + transports, +) +from google.cloud.tasks_v2.types import cloudtasks +from google.cloud.tasks_v2.types import queue +from google.cloud.tasks_v2.types import queue as gct_queue +from google.cloud.tasks_v2.types import target +from google.cloud.tasks_v2.types import task +from google.cloud.tasks_v2.types import task as gct_task def client_cert_source_callback(): @@ -95,19 +93,25 @@ def test__get_default_mtls_endpoint(): assert CloudTasksClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") @pytest.mark.parametrize( @@ -135,22 +139,32 @@ def test_cloud_tasks_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") def test_cloud_tasks_client_get_transport_class(): @@ -490,7 +504,9 @@ def test_cloud_tasks_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -618,10 +634,17 @@ def test_cloud_tasks_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListQueuesRequest, + dict, + ], +) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -650,7 +673,8 @@ def test_list_queues_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -666,7 +690,8 @@ async def test_list_queues_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListQueuesRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -677,7 +702,9 @@ async def test_list_queues_async( with mock.patch.object(type(client.transport.list_queues), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListQueuesResponse(next_page_token="next_page_token_value",) + cloudtasks.ListQueuesResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_queues(request) @@ -697,13 +724,15 @@ async def test_list_queues_async_from_dict(): def test_list_queues_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -717,18 +746,23 @@ def test_list_queues_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_queues_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -744,11 +778,16 @@ async def test_list_queues_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_queues_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -756,7 +795,9 @@ def test_list_queues_flattened(): call.return_value = cloudtasks.ListQueuesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_queues(parent="parent_value",) + client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -768,19 +809,24 @@ def test_list_queues_flattened(): def test_list_queues_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_queues_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -792,7 +838,9 @@ async def test_list_queues_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_queues(parent="parent_value",) + response = await client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -805,19 +853,23 @@ async def test_list_queues_flattened_async(): @pytest.mark.asyncio async def test_list_queues_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) def test_list_queues_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -825,14 +877,29 @@ def test_list_queues_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) @@ -844,14 +911,15 @@ def test_list_queues_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, queue.Queue) for i in results) def test_list_queues_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -859,14 +927,29 @@ def test_list_queues_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = list(client.list_queues(request={}).pages) @@ -876,7 +959,9 @@ def test_list_queues_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_queues_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -885,20 +970,37 @@ async def test_list_queues_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) - async_pager = await client.list_queues(request={},) + async_pager = await client.list_queues( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -907,7 +1009,9 @@ async def test_list_queues_async_pager(): @pytest.mark.asyncio async def test_list_queues_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -916,27 +1020,51 @@ async def test_list_queues_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_queues(request={})).pages: + async for page_ in ( + await client.list_queues(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetQueueRequest, + dict, + ], +) def test_get_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -947,7 +1075,8 @@ def test_get_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.get_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = queue.Queue( - name="name_value", state=queue.Queue.State.RUNNING, + name="name_value", + state=queue.Queue.State.RUNNING, ) response = client.get_queue(request) @@ -966,7 +1095,8 @@ def test_get_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -982,7 +1112,8 @@ async def test_get_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -993,7 +1124,10 @@ async def test_get_queue_async( with mock.patch.object(type(client.transport.get_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.get_queue(request) @@ -1014,13 +1148,15 @@ async def test_get_queue_async_from_dict(): def test_get_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1034,18 +1170,23 @@ def test_get_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1059,11 +1200,16 @@ async def test_get_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1071,7 +1217,9 @@ def test_get_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_queue(name="name_value",) + client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1083,19 +1231,24 @@ def test_get_queue_flattened(): def test_get_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1105,7 +1258,9 @@ async def test_get_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_queue(name="name_value",) + response = await client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1118,20 +1273,30 @@ async def test_get_queue_flattened_async(): @pytest.mark.asyncio async def test_get_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateQueueRequest, + dict, + ], +) def test_create_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1142,7 +1307,8 @@ def test_create_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.create_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_queue.Queue( - name="name_value", state=gct_queue.Queue.State.RUNNING, + name="name_value", + state=gct_queue.Queue.State.RUNNING, ) response = client.create_queue(request) @@ -1161,7 +1327,8 @@ def test_create_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1177,7 +1344,8 @@ async def test_create_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1188,7 +1356,10 @@ async def test_create_queue_async( with mock.patch.object(type(client.transport.create_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_queue.Queue(name="name_value", state=gct_queue.Queue.State.RUNNING,) + gct_queue.Queue( + name="name_value", + state=gct_queue.Queue.State.RUNNING, + ) ) response = await client.create_queue(request) @@ -1209,13 +1380,15 @@ async def test_create_queue_async_from_dict(): def test_create_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1229,18 +1402,23 @@ def test_create_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1254,11 +1432,16 @@ async def test_create_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1267,7 +1450,8 @@ def test_create_queue_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1283,7 +1467,9 @@ def test_create_queue_flattened(): def test_create_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1297,7 +1483,9 @@ def test_create_queue_flattened_error(): @pytest.mark.asyncio async def test_create_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1308,7 +1496,8 @@ async def test_create_queue_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1325,7 +1514,9 @@ async def test_create_queue_flattened_async(): @pytest.mark.asyncio async def test_create_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1337,10 +1528,17 @@ async def test_create_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.UpdateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.UpdateQueueRequest, + dict, + ], +) def test_update_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1351,7 +1549,8 @@ def test_update_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.update_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = gct_queue.Queue( - name="name_value", state=gct_queue.Queue.State.RUNNING, + name="name_value", + state=gct_queue.Queue.State.RUNNING, ) response = client.update_queue(request) @@ -1370,7 +1569,8 @@ def test_update_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1386,7 +1586,8 @@ async def test_update_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.UpdateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1397,7 +1598,10 @@ async def test_update_queue_async( with mock.patch.object(type(client.transport.update_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_queue.Queue(name="name_value", state=gct_queue.Queue.State.RUNNING,) + gct_queue.Queue( + name="name_value", + state=gct_queue.Queue.State.RUNNING, + ) ) response = await client.update_queue(request) @@ -1418,13 +1622,15 @@ async def test_update_queue_async_from_dict(): def test_update_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1438,18 +1644,23 @@ def test_update_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1463,11 +1674,16 @@ async def test_update_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] def test_update_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1493,7 +1709,9 @@ def test_update_queue_flattened(): def test_update_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1507,7 +1725,9 @@ def test_update_queue_flattened_error(): @pytest.mark.asyncio async def test_update_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1536,7 +1756,9 @@ async def test_update_queue_flattened_async(): @pytest.mark.asyncio async def test_update_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1548,10 +1770,17 @@ async def test_update_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteQueueRequest, + dict, + ], +) def test_delete_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1577,7 +1806,8 @@ def test_delete_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1593,7 +1823,8 @@ async def test_delete_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1621,13 +1852,15 @@ async def test_delete_queue_async_from_dict(): def test_delete_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1641,18 +1874,23 @@ def test_delete_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1666,11 +1904,16 @@ async def test_delete_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1678,7 +1921,9 @@ def test_delete_queue_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_queue(name="name_value",) + client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1690,19 +1935,24 @@ def test_delete_queue_flattened(): def test_delete_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1712,7 +1962,9 @@ async def test_delete_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_queue(name="name_value",) + response = await client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1725,20 +1977,30 @@ async def test_delete_queue_flattened_async(): @pytest.mark.asyncio async def test_delete_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PurgeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PurgeQueueRequest, + dict, + ], +) def test_purge_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1749,7 +2011,8 @@ def test_purge_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = queue.Queue( - name="name_value", state=queue.Queue.State.RUNNING, + name="name_value", + state=queue.Queue.State.RUNNING, ) response = client.purge_queue(request) @@ -1768,7 +2031,8 @@ def test_purge_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1784,7 +2048,8 @@ async def test_purge_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PurgeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1795,7 +2060,10 @@ async def test_purge_queue_async( with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.purge_queue(request) @@ -1816,13 +2084,15 @@ async def test_purge_queue_async_from_dict(): def test_purge_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1836,18 +2106,23 @@ def test_purge_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_purge_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1861,11 +2136,16 @@ async def test_purge_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_purge_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1873,7 +2153,9 @@ def test_purge_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.purge_queue(name="name_value",) + client.purge_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1885,19 +2167,24 @@ def test_purge_queue_flattened(): def test_purge_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_purge_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1907,7 +2194,9 @@ async def test_purge_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.purge_queue(name="name_value",) + response = await client.purge_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1920,20 +2209,30 @@ async def test_purge_queue_flattened_async(): @pytest.mark.asyncio async def test_purge_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PauseQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PauseQueueRequest, + dict, + ], +) def test_pause_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1944,7 +2243,8 @@ def test_pause_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = queue.Queue( - name="name_value", state=queue.Queue.State.RUNNING, + name="name_value", + state=queue.Queue.State.RUNNING, ) response = client.pause_queue(request) @@ -1963,7 +2263,8 @@ def test_pause_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1979,7 +2280,8 @@ async def test_pause_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PauseQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1990,7 +2292,10 @@ async def test_pause_queue_async( with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.pause_queue(request) @@ -2011,13 +2316,15 @@ async def test_pause_queue_async_from_dict(): def test_pause_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2031,18 +2338,23 @@ def test_pause_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_pause_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2056,11 +2368,16 @@ async def test_pause_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_pause_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2068,7 +2385,9 @@ def test_pause_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.pause_queue(name="name_value",) + client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2080,19 +2399,24 @@ def test_pause_queue_flattened(): def test_pause_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_pause_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2102,7 +2426,9 @@ async def test_pause_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.pause_queue(name="name_value",) + response = await client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2115,20 +2441,30 @@ async def test_pause_queue_flattened_async(): @pytest.mark.asyncio async def test_pause_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.ResumeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ResumeQueueRequest, + dict, + ], +) def test_resume_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2139,7 +2475,8 @@ def test_resume_queue(request_type, transport: str = "grpc"): with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = queue.Queue( - name="name_value", state=queue.Queue.State.RUNNING, + name="name_value", + state=queue.Queue.State.RUNNING, ) response = client.resume_queue(request) @@ -2158,7 +2495,8 @@ def test_resume_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2174,7 +2512,8 @@ async def test_resume_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ResumeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2185,7 +2524,10 @@ async def test_resume_queue_async( with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.resume_queue(request) @@ -2206,13 +2548,15 @@ async def test_resume_queue_async_from_dict(): def test_resume_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2226,18 +2570,23 @@ def test_resume_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_resume_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2251,11 +2600,16 @@ async def test_resume_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_resume_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2263,7 +2617,9 @@ def test_resume_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.resume_queue(name="name_value",) + client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2275,19 +2631,24 @@ def test_resume_queue_flattened(): def test_resume_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_resume_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2297,7 +2658,9 @@ async def test_resume_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.resume_queue(name="name_value",) + response = await client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2310,20 +2673,30 @@ async def test_resume_queue_flattened_async(): @pytest.mark.asyncio async def test_resume_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2333,7 +2706,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2351,7 +2727,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2367,7 +2744,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2378,7 +2756,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2399,13 +2780,15 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2419,18 +2802,23 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2444,11 +2832,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2463,7 +2856,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2471,7 +2866,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2483,19 +2880,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2505,7 +2907,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2518,20 +2922,30 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2541,7 +2955,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2559,7 +2976,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2575,7 +2993,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2586,7 +3005,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2607,13 +3029,15 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2627,18 +3051,23 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2652,11 +3081,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2665,13 +3099,16 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() def test_set_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2679,7 +3116,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2691,19 +3130,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2713,7 +3157,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2726,22 +3172,30 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2772,7 +3226,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2791,7 +3246,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2826,13 +3282,15 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2848,18 +3306,23 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2877,11 +3340,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2898,7 +3366,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2909,7 +3379,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2925,7 +3396,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2939,7 +3412,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2954,7 +3429,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2971,7 +3447,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2983,10 +3461,17 @@ async def test_test_iam_permissions_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListTasksRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListTasksRequest, + dict, + ], +) def test_list_tasks(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3015,7 +3500,8 @@ def test_list_tasks_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3031,7 +3517,8 @@ async def test_list_tasks_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListTasksRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3042,7 +3529,9 @@ async def test_list_tasks_async( with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListTasksResponse(next_page_token="next_page_token_value",) + cloudtasks.ListTasksResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_tasks(request) @@ -3062,13 +3551,15 @@ async def test_list_tasks_async_from_dict(): def test_list_tasks_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3082,18 +3573,23 @@ def test_list_tasks_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_tasks_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3109,11 +3605,16 @@ async def test_list_tasks_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_tasks_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3121,7 +3622,9 @@ def test_list_tasks_flattened(): call.return_value = cloudtasks.ListTasksResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_tasks(parent="parent_value",) + client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3133,19 +3636,24 @@ def test_list_tasks_flattened(): def test_list_tasks_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_tasks_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3157,7 +3665,9 @@ async def test_list_tasks_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_tasks(parent="parent_value",) + response = await client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3170,19 +3680,23 @@ async def test_list_tasks_flattened_async(): @pytest.mark.asyncio async def test_list_tasks_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) def test_list_tasks_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3190,11 +3704,29 @@ def test_list_tasks_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) @@ -3206,14 +3738,15 @@ def test_list_tasks_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, task.Task) for i in results) def test_list_tasks_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3221,11 +3754,29 @@ def test_list_tasks_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = list(client.list_tasks(request={}).pages) @@ -3235,7 +3786,9 @@ def test_list_tasks_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_tasks_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3244,17 +3797,37 @@ async def test_list_tasks_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) - async_pager = await client.list_tasks(request={},) + async_pager = await client.list_tasks( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -3263,7 +3836,9 @@ async def test_list_tasks_async_pager(): @pytest.mark.asyncio async def test_list_tasks_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3272,24 +3847,51 @@ async def test_list_tasks_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_tasks(request={})).pages: + async for page_ in ( + await client.list_tasks(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetTaskRequest, + dict, + ], +) def test_get_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3327,7 +3929,8 @@ def test_get_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3343,7 +3946,8 @@ async def test_get_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3382,13 +3986,15 @@ async def test_get_task_async_from_dict(): def test_get_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3402,18 +4008,23 @@ def test_get_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3427,11 +4038,16 @@ async def test_get_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3439,7 +4055,9 @@ def test_get_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_task(name="name_value",) + client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3451,19 +4069,24 @@ def test_get_task_flattened(): def test_get_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3473,7 +4096,9 @@ async def test_get_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_task(name="name_value",) + response = await client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3486,20 +4111,30 @@ async def test_get_task_flattened_async(): @pytest.mark.asyncio async def test_get_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateTaskRequest, + dict, + ], +) def test_create_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3537,7 +4172,8 @@ def test_create_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3553,7 +4189,8 @@ async def test_create_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3592,13 +4229,15 @@ async def test_create_task_async_from_dict(): def test_create_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3612,18 +4251,23 @@ def test_create_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3637,11 +4281,16 @@ async def test_create_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3650,7 +4299,8 @@ def test_create_task_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3666,7 +4316,9 @@ def test_create_task_flattened(): def test_create_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3680,7 +4332,9 @@ def test_create_task_flattened_error(): @pytest.mark.asyncio async def test_create_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3691,7 +4345,8 @@ async def test_create_task_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3708,7 +4363,9 @@ async def test_create_task_flattened_async(): @pytest.mark.asyncio async def test_create_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3720,10 +4377,17 @@ async def test_create_task_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteTaskRequest, + dict, + ], +) def test_delete_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3749,7 +4413,8 @@ def test_delete_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3765,7 +4430,8 @@ async def test_delete_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3793,13 +4459,15 @@ async def test_delete_task_async_from_dict(): def test_delete_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3813,18 +4481,23 @@ def test_delete_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3838,11 +4511,16 @@ async def test_delete_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3850,7 +4528,9 @@ def test_delete_task_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_task(name="name_value",) + client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3862,19 +4542,24 @@ def test_delete_task_flattened(): def test_delete_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3884,7 +4569,9 @@ async def test_delete_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_task(name="name_value",) + response = await client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3897,20 +4584,30 @@ async def test_delete_task_flattened_async(): @pytest.mark.asyncio async def test_delete_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.RunTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.RunTaskRequest, + dict, + ], +) def test_run_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3948,7 +4645,8 @@ def test_run_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3964,7 +4662,8 @@ async def test_run_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.RunTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4003,13 +4702,15 @@ async def test_run_task_async_from_dict(): def test_run_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4023,18 +4724,23 @@ def test_run_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_run_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4048,11 +4754,16 @@ async def test_run_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_run_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4060,7 +4771,9 @@ def test_run_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.run_task(name="name_value",) + client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4072,19 +4785,24 @@ def test_run_task_flattened(): def test_run_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_run_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4094,7 +4812,9 @@ async def test_run_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.run_task(name="name_value",) + response = await client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4107,13 +4827,16 @@ async def test_run_task_flattened_async(): @pytest.mark.asyncio async def test_run_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @@ -4124,7 +4847,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -4144,7 +4868,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudTasksClient(client_options=options, transport=transport,) + client = CloudTasksClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -4160,7 +4887,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -4190,7 +4918,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -4200,10 +4931,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = CloudTasksClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudTasksGrpcTransport,) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudTasksGrpcTransport, + ) def test_cloud_tasks_base_transport_error(): @@ -4252,6 +5001,14 @@ def test_cloud_tasks_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4263,7 +5020,8 @@ def test_cloud_tasks_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -4298,7 +5056,10 @@ def test_cloud_tasks_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -4390,24 +5151,40 @@ def test_cloud_tasks_grpc_transport_client_cert_source_for_mtls(transport_class) ) -def test_cloud_tasks_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_no_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") -def test_cloud_tasks_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_with_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:8000" + assert client.transport._host == ("cloudtasks.googleapis.com:8000") def test_cloud_tasks_grpc_transport_channel(): @@ -4415,7 +5192,8 @@ def test_cloud_tasks_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4427,7 +5205,8 @@ def test_cloud_tasks_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4531,7 +5310,9 @@ def test_queue_path(): location = "clam" queue = "whelk" expected = "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) actual = CloudTasksClient.queue_path(project, location, queue) assert expected == actual @@ -4555,8 +5336,13 @@ def test_task_path(): location = "mussel" queue = "winkle" task = "nautilus" - expected = "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + expected = ( + "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( + project=project, + location=location, + queue=queue, + task=task, + ) ) actual = CloudTasksClient.task_path(project, location, queue, task) assert expected == actual @@ -4598,7 +5384,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudTasksClient.common_folder_path(folder) assert expected == actual @@ -4616,7 +5404,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudTasksClient.common_organization_path(organization) assert expected == actual @@ -4634,7 +5424,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudTasksClient.common_project_path(project) assert expected == actual @@ -4654,7 +5446,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudTasksClient.common_location_path(project, location) assert expected == actual @@ -4679,7 +5472,8 @@ def test_client_with_default_client_info(): transports.CloudTasksTransport, "_prep_wrapped_messages" ) as prep: client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4688,7 +5482,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudTasksClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4696,7 +5491,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py index 94a3841f..ea08fcef 100644 --- a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py @@ -13,34 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.tasks_v2beta2.services.cloud_tasks import CloudTasksAsyncClient -from google.cloud.tasks_v2beta2.services.cloud_tasks import CloudTasksClient -from google.cloud.tasks_v2beta2.services.cloud_tasks import pagers -from google.cloud.tasks_v2beta2.services.cloud_tasks import transports -from google.cloud.tasks_v2beta2.types import cloudtasks -from google.cloud.tasks_v2beta2.types import queue -from google.cloud.tasks_v2beta2.types import queue as gct_queue -from google.cloud.tasks_v2beta2.types import target -from google.cloud.tasks_v2beta2.types import task -from google.cloud.tasks_v2beta2.types import task as gct_task from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -51,7 +32,24 @@ from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.type import expr_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.tasks_v2beta2.services.cloud_tasks import ( + CloudTasksAsyncClient, + CloudTasksClient, + pagers, + transports, +) +from google.cloud.tasks_v2beta2.types import cloudtasks +from google.cloud.tasks_v2beta2.types import queue +from google.cloud.tasks_v2beta2.types import queue as gct_queue +from google.cloud.tasks_v2beta2.types import target +from google.cloud.tasks_v2beta2.types import task +from google.cloud.tasks_v2beta2.types import task as gct_task def client_cert_source_callback(): @@ -95,19 +93,25 @@ def test__get_default_mtls_endpoint(): assert CloudTasksClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") @pytest.mark.parametrize( @@ -135,22 +139,32 @@ def test_cloud_tasks_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") def test_cloud_tasks_client_get_transport_class(): @@ -490,7 +504,9 @@ def test_cloud_tasks_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -618,10 +634,17 @@ def test_cloud_tasks_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListQueuesRequest, + dict, + ], +) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -650,7 +673,8 @@ def test_list_queues_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -666,7 +690,8 @@ async def test_list_queues_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListQueuesRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -677,7 +702,9 @@ async def test_list_queues_async( with mock.patch.object(type(client.transport.list_queues), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListQueuesResponse(next_page_token="next_page_token_value",) + cloudtasks.ListQueuesResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_queues(request) @@ -697,13 +724,15 @@ async def test_list_queues_async_from_dict(): def test_list_queues_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -717,18 +746,23 @@ def test_list_queues_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_queues_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -744,11 +778,16 @@ async def test_list_queues_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_queues_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -756,7 +795,9 @@ def test_list_queues_flattened(): call.return_value = cloudtasks.ListQueuesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_queues(parent="parent_value",) + client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -768,19 +809,24 @@ def test_list_queues_flattened(): def test_list_queues_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_queues_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -792,7 +838,9 @@ async def test_list_queues_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_queues(parent="parent_value",) + response = await client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -805,19 +853,23 @@ async def test_list_queues_flattened_async(): @pytest.mark.asyncio async def test_list_queues_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) def test_list_queues_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -825,14 +877,29 @@ def test_list_queues_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) @@ -844,14 +911,15 @@ def test_list_queues_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, queue.Queue) for i in results) def test_list_queues_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -859,14 +927,29 @@ def test_list_queues_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = list(client.list_queues(request={}).pages) @@ -876,7 +959,9 @@ def test_list_queues_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_queues_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -885,20 +970,37 @@ async def test_list_queues_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) - async_pager = await client.list_queues(request={},) + async_pager = await client.list_queues( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -907,7 +1009,9 @@ async def test_list_queues_async_pager(): @pytest.mark.asyncio async def test_list_queues_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -916,27 +1020,51 @@ async def test_list_queues_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_queues(request={})).pages: + async for page_ in ( + await client.list_queues(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetQueueRequest, + dict, + ], +) def test_get_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -972,7 +1100,8 @@ def test_get_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -988,7 +1117,8 @@ async def test_get_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -999,7 +1129,10 @@ async def test_get_queue_async( with mock.patch.object(type(client.transport.get_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.get_queue(request) @@ -1020,13 +1153,15 @@ async def test_get_queue_async_from_dict(): def test_get_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1040,18 +1175,23 @@ def test_get_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1065,11 +1205,16 @@ async def test_get_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1077,7 +1222,9 @@ def test_get_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_queue(name="name_value",) + client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1089,19 +1236,24 @@ def test_get_queue_flattened(): def test_get_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1111,7 +1263,9 @@ async def test_get_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_queue(name="name_value",) + response = await client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1124,20 +1278,30 @@ async def test_get_queue_flattened_async(): @pytest.mark.asyncio async def test_get_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateQueueRequest, + dict, + ], +) def test_create_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1173,7 +1337,8 @@ def test_create_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1189,7 +1354,8 @@ async def test_create_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1200,7 +1366,10 @@ async def test_create_queue_async( with mock.patch.object(type(client.transport.create_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_queue.Queue(name="name_value", state=gct_queue.Queue.State.RUNNING,) + gct_queue.Queue( + name="name_value", + state=gct_queue.Queue.State.RUNNING, + ) ) response = await client.create_queue(request) @@ -1221,13 +1390,15 @@ async def test_create_queue_async_from_dict(): def test_create_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1241,18 +1412,23 @@ def test_create_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1266,11 +1442,16 @@ async def test_create_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1279,7 +1460,8 @@ def test_create_queue_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1295,7 +1477,9 @@ def test_create_queue_flattened(): def test_create_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1309,7 +1493,9 @@ def test_create_queue_flattened_error(): @pytest.mark.asyncio async def test_create_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1320,7 +1506,8 @@ async def test_create_queue_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1337,7 +1524,9 @@ async def test_create_queue_flattened_async(): @pytest.mark.asyncio async def test_create_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1349,10 +1538,17 @@ async def test_create_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.UpdateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.UpdateQueueRequest, + dict, + ], +) def test_update_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1388,7 +1584,8 @@ def test_update_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1404,7 +1601,8 @@ async def test_update_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.UpdateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1415,7 +1613,10 @@ async def test_update_queue_async( with mock.patch.object(type(client.transport.update_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_queue.Queue(name="name_value", state=gct_queue.Queue.State.RUNNING,) + gct_queue.Queue( + name="name_value", + state=gct_queue.Queue.State.RUNNING, + ) ) response = await client.update_queue(request) @@ -1436,13 +1637,15 @@ async def test_update_queue_async_from_dict(): def test_update_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1456,18 +1659,23 @@ def test_update_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1481,11 +1689,16 @@ async def test_update_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] def test_update_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1511,7 +1724,9 @@ def test_update_queue_flattened(): def test_update_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1525,7 +1740,9 @@ def test_update_queue_flattened_error(): @pytest.mark.asyncio async def test_update_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1554,7 +1771,9 @@ async def test_update_queue_flattened_async(): @pytest.mark.asyncio async def test_update_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1566,10 +1785,17 @@ async def test_update_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteQueueRequest, + dict, + ], +) def test_delete_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1595,7 +1821,8 @@ def test_delete_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1611,7 +1838,8 @@ async def test_delete_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1639,13 +1867,15 @@ async def test_delete_queue_async_from_dict(): def test_delete_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1659,18 +1889,23 @@ def test_delete_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1684,11 +1919,16 @@ async def test_delete_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1696,7 +1936,9 @@ def test_delete_queue_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_queue(name="name_value",) + client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1708,19 +1950,24 @@ def test_delete_queue_flattened(): def test_delete_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1730,7 +1977,9 @@ async def test_delete_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_queue(name="name_value",) + response = await client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1743,20 +1992,30 @@ async def test_delete_queue_flattened_async(): @pytest.mark.asyncio async def test_delete_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PurgeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PurgeQueueRequest, + dict, + ], +) def test_purge_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1792,7 +2051,8 @@ def test_purge_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1808,7 +2068,8 @@ async def test_purge_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PurgeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1819,7 +2080,10 @@ async def test_purge_queue_async( with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.purge_queue(request) @@ -1840,13 +2104,15 @@ async def test_purge_queue_async_from_dict(): def test_purge_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1860,18 +2126,23 @@ def test_purge_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_purge_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1885,11 +2156,16 @@ async def test_purge_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_purge_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1897,7 +2173,9 @@ def test_purge_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.purge_queue(name="name_value",) + client.purge_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1909,19 +2187,24 @@ def test_purge_queue_flattened(): def test_purge_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_purge_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1931,7 +2214,9 @@ async def test_purge_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.purge_queue(name="name_value",) + response = await client.purge_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1944,20 +2229,30 @@ async def test_purge_queue_flattened_async(): @pytest.mark.asyncio async def test_purge_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PauseQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PauseQueueRequest, + dict, + ], +) def test_pause_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1993,7 +2288,8 @@ def test_pause_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2009,7 +2305,8 @@ async def test_pause_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PauseQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2020,7 +2317,10 @@ async def test_pause_queue_async( with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.pause_queue(request) @@ -2041,13 +2341,15 @@ async def test_pause_queue_async_from_dict(): def test_pause_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2061,18 +2363,23 @@ def test_pause_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_pause_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2086,11 +2393,16 @@ async def test_pause_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_pause_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2098,7 +2410,9 @@ def test_pause_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.pause_queue(name="name_value",) + client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2110,19 +2424,24 @@ def test_pause_queue_flattened(): def test_pause_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_pause_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2132,7 +2451,9 @@ async def test_pause_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.pause_queue(name="name_value",) + response = await client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2145,20 +2466,30 @@ async def test_pause_queue_flattened_async(): @pytest.mark.asyncio async def test_pause_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.ResumeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ResumeQueueRequest, + dict, + ], +) def test_resume_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2194,7 +2525,8 @@ def test_resume_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2210,7 +2542,8 @@ async def test_resume_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ResumeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2221,7 +2554,10 @@ async def test_resume_queue_async( with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - queue.Queue(name="name_value", state=queue.Queue.State.RUNNING,) + queue.Queue( + name="name_value", + state=queue.Queue.State.RUNNING, + ) ) response = await client.resume_queue(request) @@ -2242,13 +2578,15 @@ async def test_resume_queue_async_from_dict(): def test_resume_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2262,18 +2600,23 @@ def test_resume_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_resume_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2287,11 +2630,16 @@ async def test_resume_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_resume_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2299,7 +2647,9 @@ def test_resume_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.resume_queue(name="name_value",) + client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2311,19 +2661,24 @@ def test_resume_queue_flattened(): def test_resume_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_resume_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2333,7 +2688,9 @@ async def test_resume_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.resume_queue(name="name_value",) + response = await client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2346,20 +2703,30 @@ async def test_resume_queue_flattened_async(): @pytest.mark.asyncio async def test_resume_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2369,7 +2736,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2387,7 +2757,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2403,7 +2774,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2414,7 +2786,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2435,13 +2810,15 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2455,18 +2832,23 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2480,11 +2862,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2499,7 +2886,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2507,7 +2896,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2519,19 +2910,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2541,7 +2937,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2554,20 +2952,30 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2577,7 +2985,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2595,7 +3006,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2611,7 +3023,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2622,7 +3035,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2643,13 +3059,15 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2663,18 +3081,23 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2688,11 +3111,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2701,13 +3129,16 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() def test_set_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2715,7 +3146,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2727,19 +3160,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2749,7 +3187,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2762,22 +3202,30 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2808,7 +3256,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2827,7 +3276,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2862,13 +3312,15 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2884,18 +3336,23 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2913,11 +3370,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2934,7 +3396,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2945,7 +3409,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -2961,7 +3426,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2975,7 +3442,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2990,7 +3459,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3007,7 +3477,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3019,10 +3491,17 @@ async def test_test_iam_permissions_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListTasksRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListTasksRequest, + dict, + ], +) def test_list_tasks(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3051,7 +3530,8 @@ def test_list_tasks_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3067,7 +3547,8 @@ async def test_list_tasks_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListTasksRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3078,7 +3559,9 @@ async def test_list_tasks_async( with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListTasksResponse(next_page_token="next_page_token_value",) + cloudtasks.ListTasksResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_tasks(request) @@ -3098,13 +3581,15 @@ async def test_list_tasks_async_from_dict(): def test_list_tasks_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3118,18 +3603,23 @@ def test_list_tasks_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_tasks_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3145,11 +3635,16 @@ async def test_list_tasks_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_tasks_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3157,7 +3652,9 @@ def test_list_tasks_flattened(): call.return_value = cloudtasks.ListTasksResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_tasks(parent="parent_value",) + client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3169,19 +3666,24 @@ def test_list_tasks_flattened(): def test_list_tasks_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_tasks_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3193,7 +3695,9 @@ async def test_list_tasks_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_tasks(parent="parent_value",) + response = await client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3206,19 +3710,23 @@ async def test_list_tasks_flattened_async(): @pytest.mark.asyncio async def test_list_tasks_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) def test_list_tasks_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3226,11 +3734,29 @@ def test_list_tasks_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) @@ -3242,14 +3768,15 @@ def test_list_tasks_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, task.Task) for i in results) def test_list_tasks_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3257,11 +3784,29 @@ def test_list_tasks_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = list(client.list_tasks(request={}).pages) @@ -3271,7 +3816,9 @@ def test_list_tasks_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_tasks_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3280,17 +3827,37 @@ async def test_list_tasks_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) - async_pager = await client.list_tasks(request={},) + async_pager = await client.list_tasks( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -3299,7 +3866,9 @@ async def test_list_tasks_async_pager(): @pytest.mark.asyncio async def test_list_tasks_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3308,24 +3877,51 @@ async def test_list_tasks_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_tasks(request={})).pages: + async for page_ in ( + await client.list_tasks(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetTaskRequest, + dict, + ], +) def test_get_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3359,7 +3955,8 @@ def test_get_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3375,7 +3972,8 @@ async def test_get_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3386,7 +3984,10 @@ async def test_get_task_async( with mock.patch.object(type(client.transport.get_task), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - task.Task(name="name_value", view=task.Task.View.BASIC,) + task.Task( + name="name_value", + view=task.Task.View.BASIC, + ) ) response = await client.get_task(request) @@ -3407,13 +4008,15 @@ async def test_get_task_async_from_dict(): def test_get_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3427,18 +4030,23 @@ def test_get_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3452,11 +4060,16 @@ async def test_get_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3464,7 +4077,9 @@ def test_get_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_task(name="name_value",) + client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3476,19 +4091,24 @@ def test_get_task_flattened(): def test_get_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3498,7 +4118,9 @@ async def test_get_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_task(name="name_value",) + response = await client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3511,20 +4133,30 @@ async def test_get_task_flattened_async(): @pytest.mark.asyncio async def test_get_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateTaskRequest, + dict, + ], +) def test_create_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3558,7 +4190,8 @@ def test_create_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3574,7 +4207,8 @@ async def test_create_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3585,7 +4219,10 @@ async def test_create_task_async( with mock.patch.object(type(client.transport.create_task), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - gct_task.Task(name="name_value", view=gct_task.Task.View.BASIC,) + gct_task.Task( + name="name_value", + view=gct_task.Task.View.BASIC, + ) ) response = await client.create_task(request) @@ -3606,13 +4243,15 @@ async def test_create_task_async_from_dict(): def test_create_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3626,18 +4265,23 @@ def test_create_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3651,11 +4295,16 @@ async def test_create_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3664,7 +4313,8 @@ def test_create_task_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3680,7 +4330,9 @@ def test_create_task_flattened(): def test_create_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3694,7 +4346,9 @@ def test_create_task_flattened_error(): @pytest.mark.asyncio async def test_create_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3705,7 +4359,8 @@ async def test_create_task_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3722,7 +4377,9 @@ async def test_create_task_flattened_async(): @pytest.mark.asyncio async def test_create_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3734,10 +4391,17 @@ async def test_create_task_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteTaskRequest, + dict, + ], +) def test_delete_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3763,7 +4427,8 @@ def test_delete_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3779,7 +4444,8 @@ async def test_delete_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3807,13 +4473,15 @@ async def test_delete_task_async_from_dict(): def test_delete_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3827,18 +4495,23 @@ def test_delete_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3852,11 +4525,16 @@ async def test_delete_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3864,7 +4542,9 @@ def test_delete_task_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_task(name="name_value",) + client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3876,19 +4556,24 @@ def test_delete_task_flattened(): def test_delete_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3898,7 +4583,9 @@ async def test_delete_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_task(name="name_value",) + response = await client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3911,20 +4598,30 @@ async def test_delete_task_flattened_async(): @pytest.mark.asyncio async def test_delete_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.LeaseTasksRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.LeaseTasksRequest, + dict, + ], +) def test_lease_tasks(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3950,7 +4647,8 @@ def test_lease_tasks_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3966,7 +4664,8 @@ async def test_lease_tasks_async( transport: str = "grpc_asyncio", request_type=cloudtasks.LeaseTasksRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3996,13 +4695,15 @@ async def test_lease_tasks_async_from_dict(): def test_lease_tasks_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.LeaseTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lease_tasks), "__call__") as call: @@ -4016,18 +4717,23 @@ def test_lease_tasks_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_lease_tasks_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.LeaseTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lease_tasks), "__call__") as call: @@ -4043,11 +4749,16 @@ async def test_lease_tasks_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_lease_tasks_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lease_tasks), "__call__") as call: @@ -4056,7 +4767,8 @@ def test_lease_tasks_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.lease_tasks( - parent="parent_value", lease_duration=duration_pb2.Duration(seconds=751), + parent="parent_value", + lease_duration=duration_pb2.Duration(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4072,7 +4784,9 @@ def test_lease_tasks_flattened(): def test_lease_tasks_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4086,7 +4800,9 @@ def test_lease_tasks_flattened_error(): @pytest.mark.asyncio async def test_lease_tasks_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.lease_tasks), "__call__") as call: @@ -4099,7 +4815,8 @@ async def test_lease_tasks_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.lease_tasks( - parent="parent_value", lease_duration=duration_pb2.Duration(seconds=751), + parent="parent_value", + lease_duration=duration_pb2.Duration(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4116,7 +4833,9 @@ async def test_lease_tasks_flattened_async(): @pytest.mark.asyncio async def test_lease_tasks_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4128,10 +4847,17 @@ async def test_lease_tasks_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.AcknowledgeTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.AcknowledgeTaskRequest, + dict, + ], +) def test_acknowledge_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4157,7 +4883,8 @@ def test_acknowledge_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4173,7 +4900,8 @@ async def test_acknowledge_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.AcknowledgeTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4201,13 +4929,15 @@ async def test_acknowledge_task_async_from_dict(): def test_acknowledge_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.AcknowledgeTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge_task), "__call__") as call: @@ -4221,18 +4951,23 @@ def test_acknowledge_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_acknowledge_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.AcknowledgeTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge_task), "__call__") as call: @@ -4246,11 +4981,16 @@ async def test_acknowledge_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_acknowledge_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge_task), "__call__") as call: @@ -4259,7 +4999,8 @@ def test_acknowledge_task_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.acknowledge_task( - name="name_value", schedule_time=timestamp_pb2.Timestamp(seconds=751), + name="name_value", + schedule_time=timestamp_pb2.Timestamp(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4275,7 +5016,9 @@ def test_acknowledge_task_flattened(): def test_acknowledge_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4289,7 +5032,9 @@ def test_acknowledge_task_flattened_error(): @pytest.mark.asyncio async def test_acknowledge_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.acknowledge_task), "__call__") as call: @@ -4300,7 +5045,8 @@ async def test_acknowledge_task_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.acknowledge_task( - name="name_value", schedule_time=timestamp_pb2.Timestamp(seconds=751), + name="name_value", + schedule_time=timestamp_pb2.Timestamp(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4317,7 +5063,9 @@ async def test_acknowledge_task_flattened_async(): @pytest.mark.asyncio async def test_acknowledge_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4329,10 +5077,17 @@ async def test_acknowledge_task_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.RenewLeaseRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.RenewLeaseRequest, + dict, + ], +) def test_renew_lease(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4366,7 +5121,8 @@ def test_renew_lease_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4382,7 +5138,8 @@ async def test_renew_lease_async( transport: str = "grpc_asyncio", request_type=cloudtasks.RenewLeaseRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4393,7 +5150,10 @@ async def test_renew_lease_async( with mock.patch.object(type(client.transport.renew_lease), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - task.Task(name="name_value", view=task.Task.View.BASIC,) + task.Task( + name="name_value", + view=task.Task.View.BASIC, + ) ) response = await client.renew_lease(request) @@ -4414,13 +5174,15 @@ async def test_renew_lease_async_from_dict(): def test_renew_lease_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RenewLeaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.renew_lease), "__call__") as call: @@ -4434,18 +5196,23 @@ def test_renew_lease_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_renew_lease_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RenewLeaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.renew_lease), "__call__") as call: @@ -4459,11 +5226,16 @@ async def test_renew_lease_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_renew_lease_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.renew_lease), "__call__") as call: @@ -4493,7 +5265,9 @@ def test_renew_lease_flattened(): def test_renew_lease_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4508,7 +5282,9 @@ def test_renew_lease_flattened_error(): @pytest.mark.asyncio async def test_renew_lease_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.renew_lease), "__call__") as call: @@ -4541,7 +5317,9 @@ async def test_renew_lease_flattened_async(): @pytest.mark.asyncio async def test_renew_lease_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4554,10 +5332,17 @@ async def test_renew_lease_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.CancelLeaseRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CancelLeaseRequest, + dict, + ], +) def test_cancel_lease(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4591,7 +5376,8 @@ def test_cancel_lease_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4607,7 +5393,8 @@ async def test_cancel_lease_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CancelLeaseRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4618,7 +5405,10 @@ async def test_cancel_lease_async( with mock.patch.object(type(client.transport.cancel_lease), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - task.Task(name="name_value", view=task.Task.View.BASIC,) + task.Task( + name="name_value", + view=task.Task.View.BASIC, + ) ) response = await client.cancel_lease(request) @@ -4639,13 +5429,15 @@ async def test_cancel_lease_async_from_dict(): def test_cancel_lease_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CancelLeaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_lease), "__call__") as call: @@ -4659,18 +5451,23 @@ def test_cancel_lease_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_cancel_lease_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CancelLeaseRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_lease), "__call__") as call: @@ -4684,11 +5481,16 @@ async def test_cancel_lease_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_cancel_lease_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_lease), "__call__") as call: @@ -4697,7 +5499,8 @@ def test_cancel_lease_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_lease( - name="name_value", schedule_time=timestamp_pb2.Timestamp(seconds=751), + name="name_value", + schedule_time=timestamp_pb2.Timestamp(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4713,7 +5516,9 @@ def test_cancel_lease_flattened(): def test_cancel_lease_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4727,7 +5532,9 @@ def test_cancel_lease_flattened_error(): @pytest.mark.asyncio async def test_cancel_lease_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_lease), "__call__") as call: @@ -4738,7 +5545,8 @@ async def test_cancel_lease_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.cancel_lease( - name="name_value", schedule_time=timestamp_pb2.Timestamp(seconds=751), + name="name_value", + schedule_time=timestamp_pb2.Timestamp(seconds=751), ) # Establish that the underlying call was made with the expected @@ -4755,7 +5563,9 @@ async def test_cancel_lease_flattened_async(): @pytest.mark.asyncio async def test_cancel_lease_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4767,10 +5577,17 @@ async def test_cancel_lease_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.RunTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.RunTaskRequest, + dict, + ], +) def test_run_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4804,7 +5621,8 @@ def test_run_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4820,7 +5638,8 @@ async def test_run_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.RunTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4831,7 +5650,10 @@ async def test_run_task_async( with mock.patch.object(type(client.transport.run_task), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - task.Task(name="name_value", view=task.Task.View.BASIC,) + task.Task( + name="name_value", + view=task.Task.View.BASIC, + ) ) response = await client.run_task(request) @@ -4852,13 +5674,15 @@ async def test_run_task_async_from_dict(): def test_run_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4872,18 +5696,23 @@ def test_run_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_run_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4897,11 +5726,16 @@ async def test_run_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_run_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4909,7 +5743,9 @@ def test_run_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.run_task(name="name_value",) + client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4921,19 +5757,24 @@ def test_run_task_flattened(): def test_run_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_run_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4943,7 +5784,9 @@ async def test_run_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.run_task(name="name_value",) + response = await client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4956,13 +5799,16 @@ async def test_run_task_flattened_async(): @pytest.mark.asyncio async def test_run_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @@ -4973,7 +5819,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -4993,7 +5840,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudTasksClient(client_options=options, transport=transport,) + client = CloudTasksClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -5009,7 +5859,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -5039,7 +5890,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -5049,10 +5903,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = CloudTasksClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudTasksGrpcTransport,) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudTasksGrpcTransport, + ) def test_cloud_tasks_base_transport_error(): @@ -5105,6 +5977,14 @@ def test_cloud_tasks_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -5116,7 +5996,8 @@ def test_cloud_tasks_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -5151,7 +6032,10 @@ def test_cloud_tasks_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -5243,24 +6127,40 @@ def test_cloud_tasks_grpc_transport_client_cert_source_for_mtls(transport_class) ) -def test_cloud_tasks_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_no_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") -def test_cloud_tasks_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_with_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:8000" + assert client.transport._host == ("cloudtasks.googleapis.com:8000") def test_cloud_tasks_grpc_transport_channel(): @@ -5268,7 +6168,8 @@ def test_cloud_tasks_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -5280,7 +6181,8 @@ def test_cloud_tasks_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -5384,7 +6286,9 @@ def test_queue_path(): location = "clam" queue = "whelk" expected = "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) actual = CloudTasksClient.queue_path(project, location, queue) assert expected == actual @@ -5408,8 +6312,13 @@ def test_task_path(): location = "mussel" queue = "winkle" task = "nautilus" - expected = "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + expected = ( + "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( + project=project, + location=location, + queue=queue, + task=task, + ) ) actual = CloudTasksClient.task_path(project, location, queue, task) assert expected == actual @@ -5451,7 +6360,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudTasksClient.common_folder_path(folder) assert expected == actual @@ -5469,7 +6380,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudTasksClient.common_organization_path(organization) assert expected == actual @@ -5487,7 +6400,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudTasksClient.common_project_path(project) assert expected == actual @@ -5507,7 +6422,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudTasksClient.common_location_path(project, location) assert expected == actual @@ -5532,7 +6448,8 @@ def test_client_with_default_client_info(): transports.CloudTasksTransport, "_prep_wrapped_messages" ) as prep: client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5541,7 +6458,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudTasksClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5549,7 +6467,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close" diff --git a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py index a2e9893f..86fa27e3 100644 --- a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py @@ -13,34 +13,15 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import os -import mock - -import grpc -from grpc.experimental import aio import math -import pytest -from proto.marshal.rules.dates import DurationRule, TimestampRule - +import os +from google.api_core import gapic_v1, grpc_helpers, grpc_helpers_async, path_template from google.api_core import client_options from google.api_core import exceptions as core_exceptions -from google.api_core import gapic_v1 -from google.api_core import grpc_helpers -from google.api_core import grpc_helpers_async -from google.api_core import path_template +import google.auth from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError -from google.cloud.tasks_v2beta3.services.cloud_tasks import CloudTasksAsyncClient -from google.cloud.tasks_v2beta3.services.cloud_tasks import CloudTasksClient -from google.cloud.tasks_v2beta3.services.cloud_tasks import pagers -from google.cloud.tasks_v2beta3.services.cloud_tasks import transports -from google.cloud.tasks_v2beta3.types import cloudtasks -from google.cloud.tasks_v2beta3.types import queue -from google.cloud.tasks_v2beta3.types import queue as gct_queue -from google.cloud.tasks_v2beta3.types import target -from google.cloud.tasks_v2beta3.types import task -from google.cloud.tasks_v2beta3.types import task as gct_task from google.iam.v1 import iam_policy_pb2 # type: ignore from google.iam.v1 import options_pb2 # type: ignore from google.iam.v1 import policy_pb2 # type: ignore @@ -51,7 +32,24 @@ from google.protobuf import timestamp_pb2 # type: ignore from google.rpc import status_pb2 # type: ignore from google.type import expr_pb2 # type: ignore -import google.auth +import grpc +from grpc.experimental import aio +import mock +from proto.marshal.rules.dates import DurationRule, TimestampRule +import pytest + +from google.cloud.tasks_v2beta3.services.cloud_tasks import ( + CloudTasksAsyncClient, + CloudTasksClient, + pagers, + transports, +) +from google.cloud.tasks_v2beta3.types import cloudtasks +from google.cloud.tasks_v2beta3.types import queue +from google.cloud.tasks_v2beta3.types import queue as gct_queue +from google.cloud.tasks_v2beta3.types import target +from google.cloud.tasks_v2beta3.types import task +from google.cloud.tasks_v2beta3.types import task as gct_task def client_cert_source_callback(): @@ -95,19 +93,25 @@ def test__get_default_mtls_endpoint(): assert CloudTasksClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") @pytest.mark.parametrize( @@ -135,22 +139,32 @@ def test_cloud_tasks_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient,]) -def test_cloud_tasks_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudTasksClient, "grpc"), + (CloudTasksAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_tasks_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") def test_cloud_tasks_client_get_transport_class(): @@ -490,7 +504,9 @@ def test_cloud_tasks_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -618,10 +634,17 @@ def test_cloud_tasks_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListQueuesRequest, + dict, + ], +) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -650,7 +673,8 @@ def test_list_queues_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -666,7 +690,8 @@ async def test_list_queues_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListQueuesRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -677,7 +702,9 @@ async def test_list_queues_async( with mock.patch.object(type(client.transport.list_queues), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListQueuesResponse(next_page_token="next_page_token_value",) + cloudtasks.ListQueuesResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_queues(request) @@ -697,13 +724,15 @@ async def test_list_queues_async_from_dict(): def test_list_queues_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -717,18 +746,23 @@ def test_list_queues_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_queues_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListQueuesRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -744,11 +778,16 @@ async def test_list_queues_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_queues_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -756,7 +795,9 @@ def test_list_queues_flattened(): call.return_value = cloudtasks.ListQueuesResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_queues(parent="parent_value",) + client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -768,19 +809,24 @@ def test_list_queues_flattened(): def test_list_queues_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_queues_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_queues), "__call__") as call: @@ -792,7 +838,9 @@ async def test_list_queues_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_queues(parent="parent_value",) + response = await client.list_queues( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -805,19 +853,23 @@ async def test_list_queues_flattened_async(): @pytest.mark.asyncio async def test_list_queues_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_queues( - cloudtasks.ListQueuesRequest(), parent="parent_value", + cloudtasks.ListQueuesRequest(), + parent="parent_value", ) def test_list_queues_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -825,14 +877,29 @@ def test_list_queues_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) @@ -844,14 +911,15 @@ def test_list_queues_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, queue.Queue) for i in results) def test_list_queues_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -859,14 +927,29 @@ def test_list_queues_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = list(client.list_queues(request={}).pages) @@ -876,7 +959,9 @@ def test_list_queues_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_queues_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -885,20 +970,37 @@ async def test_list_queues_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) - async_pager = await client.list_queues(request={},) + async_pager = await client.list_queues( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -907,7 +1009,9 @@ async def test_list_queues_async_pager(): @pytest.mark.asyncio async def test_list_queues_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -916,27 +1020,51 @@ async def test_list_queues_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListQueuesResponse( - queues=[queue.Queue(), queue.Queue(), queue.Queue(),], + queues=[ + queue.Queue(), + queue.Queue(), + queue.Queue(), + ], next_page_token="abc", ), - cloudtasks.ListQueuesResponse(queues=[], next_page_token="def",), cloudtasks.ListQueuesResponse( - queues=[queue.Queue(),], next_page_token="ghi", + queues=[], + next_page_token="def", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + ], + next_page_token="ghi", + ), + cloudtasks.ListQueuesResponse( + queues=[ + queue.Queue(), + queue.Queue(), + ], ), - cloudtasks.ListQueuesResponse(queues=[queue.Queue(), queue.Queue(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_queues(request={})).pages: + async for page_ in ( + await client.list_queues(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetQueueRequest, + dict, + ], +) def test_get_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -974,7 +1102,8 @@ def test_get_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -990,7 +1119,8 @@ async def test_get_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1027,13 +1157,15 @@ async def test_get_queue_async_from_dict(): def test_get_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1047,18 +1179,23 @@ def test_get_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1072,11 +1209,16 @@ async def test_get_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1084,7 +1226,9 @@ def test_get_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_queue(name="name_value",) + client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1096,19 +1240,24 @@ def test_get_queue_flattened(): def test_get_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_queue), "__call__") as call: @@ -1118,7 +1267,9 @@ async def test_get_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_queue(name="name_value",) + response = await client.get_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1131,20 +1282,30 @@ async def test_get_queue_flattened_async(): @pytest.mark.asyncio async def test_get_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_queue( - cloudtasks.GetQueueRequest(), name="name_value", + cloudtasks.GetQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateQueueRequest, + dict, + ], +) def test_create_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1182,7 +1343,8 @@ def test_create_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1198,7 +1360,8 @@ async def test_create_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1235,13 +1398,15 @@ async def test_create_queue_async_from_dict(): def test_create_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1255,18 +1420,23 @@ def test_create_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateQueueRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1280,11 +1450,16 @@ async def test_create_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1293,7 +1468,8 @@ def test_create_queue_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1309,7 +1485,9 @@ def test_create_queue_flattened(): def test_create_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1323,7 +1501,9 @@ def test_create_queue_flattened_error(): @pytest.mark.asyncio async def test_create_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_queue), "__call__") as call: @@ -1334,7 +1514,8 @@ async def test_create_queue_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_queue( - parent="parent_value", queue=gct_queue.Queue(name="name_value"), + parent="parent_value", + queue=gct_queue.Queue(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -1351,7 +1532,9 @@ async def test_create_queue_flattened_async(): @pytest.mark.asyncio async def test_create_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1363,10 +1546,17 @@ async def test_create_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.UpdateQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.UpdateQueueRequest, + dict, + ], +) def test_update_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1404,7 +1594,8 @@ def test_update_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1420,7 +1611,8 @@ async def test_update_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.UpdateQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1457,13 +1649,15 @@ async def test_update_queue_async_from_dict(): def test_update_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1477,18 +1671,23 @@ def test_update_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.UpdateQueueRequest() - request.queue.name = "queue.name/value" + request.queue.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1502,11 +1701,16 @@ async def test_update_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "queue.name=queue.name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "queue.name=name_value", + ) in kw["metadata"] def test_update_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1532,7 +1736,9 @@ def test_update_queue_flattened(): def test_update_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1546,7 +1752,9 @@ def test_update_queue_flattened_error(): @pytest.mark.asyncio async def test_update_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.update_queue), "__call__") as call: @@ -1575,7 +1783,9 @@ async def test_update_queue_flattened_async(): @pytest.mark.asyncio async def test_update_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1587,10 +1797,17 @@ async def test_update_queue_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteQueueRequest, + dict, + ], +) def test_delete_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1616,7 +1833,8 @@ def test_delete_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1632,7 +1850,8 @@ async def test_delete_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1660,13 +1879,15 @@ async def test_delete_queue_async_from_dict(): def test_delete_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1680,18 +1901,23 @@ def test_delete_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1705,11 +1931,16 @@ async def test_delete_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1717,7 +1948,9 @@ def test_delete_queue_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_queue(name="name_value",) + client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1729,19 +1962,24 @@ def test_delete_queue_flattened(): def test_delete_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_queue), "__call__") as call: @@ -1751,7 +1989,9 @@ async def test_delete_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_queue(name="name_value",) + response = await client.delete_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1764,20 +2004,30 @@ async def test_delete_queue_flattened_async(): @pytest.mark.asyncio async def test_delete_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_queue( - cloudtasks.DeleteQueueRequest(), name="name_value", + cloudtasks.DeleteQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PurgeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PurgeQueueRequest, + dict, + ], +) def test_purge_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1815,7 +2065,8 @@ def test_purge_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1831,7 +2082,8 @@ async def test_purge_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PurgeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1868,13 +2120,15 @@ async def test_purge_queue_async_from_dict(): def test_purge_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1888,18 +2142,23 @@ def test_purge_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_purge_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PurgeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1913,11 +2172,16 @@ async def test_purge_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_purge_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1925,8 +2189,10 @@ def test_purge_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.purge_queue(name="name_value",) - + client.purge_queue( + name="name_value", + ) + # Establish that the underlying call was made with the expected # request object values. assert len(call.mock_calls) == 1 @@ -1937,19 +2203,24 @@ def test_purge_queue_flattened(): def test_purge_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_purge_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.purge_queue), "__call__") as call: @@ -1959,7 +2230,9 @@ async def test_purge_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.purge_queue(name="name_value",) + response = await client.purge_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -1972,20 +2245,30 @@ async def test_purge_queue_flattened_async(): @pytest.mark.asyncio async def test_purge_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.purge_queue( - cloudtasks.PurgeQueueRequest(), name="name_value", + cloudtasks.PurgeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.PauseQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.PauseQueueRequest, + dict, + ], +) def test_pause_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2023,7 +2306,8 @@ def test_pause_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2039,7 +2323,8 @@ async def test_pause_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.PauseQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2076,13 +2361,15 @@ async def test_pause_queue_async_from_dict(): def test_pause_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2096,18 +2383,23 @@ def test_pause_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_pause_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.PauseQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2121,11 +2413,16 @@ async def test_pause_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_pause_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2133,7 +2430,9 @@ def test_pause_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.pause_queue(name="name_value",) + client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2145,19 +2444,24 @@ def test_pause_queue_flattened(): def test_pause_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_pause_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.pause_queue), "__call__") as call: @@ -2167,7 +2471,9 @@ async def test_pause_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.pause_queue(name="name_value",) + response = await client.pause_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2180,20 +2486,30 @@ async def test_pause_queue_flattened_async(): @pytest.mark.asyncio async def test_pause_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.pause_queue( - cloudtasks.PauseQueueRequest(), name="name_value", + cloudtasks.PauseQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.ResumeQueueRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ResumeQueueRequest, + dict, + ], +) def test_resume_queue(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2231,7 +2547,8 @@ def test_resume_queue_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2247,7 +2564,8 @@ async def test_resume_queue_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ResumeQueueRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2284,13 +2602,15 @@ async def test_resume_queue_async_from_dict(): def test_resume_queue_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2304,18 +2624,23 @@ def test_resume_queue_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_resume_queue_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ResumeQueueRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2329,11 +2654,16 @@ async def test_resume_queue_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_resume_queue_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2341,7 +2671,9 @@ def test_resume_queue_flattened(): call.return_value = queue.Queue() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.resume_queue(name="name_value",) + client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2353,19 +2685,24 @@ def test_resume_queue_flattened(): def test_resume_queue_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_resume_queue_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.resume_queue), "__call__") as call: @@ -2375,7 +2712,9 @@ async def test_resume_queue_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(queue.Queue()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.resume_queue(name="name_value",) + response = await client.resume_queue( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2388,20 +2727,30 @@ async def test_resume_queue_flattened_async(): @pytest.mark.asyncio async def test_resume_queue_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.resume_queue( - cloudtasks.ResumeQueueRequest(), name="name_value", + cloudtasks.ResumeQueueRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.GetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.GetIamPolicyRequest, + dict, + ], +) def test_get_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2411,7 +2760,10 @@ def test_get_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.get_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2429,7 +2781,8 @@ def test_get_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2445,7 +2798,8 @@ async def test_get_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.GetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2456,7 +2810,10 @@ async def test_get_iam_policy_async( with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.get_iam_policy(request) @@ -2477,13 +2834,15 @@ async def test_get_iam_policy_async_from_dict(): def test_get_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2497,18 +2856,23 @@ def test_get_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.GetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2522,11 +2886,16 @@ async def test_get_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_get_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2541,7 +2910,9 @@ def test_get_iam_policy_from_dict_foreign(): def test_get_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2549,7 +2920,9 @@ def test_get_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_iam_policy(resource="resource_value",) + client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2561,19 +2934,24 @@ def test_get_iam_policy_flattened(): def test_get_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_get_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_iam_policy), "__call__") as call: @@ -2583,7 +2961,9 @@ async def test_get_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_iam_policy(resource="resource_value",) + response = await client.get_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2596,20 +2976,30 @@ async def test_get_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_get_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_iam_policy( - iam_policy_pb2.GetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.GetIamPolicyRequest(), + resource="resource_value", ) -@pytest.mark.parametrize("request_type", [iam_policy_pb2.SetIamPolicyRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + iam_policy_pb2.SetIamPolicyRequest, + dict, + ], +) def test_set_iam_policy(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2619,7 +3009,10 @@ def test_set_iam_policy(request_type, transport: str = "grpc"): # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. - call.return_value = policy_pb2.Policy(version=774, etag=b"etag_blob",) + call.return_value = policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) response = client.set_iam_policy(request) # Establish that the underlying gRPC stub method was called. @@ -2637,7 +3030,8 @@ def test_set_iam_policy_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2653,7 +3047,8 @@ async def test_set_iam_policy_async( transport: str = "grpc_asyncio", request_type=iam_policy_pb2.SetIamPolicyRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2664,7 +3059,10 @@ async def test_set_iam_policy_async( with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - policy_pb2.Policy(version=774, etag=b"etag_blob",) + policy_pb2.Policy( + version=774, + etag=b"etag_blob", + ) ) response = await client.set_iam_policy(request) @@ -2685,13 +3083,15 @@ async def test_set_iam_policy_async_from_dict(): def test_set_iam_policy_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2705,18 +3105,23 @@ def test_set_iam_policy_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_set_iam_policy_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.SetIamPolicyRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2730,11 +3135,16 @@ async def test_set_iam_policy_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_set_iam_policy_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: # Designate an appropriate return value for the call. @@ -2743,13 +3153,16 @@ def test_set_iam_policy_from_dict_foreign(): request={ "resource": "resource_value", "policy": policy_pb2.Policy(version=774), + "update_mask": field_mask_pb2.FieldMask(paths=["paths_value"]), } ) call.assert_called() def test_set_iam_policy_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2757,7 +3170,9 @@ def test_set_iam_policy_flattened(): call.return_value = policy_pb2.Policy() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.set_iam_policy(resource="resource_value",) + client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2769,19 +3184,24 @@ def test_set_iam_policy_flattened(): def test_set_iam_policy_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.asyncio async def test_set_iam_policy_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.set_iam_policy), "__call__") as call: @@ -2791,7 +3211,9 @@ async def test_set_iam_policy_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(policy_pb2.Policy()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.set_iam_policy(resource="resource_value",) + response = await client.set_iam_policy( + resource="resource_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2804,22 +3226,30 @@ async def test_set_iam_policy_flattened_async(): @pytest.mark.asyncio async def test_set_iam_policy_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.set_iam_policy( - iam_policy_pb2.SetIamPolicyRequest(), resource="resource_value", + iam_policy_pb2.SetIamPolicyRequest(), + resource="resource_value", ) @pytest.mark.parametrize( - "request_type", [iam_policy_pb2.TestIamPermissionsRequest, dict,] + "request_type", + [ + iam_policy_pb2.TestIamPermissionsRequest, + dict, + ], ) def test_test_iam_permissions(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2850,7 +3280,8 @@ def test_test_iam_permissions_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2869,7 +3300,8 @@ async def test_test_iam_permissions_async( request_type=iam_policy_pb2.TestIamPermissionsRequest, ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2904,13 +3336,15 @@ async def test_test_iam_permissions_async_from_dict(): def test_test_iam_permissions_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2926,18 +3360,23 @@ def test_test_iam_permissions_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_test_iam_permissions_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = iam_policy_pb2.TestIamPermissionsRequest() - request.resource = "resource/value" + request.resource = "resource_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2955,11 +3394,16 @@ async def test_test_iam_permissions_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "resource=resource/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "resource=resource_value", + ) in kw["metadata"] def test_test_iam_permissions_from_dict_foreign(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.test_iam_permissions), "__call__" @@ -2976,7 +3420,9 @@ def test_test_iam_permissions_from_dict_foreign(): def test_test_iam_permissions_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2987,7 +3433,8 @@ def test_test_iam_permissions_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3003,7 +3450,9 @@ def test_test_iam_permissions_flattened(): def test_test_iam_permissions_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3017,7 +3466,9 @@ def test_test_iam_permissions_flattened_error(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3032,7 +3483,8 @@ async def test_test_iam_permissions_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.test_iam_permissions( - resource="resource_value", permissions=["permissions_value"], + resource="resource_value", + permissions=["permissions_value"], ) # Establish that the underlying call was made with the expected @@ -3049,7 +3501,9 @@ async def test_test_iam_permissions_flattened_async(): @pytest.mark.asyncio async def test_test_iam_permissions_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3061,10 +3515,17 @@ async def test_test_iam_permissions_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.ListTasksRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.ListTasksRequest, + dict, + ], +) def test_list_tasks(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3093,7 +3554,8 @@ def test_list_tasks_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3109,7 +3571,8 @@ async def test_list_tasks_async( transport: str = "grpc_asyncio", request_type=cloudtasks.ListTasksRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3120,7 +3583,9 @@ async def test_list_tasks_async( with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudtasks.ListTasksResponse(next_page_token="next_page_token_value",) + cloudtasks.ListTasksResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_tasks(request) @@ -3140,13 +3605,15 @@ async def test_list_tasks_async_from_dict(): def test_list_tasks_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3160,18 +3627,23 @@ def test_list_tasks_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_tasks_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.ListTasksRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3187,11 +3659,16 @@ async def test_list_tasks_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_tasks_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3199,7 +3676,9 @@ def test_list_tasks_flattened(): call.return_value = cloudtasks.ListTasksResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_tasks(parent="parent_value",) + client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3211,19 +3690,24 @@ def test_list_tasks_flattened(): def test_list_tasks_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_tasks_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_tasks), "__call__") as call: @@ -3235,7 +3719,9 @@ async def test_list_tasks_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_tasks(parent="parent_value",) + response = await client.list_tasks( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3248,19 +3734,23 @@ async def test_list_tasks_flattened_async(): @pytest.mark.asyncio async def test_list_tasks_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_tasks( - cloudtasks.ListTasksRequest(), parent="parent_value", + cloudtasks.ListTasksRequest(), + parent="parent_value", ) def test_list_tasks_pager(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3268,11 +3758,29 @@ def test_list_tasks_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) @@ -3284,14 +3792,15 @@ def test_list_tasks_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, task.Task) for i in results) def test_list_tasks_pages(transport_name: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3299,11 +3808,29 @@ def test_list_tasks_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = list(client.list_tasks(request={}).pages) @@ -3313,7 +3840,9 @@ def test_list_tasks_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_tasks_async_pager(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3322,17 +3851,37 @@ async def test_list_tasks_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) - async_pager = await client.list_tasks(request={},) + async_pager = await client.list_tasks( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -3341,7 +3890,9 @@ async def test_list_tasks_async_pager(): @pytest.mark.asyncio async def test_list_tasks_async_pages(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3350,24 +3901,51 @@ async def test_list_tasks_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudtasks.ListTasksResponse( - tasks=[task.Task(), task.Task(), task.Task(),], next_page_token="abc", + tasks=[ + task.Task(), + task.Task(), + task.Task(), + ], + next_page_token="abc", + ), + cloudtasks.ListTasksResponse( + tasks=[], + next_page_token="def", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + ], + next_page_token="ghi", + ), + cloudtasks.ListTasksResponse( + tasks=[ + task.Task(), + task.Task(), + ], ), - cloudtasks.ListTasksResponse(tasks=[], next_page_token="def",), - cloudtasks.ListTasksResponse(tasks=[task.Task(),], next_page_token="ghi",), - cloudtasks.ListTasksResponse(tasks=[task.Task(), task.Task(),],), RuntimeError, ) pages = [] - async for page_ in (await client.list_tasks(request={})).pages: + async for page_ in ( + await client.list_tasks(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudtasks.GetTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.GetTaskRequest, + dict, + ], +) def test_get_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3405,7 +3983,8 @@ def test_get_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3421,7 +4000,8 @@ async def test_get_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.GetTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3460,13 +4040,15 @@ async def test_get_task_async_from_dict(): def test_get_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3480,18 +4062,23 @@ def test_get_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.GetTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3505,11 +4092,16 @@ async def test_get_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3517,7 +4109,9 @@ def test_get_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_task(name="name_value",) + client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3529,19 +4123,24 @@ def test_get_task_flattened(): def test_get_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_task), "__call__") as call: @@ -3551,7 +4150,9 @@ async def test_get_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_task(name="name_value",) + response = await client.get_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3564,20 +4165,30 @@ async def test_get_task_flattened_async(): @pytest.mark.asyncio async def test_get_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_task( - cloudtasks.GetTaskRequest(), name="name_value", + cloudtasks.GetTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.CreateTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.CreateTaskRequest, + dict, + ], +) def test_create_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3615,7 +4226,8 @@ def test_create_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3631,7 +4243,8 @@ async def test_create_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.CreateTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3670,13 +4283,15 @@ async def test_create_task_async_from_dict(): def test_create_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3690,18 +4305,23 @@ def test_create_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.CreateTaskRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3715,11 +4335,16 @@ async def test_create_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3728,7 +4353,8 @@ def test_create_task_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3744,7 +4370,9 @@ def test_create_task_flattened(): def test_create_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3758,7 +4386,9 @@ def test_create_task_flattened_error(): @pytest.mark.asyncio async def test_create_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_task), "__call__") as call: @@ -3769,7 +4399,8 @@ async def test_create_task_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_task( - parent="parent_value", task=gct_task.Task(name="name_value"), + parent="parent_value", + task=gct_task.Task(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -3786,7 +4417,9 @@ async def test_create_task_flattened_async(): @pytest.mark.asyncio async def test_create_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3798,10 +4431,17 @@ async def test_create_task_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudtasks.DeleteTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.DeleteTaskRequest, + dict, + ], +) def test_delete_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3827,7 +4467,8 @@ def test_delete_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3843,7 +4484,8 @@ async def test_delete_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.DeleteTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3871,13 +4513,15 @@ async def test_delete_task_async_from_dict(): def test_delete_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3891,18 +4535,23 @@ def test_delete_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.DeleteTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3916,11 +4565,16 @@ async def test_delete_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3928,7 +4582,9 @@ def test_delete_task_flattened(): call.return_value = None # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.delete_task(name="name_value",) + client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3940,19 +4596,24 @@ def test_delete_task_flattened(): def test_delete_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.delete_task), "__call__") as call: @@ -3962,7 +4623,9 @@ async def test_delete_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_task(name="name_value",) + response = await client.delete_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3975,20 +4638,30 @@ async def test_delete_task_flattened_async(): @pytest.mark.asyncio async def test_delete_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_task( - cloudtasks.DeleteTaskRequest(), name="name_value", + cloudtasks.DeleteTaskRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudtasks.RunTaskRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudtasks.RunTaskRequest, + dict, + ], +) def test_run_task(request_type, transport: str = "grpc"): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4026,7 +4699,8 @@ def test_run_task_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4042,7 +4716,8 @@ async def test_run_task_async( transport: str = "grpc_asyncio", request_type=cloudtasks.RunTaskRequest ): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4081,13 +4756,15 @@ async def test_run_task_async_from_dict(): def test_run_task_field_headers(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4101,18 +4778,23 @@ def test_run_task_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_run_task_field_headers_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudtasks.RunTaskRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4126,11 +4808,16 @@ async def test_run_task_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_run_task_flattened(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4138,7 +4825,9 @@ def test_run_task_flattened(): call.return_value = task.Task() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.run_task(name="name_value",) + client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4150,19 +4839,24 @@ def test_run_task_flattened(): def test_run_task_flattened_error(): - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_run_task_flattened_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.run_task), "__call__") as call: @@ -4172,7 +4866,9 @@ async def test_run_task_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(task.Task()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.run_task(name="name_value",) + response = await client.run_task( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4185,13 +4881,16 @@ async def test_run_task_flattened_async(): @pytest.mark.asyncio async def test_run_task_flattened_error_async(): - client = CloudTasksAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudTasksAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.run_task( - cloudtasks.RunTaskRequest(), name="name_value", + cloudtasks.RunTaskRequest(), + name="name_value", ) @@ -4202,7 +4901,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -4222,7 +4922,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudTasksClient(client_options=options, transport=transport,) + client = CloudTasksClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -4238,7 +4941,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudTasksClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -4268,7 +4972,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -4278,10 +4985,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = CloudTasksClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudTasksClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudTasksGrpcTransport,) + client = CloudTasksClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudTasksGrpcTransport, + ) def test_cloud_tasks_base_transport_error(): @@ -4330,6 +5055,14 @@ def test_cloud_tasks_base_transport(): with pytest.raises(NotImplementedError): transport.close() + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_cloud_tasks_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4341,7 +5074,8 @@ def test_cloud_tasks_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudTasksTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -4376,7 +5110,10 @@ def test_cloud_tasks_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.CloudTasksGrpcTransport, transports.CloudTasksGrpcAsyncIOTransport,], + [ + transports.CloudTasksGrpcTransport, + transports.CloudTasksGrpcAsyncIOTransport, + ], ) def test_cloud_tasks_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -4468,24 +5205,40 @@ def test_cloud_tasks_grpc_transport_client_cert_source_for_mtls(transport_class) ) -def test_cloud_tasks_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_no_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:443" + assert client.transport._host == ("cloudtasks.googleapis.com:443") -def test_cloud_tasks_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_tasks_host_with_port(transport_name): client = CloudTasksClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudtasks.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudtasks.googleapis.com:8000" + assert client.transport._host == ("cloudtasks.googleapis.com:8000") def test_cloud_tasks_grpc_transport_channel(): @@ -4493,7 +5246,8 @@ def test_cloud_tasks_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4505,7 +5259,8 @@ def test_cloud_tasks_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudTasksGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4609,7 +5364,9 @@ def test_queue_path(): location = "clam" queue = "whelk" expected = "projects/{project}/locations/{location}/queues/{queue}".format( - project=project, location=location, queue=queue, + project=project, + location=location, + queue=queue, ) actual = CloudTasksClient.queue_path(project, location, queue) assert expected == actual @@ -4633,8 +5390,13 @@ def test_task_path(): location = "mussel" queue = "winkle" task = "nautilus" - expected = "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( - project=project, location=location, queue=queue, task=task, + expected = ( + "projects/{project}/locations/{location}/queues/{queue}/tasks/{task}".format( + project=project, + location=location, + queue=queue, + task=task, + ) ) actual = CloudTasksClient.task_path(project, location, queue, task) assert expected == actual @@ -4676,7 +5438,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "oyster" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudTasksClient.common_folder_path(folder) assert expected == actual @@ -4694,7 +5458,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "cuttlefish" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudTasksClient.common_organization_path(organization) assert expected == actual @@ -4712,7 +5478,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "winkle" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudTasksClient.common_project_path(project) assert expected == actual @@ -4732,7 +5500,8 @@ def test_common_location_path(): project = "scallop" location = "abalone" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudTasksClient.common_location_path(project, location) assert expected == actual @@ -4757,7 +5526,8 @@ def test_client_with_default_client_info(): transports.CloudTasksTransport, "_prep_wrapped_messages" ) as prep: client = CloudTasksClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4766,7 +5536,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudTasksClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4774,7 +5545,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudTasksAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"