diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 6b8a73b3..b668c04d 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,17 @@ +# 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. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:36a95b8f494e4674dc9eee9af98961293b51b86b3649942aac800ae6c1f796d4 + digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 + diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 25128855..63a84c3b 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,8 +5,8 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax # Note: This file is autogenerated. To make changes to the codeowner team, please update .repo-metadata.json. -# @googleapis/yoshi-python @googleapis/serverless-team are the default owners for changes in this repo -* @googleapis/yoshi-python @googleapis/serverless-team +# @googleapis/yoshi-python @googleapis/aap-dpes are the default owners for changes in this repo +* @googleapis/yoshi-python @googleapis/aap-dpes -# @googleapis/python-samples-reviewers @googleapis/serverless-team are the default owners for samples changes -/samples/ @googleapis/python-samples-reviewers @googleapis/serverless-team +# @googleapis/python-samples-reviewers @googleapis/aap-dpes are the default owners for samples changes +/samples/ @googleapis/python-samples-reviewers @googleapis/aap-dpes diff --git a/.github/release-please.yml b/.github/release-please.yml index 4507ad05..466597e5 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1 +1,2 @@ releaseType: python +handleGHRelease: true diff --git a/.github/release-trigger.yml b/.github/release-trigger.yml new file mode 100644 index 00000000..d4ca9418 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 3e98ae70..37438d33 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -10,6 +10,5 @@ branchProtectionRules: - 'Kokoro' - 'cla/google' - 'Samples - Lint' - - 'Samples - Python 3.6' - 'Samples - Python 3.7' - 'Samples - Python 3.8' diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 00000000..f7b8344c --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,38 @@ +on: + pull_request: + branches: + - main +name: docs +jobs: + docs: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docs + run: | + nox -s docs + docfx: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run docfx + run: | + nox -s docfx diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 00000000..1e8b05c3 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,25 @@ +on: + pull_request: + branches: + - main +name: lint +jobs: + lint: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run lint + run: | + nox -s lint + - name: Run lint_setup_py + run: | + nox -s lint_setup_py diff --git a/.github/workflows/unittest.yml b/.github/workflows/unittest.yml new file mode 100644 index 00000000..074ee250 --- /dev/null +++ b/.github/workflows/unittest.yml @@ -0,0 +1,57 @@ +on: + pull_request: + branches: + - main +name: unittest +jobs: + unit: + runs-on: ubuntu-latest + strategy: + matrix: + python: ['3.6', '3.7', '3.8', '3.9', '3.10'] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: ${{ matrix.python }} + - name: Install nox + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install nox + - name: Run unit tests + env: + COVERAGE_FILE: .coverage-${{ matrix.python }} + run: | + nox -s unit-${{ matrix.python }} + - name: Upload coverage results + uses: actions/upload-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-${{ matrix.python }} + + cover: + runs-on: ubuntu-latest + needs: + - unit + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup Python + uses: actions/setup-python@v2 + with: + python-version: "3.10" + - name: Install coverage + run: | + python -m pip install --upgrade setuptools pip wheel + python -m pip install coverage + - name: Download coverage results + uses: actions/download-artifact@v2 + with: + name: coverage-artifacts + path: .coverage-results/ + - name: Report coverage results + run: | + coverage combine .coverage-results/.coverage* + coverage report --show-missing --fail-under=100 diff --git a/.kokoro/release.sh b/.kokoro/release.sh index 163eb07a..dcd5c6d9 100755 --- a/.kokoro/release.sh +++ b/.kokoro/release.sh @@ -26,7 +26,7 @@ python3 -m pip install --upgrade twine wheel setuptools export PYTHONUNBUFFERED=1 # Move into the package, build the distribution and upload. -TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") +TWINE_PASSWORD=$(cat "${KOKORO_KEYSTORE_DIR}/73713_google-cloud-pypi-token-keystore-1") cd github/python-tasks python3 setup.py sdist bdist_wheel twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 716e424e..cc6bbafb 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-tasks/.kokoro/release.sh" } +# Fetch PyPI password +before_action { + fetch_keystore { + keystore_resource { + keystore_config_id: 73713 + keyname: "google-cloud-pypi-token-keystore-1" + } + } +} + # Tokens needed to report release status back to GitHub env_vars: { key: "SECRET_MANAGER_KEYS" - value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" } diff --git a/.repo-metadata.json b/.repo-metadata.json index 2144604c..c251c2ba 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -12,6 +12,6 @@ "api_id": "cloudtasks.googleapis.com", "requires_billing": true, "default_version": "v2", - "codeowner_team": "@googleapis/serverless-team", + "codeowner_team": "@googleapis/aap-dpes", "api_shortname": "cloudtasks" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d4ddec8..44b24684 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ [1]: https://pypi.org/project/google-cloud-tasks/#history +## [2.8.0](https://github.com/googleapis/python-tasks/compare/v2.7.2...v2.8.0) (2022-02-14) + + +### Features + +* add api key support ([#214](https://github.com/googleapis/python-tasks/issues/214)) ([ce21598](https://github.com/googleapis/python-tasks/commit/ce215987f969cbc6347fb58cd2163394a6fc7f1c)) + + +### Bug Fixes + +* resolve DuplicateCredentialArgs error when using credentials_file ([8dd8aec](https://github.com/googleapis/python-tasks/commit/8dd8aec79d2302007e3f9511daeab817f05d2aa6)) + ### [2.7.2](https://www.github.com/googleapis/python-tasks/compare/v2.7.1...v2.7.2) (2022-01-08) 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 250d60b7..ee93b143 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -114,6 +114,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return CloudTasksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> CloudTasksTransport: """Returns the transport used by the client instance. @@ -186,6 +222,27 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ListQueuesRequest, dict]): The request object. Request message for @@ -213,7 +270,7 @@ async def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -276,6 +333,25 @@ async def get_queue( ) -> queue.Queue: r"""Gets a queue. + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.GetQueueRequest, dict]): The request object. Request message for @@ -304,7 +380,7 @@ async def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -372,6 +448,26 @@ async def create_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.CreateQueueRequest, dict]): The request object. Request message for @@ -414,7 +510,7 @@ async def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -477,6 +573,25 @@ async def update_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -522,7 +637,7 @@ async def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -584,6 +699,23 @@ async def delete_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -602,7 +734,7 @@ async def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -663,6 +795,26 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -691,7 +843,7 @@ async def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -745,6 +897,26 @@ 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:: + + from google.cloud import tasks_v2 + + def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.PauseQueueRequest, dict]): The request object. Request message for @@ -773,7 +945,7 @@ async def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -834,6 +1006,26 @@ async def resume_queue( Scaling Risks `__. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -862,7 +1054,7 @@ async def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -917,6 +1109,26 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -996,7 +1208,7 @@ async def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1065,6 +1277,26 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1144,7 +1376,7 @@ async def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1200,6 +1432,27 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1233,7 +1486,7 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1301,6 +1554,27 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1329,7 +1603,7 @@ async def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1392,6 +1666,25 @@ async def get_task( ) -> task.Task: r"""Gets a task. + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1415,7 +1708,7 @@ async def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1478,6 +1771,26 @@ async def create_task( - The maximum task size is 100KB. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1548,7 +1861,7 @@ async def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1600,6 +1913,23 @@ async def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1619,7 +1949,7 @@ async def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1701,6 +2031,26 @@ 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:: + + from google.cloud import tasks_v2 + + def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -1724,7 +2074,7 @@ async def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/tasks_v2/services/cloud_tasks/client.py b/google/cloud/tasks_v2/services/cloud_tasks/client.py index 04e5cd06..0343d21a 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/client.py @@ -260,6 +260,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -310,57 +377,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, CloudTasksTransport): # transport is a CloudTasksTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -372,6 +404,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -396,6 +437,28 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ListQueuesRequest, dict]): The request object. Request message for @@ -423,7 +486,7 @@ def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -476,6 +539,26 @@ def get_queue( ) -> queue.Queue: r"""Gets a queue. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.GetQueueRequest, dict]): The request object. Request message for @@ -504,7 +587,7 @@ def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -562,6 +645,27 @@ def create_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.CreateQueueRequest, dict]): The request object. Request message for @@ -604,7 +708,7 @@ def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -667,6 +771,26 @@ def update_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -712,7 +836,7 @@ def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -774,6 +898,24 @@ def delete_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -792,7 +934,7 @@ def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -843,6 +985,27 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -871,7 +1034,7 @@ def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -925,6 +1088,27 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2.Queue.state] is [PAUSED][google.cloud.tasks.v2.Queue.State.PAUSED]. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.PauseQueueRequest, dict]): The request object. Request message for @@ -953,7 +1137,7 @@ def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1014,6 +1198,27 @@ def resume_queue( Scaling Risks `__. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -1042,7 +1247,7 @@ def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1097,6 +1302,27 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1176,7 +1402,7 @@ def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1234,6 +1460,27 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1313,7 +1560,7 @@ def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1368,6 +1615,28 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1401,7 +1670,7 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1458,6 +1727,28 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1486,7 +1777,7 @@ def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1539,6 +1830,26 @@ def get_task( ) -> task.Task: r"""Gets a task. + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1562,7 +1873,7 @@ def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1615,6 +1926,27 @@ def create_task( - The maximum task size is 100KB. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1685,7 +2017,7 @@ def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1737,6 +2069,24 @@ def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. + + + .. code-block:: + + from google.cloud import tasks_v2 + + def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1756,7 +2106,7 @@ def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1828,6 +2178,27 @@ 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:: + + from google.cloud import tasks_v2 + + def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -1851,7 +2222,7 @@ def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: 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 47efb962..6cb898fb 100644 --- a/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2/services/cloud_tasks/transports/grpc.py @@ -166,8 +166,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 8a25d355..976507b1 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 @@ -211,8 +211,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 072eb6bd..7afbc95b 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -114,6 +114,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return CloudTasksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> CloudTasksTransport: """Returns the transport used by the client instance. @@ -186,6 +222,27 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ListQueuesRequest, dict]): The request object. Request message for @@ -213,7 +270,7 @@ async def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -276,6 +333,25 @@ async def get_queue( ) -> queue.Queue: r"""Gets a queue. + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.GetQueueRequest, dict]): The request object. Request message for @@ -304,7 +380,7 @@ async def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -372,6 +448,26 @@ async def create_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CreateQueueRequest, dict]): The request object. Request message for @@ -414,7 +510,7 @@ async def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -477,6 +573,25 @@ async def update_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -523,7 +638,7 @@ async def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -585,6 +700,23 @@ async def delete_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -603,7 +735,7 @@ async def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -664,6 +796,26 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -692,7 +844,7 @@ async def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -746,6 +898,26 @@ 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:: + + from google.cloud import tasks_v2beta2 + + def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.PauseQueueRequest, dict]): The request object. Request message for @@ -774,7 +946,7 @@ async def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -835,6 +1007,26 @@ async def resume_queue( Scaling Risks `__. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -863,7 +1055,7 @@ async def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -918,6 +1110,26 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -997,7 +1209,7 @@ async def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1066,6 +1278,26 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1145,7 +1377,7 @@ async def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1201,6 +1433,27 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1234,7 +1487,7 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1302,6 +1555,27 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1330,7 +1604,7 @@ async def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1393,6 +1667,25 @@ async def get_task( ) -> task.Task: r"""Gets a task. + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1416,7 +1709,7 @@ async def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1483,6 +1776,26 @@ async def create_task( - For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1553,7 +1866,7 @@ async def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1605,6 +1918,23 @@ async def delete_task( A task cannot be deleted if it has completed successfully or permanently failed. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1624,7 +1954,7 @@ async def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1704,6 +2034,26 @@ async def lease_tasks( [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = client.lease_tasks(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.LeaseTasksRequest, dict]): The request object. Request message for leasing tasks @@ -1759,7 +2109,7 @@ async def lease_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, lease_duration]) if request is not None and has_flattened_params: @@ -1823,6 +2173,23 @@ async def acknowledge_task( [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + client.acknowledge_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]): The request object. Request message for acknowledging a @@ -1856,7 +2223,7 @@ async def acknowledge_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time]) if request is not None and has_flattened_params: @@ -1911,6 +2278,26 @@ async def renew_lease( in the task's [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.renew_lease(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.RenewLeaseRequest, dict]): The request object. Request message for renewing a lease @@ -1958,7 +2345,7 @@ async def renew_lease( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time, lease_duration]) if request is not None and has_flattened_params: @@ -2017,6 +2404,26 @@ async def cancel_lease( next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.cancel_lease(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CancelLeaseRequest, dict]): The request object. Request message for canceling a @@ -2054,7 +2461,7 @@ async def cancel_lease( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time]) if request is not None and has_flattened_params: @@ -2135,6 +2542,26 @@ async def run_task( be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage]. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -2158,7 +2585,7 @@ async def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py index 7188dc89..2a29ebac 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/client.py @@ -260,6 +260,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -310,57 +377,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, CloudTasksTransport): # transport is a CloudTasksTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -372,6 +404,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -396,6 +437,28 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ListQueuesRequest, dict]): The request object. Request message for @@ -423,7 +486,7 @@ def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -476,6 +539,26 @@ def get_queue( ) -> queue.Queue: r"""Gets a queue. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.GetQueueRequest, dict]): The request object. Request message for @@ -504,7 +587,7 @@ def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -562,6 +645,27 @@ def create_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CreateQueueRequest, dict]): The request object. Request message for @@ -604,7 +708,7 @@ def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -667,6 +771,26 @@ def update_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -713,7 +837,7 @@ def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -775,6 +899,24 @@ def delete_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -793,7 +935,7 @@ def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -844,6 +986,27 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -872,7 +1035,7 @@ def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -926,6 +1089,27 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2beta2.Queue.state] is [PAUSED][google.cloud.tasks.v2beta2.Queue.State.PAUSED]. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.PauseQueueRequest, dict]): The request object. Request message for @@ -954,7 +1138,7 @@ def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1015,6 +1199,27 @@ def resume_queue( Scaling Risks `__. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -1043,7 +1248,7 @@ def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1098,6 +1303,27 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1177,7 +1403,7 @@ def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1235,6 +1461,27 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1314,7 +1561,7 @@ def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1369,6 +1616,28 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1402,7 +1671,7 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1459,6 +1728,28 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1487,7 +1778,7 @@ def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1540,6 +1831,26 @@ def get_task( ) -> task.Task: r"""Gets a task. + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1563,7 +1874,7 @@ def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1620,6 +1931,27 @@ def create_task( - For [pull queues][google.cloud.tasks.v2beta2.PullTarget], the maximum task size is 1MB. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1690,7 +2022,7 @@ def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1742,6 +2074,24 @@ def delete_task( A task cannot be deleted if it has completed successfully or permanently failed. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1761,7 +2111,7 @@ def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1831,6 +2181,27 @@ def lease_tasks( [max_tasks_dispatched_per_second][google.cloud.tasks.v2beta2.RateLimits.max_tasks_dispatched_per_second] is exceeded. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = client.lease_tasks(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.LeaseTasksRequest, dict]): The request object. Request message for leasing tasks @@ -1886,7 +2257,7 @@ def lease_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, lease_duration]) if request is not None and has_flattened_params: @@ -1950,6 +2321,24 @@ def acknowledge_task( [GetTask][google.cloud.tasks.v2beta2.CloudTasks.GetTask], or [ListTasks][google.cloud.tasks.v2beta2.CloudTasks.ListTasks]. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + client.acknowledge_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta2.types.AcknowledgeTaskRequest, dict]): The request object. Request message for acknowledging a @@ -1983,7 +2372,7 @@ def acknowledge_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time]) if request is not None and has_flattened_params: @@ -2038,6 +2427,27 @@ def renew_lease( in the task's [schedule_time][google.cloud.tasks.v2beta2.Task.schedule_time]. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.renew_lease(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.RenewLeaseRequest, dict]): The request object. Request message for renewing a lease @@ -2085,7 +2495,7 @@ def renew_lease( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time, lease_duration]) if request is not None and has_flattened_params: @@ -2144,6 +2554,27 @@ def cancel_lease( next caller of [LeaseTasks][google.cloud.tasks.v2beta2.CloudTasks.LeaseTasks]. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.cancel_lease(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.CancelLeaseRequest, dict]): The request object. Request message for canceling a @@ -2181,7 +2612,7 @@ def cancel_lease( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name, schedule_time]) if request is not None and has_flattened_params: @@ -2262,6 +2693,27 @@ def run_task( be called on a [pull task][google.cloud.tasks.v2beta2.PullMessage]. + + + .. code-block:: + + from google.cloud import tasks_v2beta2 + + def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta2.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -2285,7 +2737,7 @@ def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: 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 a5b58157..2f5af17a 100644 --- a/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2beta2/services/cloud_tasks/transports/grpc.py @@ -166,8 +166,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 c58456b2..27513cd4 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 @@ -211,8 +211,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 e65ae368..83d42849 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/async_client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Sequence, Tuple, Type, Union +from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -114,6 +114,42 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): from_service_account_json = from_service_account_file + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + return CloudTasksClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> CloudTasksTransport: """Returns the transport used by the client instance. @@ -186,6 +222,27 @@ async def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ListQueuesRequest, dict]): The request object. Request message for @@ -213,7 +270,7 @@ async def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -276,6 +333,25 @@ async def get_queue( ) -> queue.Queue: r"""Gets a queue. + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.GetQueueRequest, dict]): The request object. Request message for @@ -304,7 +380,7 @@ async def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -372,6 +448,26 @@ async def create_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.CreateQueueRequest, dict]): The request object. Request message for @@ -414,7 +510,7 @@ async def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -477,6 +573,25 @@ async def update_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -523,7 +638,7 @@ async def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -585,6 +700,23 @@ async def delete_queue( queue.yaml `__ before using this method. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -603,7 +735,7 @@ async def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -664,6 +796,26 @@ async def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -692,7 +844,7 @@ async def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -746,6 +898,26 @@ 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:: + + from google.cloud import tasks_v2beta3 + + def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.PauseQueueRequest, dict]): The request object. Request message for @@ -774,7 +946,7 @@ async def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -835,6 +1007,26 @@ async def resume_queue( Scaling Risks `__. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -863,7 +1055,7 @@ async def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -918,6 +1110,26 @@ async def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -997,7 +1209,7 @@ async def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1066,6 +1278,26 @@ async def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1145,7 +1377,7 @@ async def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1201,6 +1433,27 @@ async def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1234,7 +1487,7 @@ async def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1302,6 +1555,27 @@ async def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1330,7 +1604,7 @@ async def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1393,6 +1667,25 @@ async def get_task( ) -> task.Task: r"""Gets a task. + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1416,7 +1709,7 @@ async def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1479,6 +1772,26 @@ async def create_task( - The maximum task size is 100KB. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1549,7 +1862,7 @@ async def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1601,6 +1914,23 @@ async def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1620,7 +1950,7 @@ async def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1703,6 +2033,26 @@ 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:: + + from google.cloud import tasks_v2beta3 + + def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -1726,7 +2076,7 @@ async def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: diff --git a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py index 1012117c..b6474ad0 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/client.py @@ -260,6 +260,73 @@ def parse_common_location_path(path: str) -> Dict[str, str]: m = re.match(r"^projects/(?P.+?)/locations/(?P.+?)$", path) return m.groupdict() if m else {} + @classmethod + def get_mtls_endpoint_and_cert_source( + cls, client_options: Optional[client_options_lib.ClientOptions] = None + ): + """Return the API endpoint and client cert source for mutual TLS. + + The client cert source is determined in the following order: + (1) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is not "true", the + client cert source is None. + (2) if `client_options.client_cert_source` is provided, use the provided one; if the + default client cert source exists, use the default one; otherwise the client cert + source is None. + + The API endpoint is determined in the following order: + (1) if `client_options.api_endpoint` if provided, use the provided one. + (2) if `GOOGLE_API_USE_CLIENT_CERTIFICATE` environment variable is "always", use the + default mTLS endpoint; if the environment variabel is "never", use the default API + endpoint; otherwise if client cert source exists, use the default mTLS endpoint, otherwise + use the default API endpoint. + + More details can be found at https://google.aip.dev/auth/4114. + + Args: + client_options (google.api_core.client_options.ClientOptions): Custom options for the + client. Only the `api_endpoint` and `client_cert_source` properties may be used + in this method. + + Returns: + Tuple[str, Callable[[], Tuple[bytes, bytes]]]: returns the API endpoint and the + client cert source to use. + + Raises: + google.auth.exceptions.MutualTLSChannelError: If any errors happen. + """ + if client_options is None: + client_options = client_options_lib.ClientOptions() + use_client_cert = os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") + use_mtls_endpoint = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") + if use_client_cert not in ("true", "false"): + raise ValueError( + "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" + ) + if use_mtls_endpoint not in ("auto", "never", "always"): + raise MutualTLSChannelError( + "Environment variable `GOOGLE_API_USE_MTLS_ENDPOINT` must be `never`, `auto` or `always`" + ) + + # Figure out the client cert source to use. + client_cert_source = None + if use_client_cert == "true": + if client_options.client_cert_source: + client_cert_source = client_options.client_cert_source + elif mtls.has_default_client_cert_source(): + client_cert_source = mtls.default_client_cert_source() + + # Figure out which api endpoint to use. + if client_options.api_endpoint is not None: + api_endpoint = client_options.api_endpoint + elif use_mtls_endpoint == "always" or ( + use_mtls_endpoint == "auto" and client_cert_source + ): + api_endpoint = cls.DEFAULT_MTLS_ENDPOINT + else: + api_endpoint = cls.DEFAULT_ENDPOINT + + return api_endpoint, client_cert_source + def __init__( self, *, @@ -310,57 +377,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - if os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") not in ( - "true", - "false", - ): - raise ValueError( - "Environment variable `GOOGLE_API_USE_CLIENT_CERTIFICATE` must be either `true` or `false`" - ) - use_client_cert = ( - os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true" + api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source( + client_options ) - client_cert_source_func = None - is_mtls = False - if use_client_cert: - if client_options.client_cert_source: - is_mtls = True - client_cert_source_func = client_options.client_cert_source - else: - is_mtls = mtls.has_default_client_cert_source() - if is_mtls: - client_cert_source_func = mtls.default_client_cert_source() - else: - client_cert_source_func = None - - # Figure out which api endpoint to use. - if client_options.api_endpoint is not None: - api_endpoint = client_options.api_endpoint - else: - use_mtls_env = os.getenv("GOOGLE_API_USE_MTLS_ENDPOINT", "auto") - if use_mtls_env == "never": - api_endpoint = self.DEFAULT_ENDPOINT - elif use_mtls_env == "always": - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - elif use_mtls_env == "auto": - if is_mtls: - api_endpoint = self.DEFAULT_MTLS_ENDPOINT - else: - api_endpoint = self.DEFAULT_ENDPOINT - else: - raise MutualTLSChannelError( - "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " - "values: never, auto, always" - ) + api_key_value = getattr(client_options, "api_key", None) + if api_key_value and credentials: + raise ValueError( + "client_options.api_key and credentials are mutually exclusive" + ) # Save or instantiate the transport. # Ordinarily, we provide the transport, but allowing a custom transport # instance provides an extensibility point for unusual situations. if isinstance(transport, CloudTasksTransport): # transport is a CloudTasksTransport instance. - if credentials or client_options.credentials_file: + if credentials or client_options.credentials_file or api_key_value: raise ValueError( "When providing a transport instance, " "provide its credentials directly." @@ -372,6 +404,15 @@ def __init__( ) self._transport = transport else: + import google.auth._default # type: ignore + + if api_key_value and hasattr( + google.auth._default, "get_api_key_credentials" + ): + credentials = google.auth._default.get_api_key_credentials( + api_key_value + ) + Transport = type(self).get_transport_class(transport) self._transport = Transport( credentials=credentials, @@ -396,6 +437,28 @@ def list_queues( r"""Lists queues. Queues are returned in lexicographical order. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ListQueuesRequest, dict]): The request object. Request message for @@ -423,7 +486,7 @@ def list_queues( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -476,6 +539,26 @@ def get_queue( ) -> queue.Queue: r"""Gets a queue. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.GetQueueRequest, dict]): The request object. Request message for @@ -504,7 +587,7 @@ def get_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -562,6 +645,27 @@ def create_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.CreateQueueRequest, dict]): The request object. Request message for @@ -604,7 +708,7 @@ def create_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, queue]) if request is not None and has_flattened_params: @@ -667,6 +771,26 @@ def update_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.UpdateQueueRequest, dict]): The request object. Request message for @@ -713,7 +837,7 @@ def update_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([queue, update_mask]) if request is not None and has_flattened_params: @@ -775,6 +899,24 @@ def delete_queue( queue.yaml `__ before using this method. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteQueueRequest, dict]): The request object. Request message for @@ -793,7 +935,7 @@ def delete_queue( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -844,6 +986,27 @@ def purge_queue( effect. Tasks might be dispatched before the purge takes effect. A purge is irreversible. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.PurgeQueueRequest, dict]): The request object. Request message for @@ -872,7 +1035,7 @@ def purge_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -926,6 +1089,27 @@ def pause_queue( paused if its [state][google.cloud.tasks.v2beta3.Queue.state] is [PAUSED][google.cloud.tasks.v2beta3.Queue.State.PAUSED]. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.PauseQueueRequest, dict]): The request object. Request message for @@ -954,7 +1138,7 @@ def pause_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1015,6 +1199,27 @@ def resume_queue( Scaling Risks `__. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ResumeQueueRequest, dict]): The request object. Request message for @@ -1043,7 +1248,7 @@ def resume_queue( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1098,6 +1303,27 @@ def get_iam_policy( - ``cloudtasks.queues.getIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.GetIamPolicyRequest, dict]): The request object. Request message for `GetIamPolicy` @@ -1177,7 +1403,7 @@ def get_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1235,6 +1461,27 @@ def set_iam_policy( - ``cloudtasks.queues.setIamPolicy`` + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.SetIamPolicyRequest, dict]): The request object. Request message for `SetIamPolicy` @@ -1314,7 +1561,7 @@ def set_iam_policy( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource]) if request is not None and has_flattened_params: @@ -1369,6 +1616,28 @@ def test_iam_permissions( authorization checking. This operation may "fail open" without warning. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + Args: request (Union[google.iam.v1.iam_policy_pb2.TestIamPermissionsRequest, dict]): The request object. Request message for @@ -1402,7 +1671,7 @@ def test_iam_permissions( Response message for TestIamPermissions method. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([resource, permissions]) if request is not None and has_flattened_params: @@ -1459,6 +1728,28 @@ def list_tasks( The tasks may be returned in any order. The ordering may change at any time. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.ListTasksRequest, dict]): The request object. Request message for listing tasks @@ -1487,7 +1778,7 @@ def list_tasks( """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent]) if request is not None and has_flattened_params: @@ -1540,6 +1831,26 @@ def get_task( ) -> task.Task: r"""Gets a task. + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.GetTaskRequest, dict]): The request object. Request message for getting a task @@ -1563,7 +1874,7 @@ def get_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1616,6 +1927,27 @@ def create_task( - The maximum task size is 100KB. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.CreateTaskRequest, dict]): The request object. Request message for @@ -1686,7 +2018,7 @@ def create_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([parent, task]) if request is not None and has_flattened_params: @@ -1738,6 +2070,24 @@ def delete_task( A task cannot be deleted if it has executed successfully or permanently failed. + + + .. code-block:: + + from google.cloud import tasks_v2beta3 + + def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + Args: request (Union[google.cloud.tasks_v2beta3.types.DeleteTaskRequest, dict]): The request object. Request message for deleting a task @@ -1757,7 +2107,7 @@ def delete_task( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: @@ -1830,6 +2180,27 @@ 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:: + + from google.cloud import tasks_v2beta3 + + def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.tasks_v2beta3.types.RunTaskRequest, dict]): The request object. Request message for forcing a task @@ -1853,7 +2224,7 @@ def run_task( A unit of scheduled work. """ # Create or coerce a protobuf request object. - # Sanity check: If we got a request object, we should *not* have + # Quick check: If we got a request object, we should *not* have # gotten any keyword arguments that map to the request. has_flattened_params = any([name]) if request is not None and has_flattened_params: 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 3f0bb485..550340d8 100644 --- a/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py +++ b/google/cloud/tasks_v2beta3/services/cloud_tasks/transports/grpc.py @@ -166,8 +166,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, 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 faad7554..44bf7fd3 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 @@ -211,8 +211,11 @@ def __init__( if not self._grpc_channel: self._grpc_channel = type(self).create_channel( self._host, + # use the credentials which are saved credentials=self._credentials, - credentials_file=credentials_file, + # Set ``credentials_file`` to ``None`` here as + # the credentials that we saved earlier should be used. + credentials_file=None, scopes=self._scopes, ssl_credentials=self._ssl_channel_credentials, quota_project_id=quota_project_id, diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_async.py new file mode 100644 index 00000000..7a394885 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_async] +from google.cloud import tasks_v2 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_sync.py new file mode 100644 index 00000000..33ac4e28 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_sync] +from google.cloud import tasks_v2 + + +def sample_create_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_async.py new file mode 100644 index 00000000..768adef2 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_async] +from google.cloud import tasks_v2 + + +async def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_sync.py new file mode 100644 index 00000000..bb120206 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_create_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_sync] +from google.cloud import tasks_v2 + + +def sample_create_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_async.py new file mode 100644 index 00000000..ed8e8e46 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_async] +from google.cloud import tasks_v2 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_sync.py new file mode 100644 index 00000000..7a9cdf70 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_sync] +from google.cloud import tasks_v2 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_async.py new file mode 100644 index 00000000..a541ee3e --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_async] +from google.cloud import tasks_v2 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_sync.py new file mode 100644 index 00000000..e08e68f0 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_sync] +from google.cloud import tasks_v2 + + +def sample_delete_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 00000000..122d7a71 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_async] +from google.cloud import tasks_v2 + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 00000000..f0c82dd8 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_sync] +from google.cloud import tasks_v2 + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_async.py new file mode 100644 index 00000000..3e3ab398 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_async] +from google.cloud import tasks_v2 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_sync.py new file mode 100644 index 00000000..726f9fad --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_sync] +from google.cloud import tasks_v2 + + +def sample_get_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_async.py new file mode 100644 index 00000000..448b385e --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetTask_async] +from google.cloud import tasks_v2 + + +async def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_sync.py new file mode 100644 index 00000000..edab8572 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_get_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_GetTask_sync] +from google.cloud import tasks_v2 + + +def sample_get_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_GetTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_async.py new file mode 100644 index 00000000..8af6815f --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_async] +from google.cloud import tasks_v2 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_sync.py new file mode 100644 index 00000000..3f8d4bb8 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_sync] +from google.cloud import tasks_v2 + + +def sample_list_queues(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_async.py new file mode 100644 index 00000000..a396219f --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_async] +from google.cloud import tasks_v2 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_sync.py new file mode 100644 index 00000000..7fb16521 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_sync] +from google.cloud import tasks_v2 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_async.py new file mode 100644 index 00000000..8c3cdb18 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_async] +from google.cloud import tasks_v2 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_sync.py new file mode 100644 index 00000000..63444e5c --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_sync] +from google.cloud import tasks_v2 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_async.py new file mode 100644 index 00000000..c59e7080 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_async] +from google.cloud import tasks_v2 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_sync.py new file mode 100644 index 00000000..51240ca1 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_sync] +from google.cloud import tasks_v2 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_async.py new file mode 100644 index 00000000..227dc425 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_async] +from google.cloud import tasks_v2 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_sync.py new file mode 100644 index 00000000..01dc3292 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_sync] +from google.cloud import tasks_v2 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_async.py new file mode 100644 index 00000000..8aae851a --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_RunTask_async] +from google.cloud import tasks_v2 + + +async def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_RunTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_sync.py new file mode 100644 index 00000000..8a885ccc --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_run_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_RunTask_sync] +from google.cloud import tasks_v2 + + +def sample_run_task(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_RunTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 00000000..9b599bda --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_async] +from google.cloud import tasks_v2 + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 00000000..09d7b434 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_sync] +from google.cloud import tasks_v2 + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 00000000..87419265 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_async] +from google.cloud import tasks_v2 + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 00000000..1c26e2d3 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_sync] +from google.cloud import tasks_v2 + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_async.py new file mode 100644 index 00000000..a6c8bc09 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_async] +from google.cloud import tasks_v2 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_sync.py new file mode 100644 index 00000000..65f0af17 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_sync] +from google.cloud import tasks_v2 + + +def sample_update_queue(): + # Create a client + client = tasks_v2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_async.py new file mode 100644 index 00000000..4feba15d --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AcknowledgeTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_async] +from google.cloud import tasks_v2beta2 + + +async def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + await client.acknowledge_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_sync.py new file mode 100644 index 00000000..e0388b24 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for AcknowledgeTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_sync] +from google.cloud import tasks_v2beta2 + + +def sample_acknowledge_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.AcknowledgeTaskRequest( + name="name_value", + ) + + # Make the request + client.acknowledge_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_async.py new file mode 100644 index 00000000..c49c0609 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CancelLease +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_async] +from google.cloud import tasks_v2beta2 + + +async def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = await client.cancel_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_sync.py new file mode 100644 index 00000000..bee63f63 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CancelLease +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_sync] +from google.cloud import tasks_v2beta2 + + +def sample_cancel_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CancelLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.cancel_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_async.py new file mode 100644 index 00000000..f0aebedf --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_sync.py new file mode 100644 index 00000000..0fa73006 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_create_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_async.py new file mode 100644 index 00000000..8e98e233 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_async] +from google.cloud import tasks_v2beta2 + + +async def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_sync.py new file mode 100644 index 00000000..80101f53 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_sync] +from google.cloud import tasks_v2beta2 + + +def sample_create_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_async.py new file mode 100644 index 00000000..494e8f3c --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_sync.py new file mode 100644 index 00000000..f8cb30ac --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_async.py new file mode 100644 index 00000000..f5ae4a6a --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_async] +from google.cloud import tasks_v2beta2 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_sync.py new file mode 100644 index 00000000..846270fb --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_sync] +from google.cloud import tasks_v2beta2 + + +def sample_delete_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 00000000..0101abee --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_async] +from google.cloud import tasks_v2beta2 + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 00000000..a6fe34a4 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_sync] +from google.cloud import tasks_v2beta2 + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_async.py new file mode 100644 index 00000000..51d449fb --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_sync.py new file mode 100644 index 00000000..5fd69edb --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_get_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_async.py new file mode 100644 index 00000000..8257d8e5 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_async] +from google.cloud import tasks_v2beta2 + + +async def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_sync.py new file mode 100644 index 00000000..edfa875d --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_sync] +from google.cloud import tasks_v2beta2 + + +def sample_get_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_async.py new file mode 100644 index 00000000..608add9b --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LeaseTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_async] +from google.cloud import tasks_v2beta2 + + +async def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = await client.lease_tasks(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_sync.py new file mode 100644 index 00000000..caab21e9 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for LeaseTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_sync] +from google.cloud import tasks_v2beta2 + + +def sample_lease_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.LeaseTasksRequest( + parent="parent_value", + ) + + # Make the request + response = client.lease_tasks(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_async.py new file mode 100644 index 00000000..132cd471 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_async] +from google.cloud import tasks_v2beta2 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_sync.py new file mode 100644 index 00000000..1bc6fa8e --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_sync] +from google.cloud import tasks_v2beta2 + + +def sample_list_queues(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_async.py new file mode 100644 index 00000000..54a01f23 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_async] +from google.cloud import tasks_v2beta2 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_sync.py new file mode 100644 index 00000000..2d4484d4 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_sync] +from google.cloud import tasks_v2beta2 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_async.py new file mode 100644 index 00000000..af15fcd6 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_sync.py new file mode 100644 index 00000000..361473af --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_async.py new file mode 100644 index 00000000..bb6fd101 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_sync.py new file mode 100644 index 00000000..61548d97 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_async.py new file mode 100644 index 00000000..edf97861 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RenewLease +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_async] +from google.cloud import tasks_v2beta2 + + +async def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = await client.renew_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_sync.py new file mode 100644 index 00000000..f7b95e17 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RenewLease +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_sync] +from google.cloud import tasks_v2beta2 + + +def sample_renew_lease(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RenewLeaseRequest( + name="name_value", + ) + + # Make the request + response = client.renew_lease(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_async.py new file mode 100644 index 00000000..15eea3d0 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_sync.py new file mode 100644 index 00000000..3552c2ff --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_async.py new file mode 100644 index 00000000..c4c157cb --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_async] +from google.cloud import tasks_v2beta2 + + +async def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_sync.py new file mode 100644 index 00000000..2cc916f3 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_sync] +from google.cloud import tasks_v2beta2 + + +def sample_run_task(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 00000000..d5c5e908 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_async] +from google.cloud import tasks_v2beta2 + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 00000000..0b28f1d6 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_sync] +from google.cloud import tasks_v2beta2 + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 00000000..74f2ff7c --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_async] +from google.cloud import tasks_v2beta2 + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 00000000..84190def --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_sync] +from google.cloud import tasks_v2beta2 + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_async.py new file mode 100644 index 00000000..7349b4cf --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_async] +from google.cloud import tasks_v2beta2 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_sync.py new file mode 100644 index 00000000..4f8e1104 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_sync] +from google.cloud import tasks_v2beta2 + + +def sample_update_queue(): + # Create a client + client = tasks_v2beta2.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta2.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_async.py new file mode 100644 index 00000000..66ddf77c --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_sync.py new file mode 100644 index 00000000..2648c76b --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_create_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateQueueRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_async.py new file mode 100644 index 00000000..b197a58b --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_async] +from google.cloud import tasks_v2beta3 + + +async def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = await client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_sync.py new file mode 100644 index 00000000..450f6435 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_sync] +from google.cloud import tasks_v2beta3 + + +def sample_create_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.CreateTaskRequest( + parent="parent_value", + ) + + # Make the request + response = client.create_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_async.py new file mode 100644 index 00000000..bd5905a5 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + await client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_sync.py new file mode 100644 index 00000000..9b1c6c11 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_delete_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteQueueRequest( + name="name_value", + ) + + # Make the request + client.delete_queue(request=request) + + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_async.py new file mode 100644 index 00000000..5c2decc0 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_async.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_async] +from google.cloud import tasks_v2beta3 + + +async def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + await client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_sync.py new file mode 100644 index 00000000..45bab213 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_sync.py @@ -0,0 +1,43 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_sync] +from google.cloud import tasks_v2beta3 + + +def sample_delete_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.DeleteTaskRequest( + name="name_value", + ) + + # Make the request + client.delete_task(request=request) + + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_async.py new file mode 100644 index 00000000..68bc0446 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_async] +from google.cloud import tasks_v2beta3 + + +async def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_sync.py new file mode 100644 index 00000000..cea61282 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_sync] +from google.cloud import tasks_v2beta3 + + +def sample_get_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.get_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_async.py new file mode 100644 index 00000000..bc7992f8 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_sync.py new file mode 100644 index 00000000..23f15f97 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_get_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetQueueRequest( + name="name_value", + ) + + # Make the request + response = client.get_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_async.py new file mode 100644 index 00000000..88b6c9a3 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_async] +from google.cloud import tasks_v2beta3 + + +async def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_sync.py new file mode 100644 index 00000000..9f90fc21 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_sync] +from google.cloud import tasks_v2beta3 + + +def sample_get_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.GetTaskRequest( + name="name_value", + ) + + # Make the request + response = client.get_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_async.py new file mode 100644 index 00000000..cc1b8000 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_async] +from google.cloud import tasks_v2beta3 + + +async def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_sync.py new file mode 100644 index 00000000..d1e2fc4a --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListQueues +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_sync] +from google.cloud import tasks_v2beta3 + + +def sample_list_queues(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListQueuesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_queues(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_async.py new file mode 100644 index 00000000..bd00a508 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_async] +from google.cloud import tasks_v2beta3 + + +async def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_sync.py new file mode 100644 index 00000000..798c831a --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTasks +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_sync] +from google.cloud import tasks_v2beta3 + + +def sample_list_tasks(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ListTasksRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_tasks(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_async.py new file mode 100644 index 00000000..3f9e9dba --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_sync.py new file mode 100644 index 00000000..70b13afb --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PauseQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_pause_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PauseQueueRequest( + name="name_value", + ) + + # Make the request + response = client.pause_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_async.py new file mode 100644 index 00000000..d6fe86b5 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_sync.py new file mode 100644 index 00000000..ca224c23 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for PurgeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_purge_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.PurgeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.purge_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_async.py new file mode 100644 index 00000000..8d6df0ba --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = await client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_sync.py new file mode 100644 index 00000000..b64a7ae1 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ResumeQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_resume_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.ResumeQueueRequest( + name="name_value", + ) + + # Make the request + response = client.resume_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_async.py new file mode 100644 index 00000000..7d015ec8 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_async] +from google.cloud import tasks_v2beta3 + + +async def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = await client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_sync.py new file mode 100644 index 00000000..3b9bebf2 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for RunTask +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_sync] +from google.cloud import tasks_v2beta3 + + +def sample_run_task(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.RunTaskRequest( + name="name_value", + ) + + # Make the request + response = client.run_task(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_async.py new file mode 100644 index 00000000..50752297 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_async] +from google.cloud import tasks_v2beta3 + + +async def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = await client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_sync.py new file mode 100644 index 00000000..3af365e1 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for SetIamPolicy +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_sync] +from google.cloud import tasks_v2beta3 + + +def sample_set_iam_policy(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.SetIamPolicyRequest( + resource="resource_value", + ) + + # Make the request + response = client.set_iam_policy(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_async.py new file mode 100644 index 00000000..009d0f85 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_async] +from google.cloud import tasks_v2beta3 + + +async def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = await client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_sync.py new file mode 100644 index 00000000..07541ae9 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for TestIamPermissions +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_sync] +from google.cloud import tasks_v2beta3 + + +def sample_test_iam_permissions(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.TestIamPermissionsRequest( + resource="resource_value", + permissions=['permissions_value_1', 'permissions_value_2'], + ) + + # Make the request + response = client.test_iam_permissions(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_sync] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_async.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_async.py new file mode 100644 index 00000000..9717e0b9 --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_async.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_async] +from google.cloud import tasks_v2beta3 + + +async def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksAsyncClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = await client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_async] diff --git a/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_sync.py b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_sync.py new file mode 100644 index 00000000..8e08d95d --- /dev/null +++ b/samples/generated_samples/cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_sync.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateQueue +# NOTE: This snippet has been automatically generated for illustrative purposes only. +# It may require modifications to work in your environment. + +# To install the latest published package dependency, execute the following: +# python3 -m pip install google-cloud-tasks + + +# [START cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_sync] +from google.cloud import tasks_v2beta3 + + +def sample_update_queue(): + # Create a client + client = tasks_v2beta3.CloudTasksClient() + + # Initialize request argument(s) + request = tasks_v2beta3.UpdateQueueRequest( + ) + + # Make the request + response = client.update_queue(request=request) + + # Handle the response + print(response) + +# [END cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_sync] diff --git a/samples/generated_samples/snippet_metadata_tasks_v2.json b/samples/generated_samples/snippet_metadata_tasks_v2.json new file mode 100644 index 00000000..f00a313e --- /dev/null +++ b/samples/generated_samples/snippet_metadata_tasks_v2.json @@ -0,0 +1,1420 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_create_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_CreateQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_create_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_create_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_CreateTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_delete_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_delete_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_get_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_GetTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_list_queues_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ListQueues_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_list_tasks_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ListTasks_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_pause_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_PauseQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_purge_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_PurgeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_resume_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_ResumeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_run_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_RunTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_run_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_RunTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_set_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_test_iam_permissions_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2_cloud_tasks_update_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_tasks_v2beta2.json b/samples/generated_samples/snippet_metadata_tasks_v2beta2.json new file mode 100644 index 00000000..967ebf31 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_tasks_v2beta2.json @@ -0,0 +1,1772 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "AcknowledgeTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "AcknowledgeTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_acknowledge_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_AcknowledgeTask_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CancelLease" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CancelLease" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_cancel_lease_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CancelLease_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_create_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_CreateTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_delete_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_get_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_GetTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "LeaseTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "LeaseTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_lease_tasks_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_LeaseTasks_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_queues_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ListQueues_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_list_tasks_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ListTasks_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_pause_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_PauseQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_purge_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_PurgeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RenewLease" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RenewLease" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_renew_lease_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_RenewLease_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_resume_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_ResumeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_run_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_RunTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_set_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_test_iam_permissions_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta2_cloud_tasks_update_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta2_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/generated_samples/snippet_metadata_tasks_v2beta3.json b/samples/generated_samples/snippet_metadata_tasks_v2beta3.json new file mode 100644 index 00000000..0ce28a65 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_tasks_v2beta3.json @@ -0,0 +1,1420 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "CreateTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_create_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_CreateTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteQueue_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_async", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "DeleteTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_delete_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_DeleteTask_sync", + "segments": [ + { + "end": 42, + "start": 27, + "type": "FULL" + }, + { + "end": 42, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "GetTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_get_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_GetTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListQueues" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_queues_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ListQueues_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ListTasks" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_list_tasks_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ListTasks_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PauseQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_pause_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_PauseQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "PurgeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_purge_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_PurgeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "ResumeQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_resume_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_ResumeQueue_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "RunTask" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_run_task_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_RunTask_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_async", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "SetIamPolicy" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_set_iam_policy_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_SetIamPolicy_sync", + "segments": [ + { + "end": 44, + "start": 27, + "type": "FULL" + }, + { + "end": 44, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 41, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 45, + "start": 42, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_async", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "TestIamPermissions" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_test_iam_permissions_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_TestIamPermissions_sync", + "segments": [ + { + "end": 45, + "start": 27, + "type": "FULL" + }, + { + "end": 45, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 42, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 46, + "start": 43, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_async.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_async", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudTasks" + }, + "shortName": "UpdateQueue" + } + }, + "file": "cloudtasks_generated_tasks_v2beta3_cloud_tasks_update_queue_sync.py", + "regionTag": "cloudtasks_generated_tasks_v2beta3_CloudTasks_UpdateQueue_sync", + "segments": [ + { + "end": 43, + "start": 27, + "type": "FULL" + }, + { + "end": 43, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 40, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 44, + "start": 41, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/samples/snippets/create_http_task.py b/samples/snippets/create_http_task.py index e6d7435e..40e735b3 100644 --- a/samples/snippets/create_http_task.py +++ b/samples/snippets/create_http_task.py @@ -18,13 +18,20 @@ def create_http_task( - project, queue, location, url, payload=None, in_seconds=None, task_name=None + project, + queue, + location, + url, + payload=None, + in_seconds=None, + task_name=None, + deadline=None, ): # [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 + from google.protobuf import timestamp_pb2, duration_pb2 import datetime import json @@ -39,6 +46,7 @@ def create_http_task( # payload = 'hello' or {'param': 'value'} for application/json # in_seconds = 180 # task_name = 'my-unique-task' + # deadline = 900 # Construct the fully qualified queue name. parent = client.queue_path(project, location, queue) @@ -78,6 +86,11 @@ def create_http_task( # Add the name to tasks. task["name"] = client.task_path(project, location, queue, task_name) + if deadline is not None: + # Add dispatch deadline for requests sent to the worker. + duration = duration_pb2.Duration() + task["dispatch_deadline"] = duration.FromSeconds(deadline) + # Use the client to build and send the task. response = client.create_task(request={"parent": parent, "task": task}) diff --git a/samples/snippets/create_http_task_test.py b/samples/snippets/create_http_task_test.py index 20cfced9..a66f3287 100644 --- a/samples/snippets/create_http_task_test.py +++ b/samples/snippets/create_http_task_test.py @@ -46,3 +46,15 @@ def test_create_http_task(test_queue): TEST_PROJECT_ID, TEST_QUEUE_NAME, TEST_LOCATION, url ) assert TEST_QUEUE_NAME in result.name + + result = create_http_task.create_http_task( + TEST_PROJECT_ID, + TEST_QUEUE_NAME, + TEST_LOCATION, + url, + payload="hello", + in_seconds=180, + task_name=uuid.uuid4().hex, + deadline=900, + ) + assert TEST_QUEUE_NAME in result.name diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 3bbef5d5..20cdfc62 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -187,6 +187,7 @@ def _session_tests( ) -> None: # check for presence of tests test_list = glob.glob("*_test.py") + glob.glob("test_*.py") + test_list.extend(glob.glob("tests")) if len(test_list) == 0: print("No tests found, skipping directory.") else: diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 92709451..c2845bff 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==6.2.5 +pytest==7.0.1 diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 912c8dda..4128ab74 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1 +1 @@ -google-cloud-tasks==2.7.1 +google-cloud-tasks==2.7.2 diff --git a/setup.py b/setup.py index a99bf79e..c59bb405 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ name = "google-cloud-tasks" description = "Cloud Tasks API API client library" -version = "2.7.2" +version = "2.8.0" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ # NOTE: Maintainers, please do not require google-api-core>=2.x.x diff --git a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py index 3c511e52..11c0444e 100644 --- a/tests/unit/gapic/tasks_v2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2/test_cloud_tasks.py @@ -398,6 +398,83 @@ def test_cloud_tasks_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient]) +@mock.patch.object( + CloudTasksClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudTasksClient) +) +@mock.patch.object( + CloudTasksAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(CloudTasksAsyncClient), +) +def test_cloud_tasks_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -430,21 +507,23 @@ def test_cloud_tasks_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc"), + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), ( CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_cloud_tasks_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -478,6 +557,67 @@ def test_cloud_tasks_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), + ( + CloudTasksAsyncClient, + transports.CloudTasksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_cloud_tasks_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "cloudtasks.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="cloudtasks.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( @@ -3997,6 +4137,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.CloudTasksGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.CloudTasksGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -4580,3 +4737,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport), + (CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py index 7613f45c..00fe29be 100644 --- a/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta2/test_cloud_tasks.py @@ -398,6 +398,83 @@ def test_cloud_tasks_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient]) +@mock.patch.object( + CloudTasksClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudTasksClient) +) +@mock.patch.object( + CloudTasksAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(CloudTasksAsyncClient), +) +def test_cloud_tasks_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -430,21 +507,23 @@ def test_cloud_tasks_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc"), + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), ( CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_cloud_tasks_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -478,6 +557,67 @@ def test_cloud_tasks_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), + ( + CloudTasksAsyncClient, + transports.CloudTasksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_cloud_tasks_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "cloudtasks.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="cloudtasks.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( @@ -4846,6 +4986,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.CloudTasksGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.CloudTasksGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -5433,3 +5590,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport), + (CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) diff --git a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py index 858eca12..ca3d61ce 100644 --- a/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py +++ b/tests/unit/gapic/tasks_v2beta3/test_cloud_tasks.py @@ -398,6 +398,83 @@ def test_cloud_tasks_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [CloudTasksClient, CloudTasksAsyncClient]) +@mock.patch.object( + CloudTasksClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudTasksClient) +) +@mock.patch.object( + CloudTasksAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(CloudTasksAsyncClient), +) +def test_cloud_tasks_client_get_mtls_endpoint_and_cert_source(client_class): + mock_client_cert_source = mock.Mock() + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "true". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source == mock_client_cert_source + + # Test the case GOOGLE_API_USE_CLIENT_CERTIFICATE is "false". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "false"}): + mock_client_cert_source = mock.Mock() + mock_api_endpoint = "foo" + options = client_options.ClientOptions( + client_cert_source=mock_client_cert_source, api_endpoint=mock_api_endpoint + ) + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source( + options + ) + assert api_endpoint == mock_api_endpoint + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "never". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "never"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "always". + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "always"}): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert doesn't exist. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=False, + ): + api_endpoint, cert_source = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_ENDPOINT + assert cert_source is None + + # Test the case GOOGLE_API_USE_MTLS_ENDPOINT is "auto" and default cert exists. + with mock.patch.dict(os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "true"}): + with mock.patch( + "google.auth.transport.mtls.has_default_client_cert_source", + return_value=True, + ): + with mock.patch( + "google.auth.transport.mtls.default_client_cert_source", + return_value=mock_client_cert_source, + ): + ( + api_endpoint, + cert_source, + ) = client_class.get_mtls_endpoint_and_cert_source() + assert api_endpoint == client_class.DEFAULT_MTLS_ENDPOINT + assert cert_source == mock_client_cert_source + + @pytest.mark.parametrize( "client_class,transport_class,transport_name", [ @@ -430,21 +507,23 @@ def test_cloud_tasks_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc"), + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), ( CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_cloud_tasks_client_client_options_credentials_file( - client_class, transport_class, transport_name + client_class, transport_class, transport_name, grpc_helpers ): # Check the case credentials file is provided. options = client_options.ClientOptions(credentials_file="credentials.json") + with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -478,6 +557,67 @@ def test_cloud_tasks_client_client_options_from_dict(): ) +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport, "grpc", grpc_helpers), + ( + CloudTasksAsyncClient, + transports.CloudTasksGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_cloud_tasks_client_create_channel_credentials_file( + client_class, transport_class, transport_name, grpc_helpers +): + # Check the case credentials file is provided. + options = client_options.ClientOptions(credentials_file="credentials.json") + + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options, transport=transport_name) + patched.assert_called_once_with( + credentials=None, + credentials_file="credentials.json", + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + ) + + # test that the credentials from file are saved and used as the credentials. + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel" + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + file_creds = ga_credentials.AnonymousCredentials() + load_creds.return_value = (file_creds, None) + adc.return_value = (creds, None) + client = client_class(client_options=options, transport=transport_name) + create_channel.assert_called_with( + "cloudtasks.googleapis.com:443", + credentials=file_creds, + credentials_file=None, + quota_project_id=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=None, + default_host="cloudtasks.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize("request_type", [cloudtasks.ListQueuesRequest, dict,]) def test_list_queues(request_type, transport: str = "grpc"): client = CloudTasksClient( @@ -4075,6 +4215,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.CloudTasksGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient(client_options=options, transport=transport,) + + # It is an error to provide an api_key and a credential. + options = mock.Mock() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudTasksClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.CloudTasksGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -4658,3 +4815,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (CloudTasksClient, transports.CloudTasksGrpcTransport), + (CloudTasksAsyncClient, transports.CloudTasksGrpcAsyncIOTransport), + ], +) +def test_api_key_credentials(client_class, transport_class): + with mock.patch.object( + google.auth._default, "get_api_key_credentials", create=True + ) as get_api_key_credentials: + mock_cred = mock.Mock() + get_api_key_credentials.return_value = mock_cred + options = client_options.ClientOptions() + options.api_key = "api_key" + with mock.patch.object(transport_class, "__init__") as patched: + patched.return_value = None + client = client_class(client_options=options) + patched.assert_called_once_with( + credentials=mock_cred, + credentials_file=None, + host=client.DEFAULT_ENDPOINT, + scopes=None, + client_cert_source_for_mtls=None, + quota_project_id=None, + client_info=transports.base.DEFAULT_CLIENT_INFO, + always_use_jwt_access=True, + )