diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 108063d..8cb4380 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -1,3 +1,16 @@ +# 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:4ee57a76a176ede9087c14330c625a71553cf9c72828b2c0ca12f5338171ba60 + digest: sha256:ed1f9983d5a935a89fe8085e8bb97d94e41015252c5b6c9771257cf8624367e6 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index be888a9..63a84c3 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -3,9 +3,10 @@ # # For syntax help see: # 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. -# The @googleapis/yoshi-python is the default owner for changes in this repo -* @googleapis/yoshi-python +# @googleapis/yoshi-python @googleapis/aap-dpes are the default owners for changes in this repo +* @googleapis/yoshi-python @googleapis/aap-dpes - -/samples/ @googleapis/python-samples-owners +# @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 4507ad0..466597e 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 0000000..d4ca941 --- /dev/null +++ b/.github/release-trigger.yml @@ -0,0 +1 @@ +enabled: true diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml new file mode 100644 index 0000000..f7b8344 --- /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 0000000..1e8b05c --- /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 0000000..074ee25 --- /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 7440566..af2f2dc 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-deploy 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 3c3b1cf..d9a70c2 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,8 +23,18 @@ env_vars: { value: "github/python-deploy/.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 ebdd10d..10387f2 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -2,14 +2,15 @@ "name": "clouddeploy", "name_pretty": "Google Cloud Deploy", "product_documentation": "https://cloud.google.com/deploy/", - "client_documentation": "https://googleapis.dev/python/clouddeploy/latest", + "client_documentation": "https://cloud.google.com/python/docs/reference/clouddeploy/latest", "issue_tracker": "", - "release_level": "ga", + "release_level": "stable", "language": "python", "library_type": "GAPIC_AUTO", "repo": "googleapis/python-deploy", "distribution_name": "google-cloud-deploy", "api_id": "clouddeploy.googleapis.com", "default_version": "v1", - "codeowner_team": "" + "codeowner_team": "@googleapis/aap-dpes", + "api_shortname": "clouddeploy" } diff --git a/CHANGELOG.md b/CHANGELOG.md index ee0d401..5240b68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## [1.1.0](https://github.com/googleapis/python-deploy/compare/v1.0.0...v1.1.0) (2022-02-26) + + +### Features + +* add api key support ([#35](https://github.com/googleapis/python-deploy/issues/35)) ([aaa957f](https://github.com/googleapis/python-deploy/commit/aaa957f2673db673c3a8e38275d4689323ded044)) + + +### Bug Fixes + +* resolve DuplicateCredentialArgs error when using credentials_file ([9bd690d](https://github.com/googleapis/python-deploy/commit/9bd690d27c07159059aa26a86df44e304dc431fd)) + ## [1.0.0](https://www.github.com/googleapis/python-deploy/compare/v0.3.0...v1.0.0) (2021-11-01) diff --git a/README.rst b/README.rst index 391b8d0..3f6c68b 100644 --- a/README.rst +++ b/README.rst @@ -17,7 +17,7 @@ Scale pipelines across your organization, while having a cross-project, central .. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-deploy.svg :target: https://pypi.org/project/google-cloud-deploy/ .. _Google Cloud Deploy: https://cloud.google.com/deploy -.. _Client Library Documentation: https://googleapis.dev/python/clouddeploy/latest +.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/clouddeploy/latest .. _Product Documentation: https://cloud.google.com/deploy/docs Quick Start diff --git a/google/cloud/deploy/__init__.py b/google/cloud/deploy/__init__.py index c9262c6..49ae1a8 100644 --- a/google/cloud/deploy/__init__.py +++ b/google/cloud/deploy/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/__init__.py b/google/cloud/deploy_v1/__init__.py index 2c04068..6dc1b97 100644 --- a/google/cloud/deploy_v1/__init__.py +++ b/google/cloud/deploy_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/services/__init__.py b/google/cloud/deploy_v1/services/__init__.py index 4de6597..e8e1c38 100644 --- a/google/cloud/deploy_v1/services/__init__.py +++ b/google/cloud/deploy_v1/services/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/services/cloud_deploy/__init__.py b/google/cloud/deploy_v1/services/cloud_deploy/__init__.py index 7016580..05c2b17 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/__init__.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/services/cloud_deploy/async_client.py b/google/cloud/deploy_v1/services/cloud_deploy/async_client.py index 9bd224c..68828da 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/async_client.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/async_client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -16,17 +16,20 @@ 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 # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core.client_options import ClientOptions +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -123,6 +126,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 CloudDeployClient.get_mtls_endpoint_and_cert_source(client_options) # type: ignore + @property def transport(self) -> CloudDeployTransport: """Returns the transport used by the client instance. @@ -195,6 +234,27 @@ async def list_delivery_pipelines( r"""Lists DeliveryPipelines in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_delivery_pipelines(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListDeliveryPipelinesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_delivery_pipelines(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListDeliveryPipelinesRequest, dict]): The request object. The request object for @@ -222,7 +282,7 @@ async def list_delivery_pipelines( """ # 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: @@ -284,6 +344,25 @@ async def get_delivery_pipeline( ) -> cloud_deploy.DeliveryPipeline: r"""Gets details of a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + response = client.get_delivery_pipeline(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetDeliveryPipelineRequest, dict]): The request object. The request object for @@ -312,7 +391,7 @@ async def get_delivery_pipeline( """ # 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: @@ -371,6 +450,31 @@ async def create_delivery_pipeline( r"""Creates a new DeliveryPipeline in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateDeliveryPipelineRequest( + parent="parent_value", + delivery_pipeline_id="delivery_pipeline_id_value", + ) + + # Make the request + operation = client.create_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateDeliveryPipelineRequest, dict]): The request object. The request object for @@ -413,7 +517,7 @@ async def create_delivery_pipeline( """ # 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, delivery_pipeline, delivery_pipeline_id]) if request is not None and has_flattened_params: @@ -473,6 +577,28 @@ async def update_delivery_pipeline( ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_update_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateDeliveryPipelineRequest( + ) + + # Make the request + operation = client.update_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.UpdateDeliveryPipelineRequest, dict]): The request object. The request object for @@ -514,7 +640,7 @@ async def update_delivery_pipeline( """ # 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([delivery_pipeline, update_mask]) if request is not None and has_flattened_params: @@ -573,6 +699,29 @@ async def delete_delivery_pipeline( ) -> operation_async.AsyncOperation: r"""Deletes a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_delete_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.DeleteDeliveryPipelineRequest, dict]): The request object. The request object for @@ -611,7 +760,7 @@ async def delete_delivery_pipeline( """ # 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: @@ -666,6 +815,26 @@ async def list_targets( ) -> pagers.ListTargetsAsyncPager: r"""Lists Targets in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_targets(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListTargetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_targets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListTargetsRequest, dict]): The request object. The request object for @@ -693,7 +862,7 @@ async def list_targets( """ # 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: @@ -755,6 +924,25 @@ async def get_target( ) -> cloud_deploy.Target: r"""Gets details of a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetTargetRequest( + name="name_value", + ) + + # Make the request + response = client.get_target(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetTargetRequest, dict]): The request object. The request object for `GetTarget`. @@ -780,7 +968,7 @@ async def get_target( """ # 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: @@ -838,6 +1026,30 @@ async def create_target( ) -> operation_async.AsyncOperation: r"""Creates a new Target in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateTargetRequest( + parent="parent_value", + target_id="target_id_value", + ) + + # Make the request + operation = client.create_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateTargetRequest, dict]): The request object. The request object for @@ -879,7 +1091,7 @@ async def create_target( """ # 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, target, target_id]) if request is not None and has_flattened_params: @@ -939,6 +1151,28 @@ async def update_target( ) -> operation_async.AsyncOperation: r"""Updates the parameters of a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_update_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateTargetRequest( + ) + + # Make the request + operation = client.update_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.UpdateTargetRequest, dict]): The request object. The request object for @@ -978,7 +1212,7 @@ async def update_target( """ # 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([target, update_mask]) if request is not None and has_flattened_params: @@ -1037,6 +1271,29 @@ async def delete_target( ) -> operation_async.AsyncOperation: r"""Deletes a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_delete_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteTargetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.DeleteTargetRequest, dict]): The request object. The request object for @@ -1075,7 +1332,7 @@ async def delete_target( """ # 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: @@ -1130,6 +1387,26 @@ async def list_releases( ) -> pagers.ListReleasesAsyncPager: r"""Lists Releases in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_releases(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListReleasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_releases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListReleasesRequest, dict]): The request object. The request object for @@ -1156,7 +1433,7 @@ async def list_releases( """ # 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: @@ -1218,6 +1495,25 @@ async def get_release( ) -> cloud_deploy.Release: r"""Gets details of a single Release. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetReleaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_release(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetReleaseRequest, dict]): The request object. The request object for `GetRelease`. @@ -1243,7 +1539,7 @@ async def get_release( """ # 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: @@ -1302,6 +1598,31 @@ async def create_release( r"""Creates a new Release in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateReleaseRequest( + parent="parent_value", + release_id="release_id_value", + ) + + # Make the request + operation = client.create_release(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateReleaseRequest, dict]): The request object. The request object for @@ -1343,7 +1664,7 @@ async def create_release( """ # 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, release, release_id]) if request is not None and has_flattened_params: @@ -1402,6 +1723,26 @@ async def approve_rollout( ) -> cloud_deploy.ApproveRolloutResponse: r"""Approves a Rollout. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_approve_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ApproveRolloutRequest( + name="name_value", + approved=True, + ) + + # Make the request + response = client.approve_rollout(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ApproveRolloutRequest, dict]): The request object. The request object used by @@ -1426,7 +1767,7 @@ async def approve_rollout( The response object from ApproveRollout. """ # 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: @@ -1473,6 +1814,26 @@ async def list_rollouts( ) -> pagers.ListRolloutsAsyncPager: r"""Lists Rollouts in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_rollouts(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListRolloutsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rollouts(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListRolloutsRequest, dict]): The request object. ListRolloutsRequest is the request @@ -1500,7 +1861,7 @@ async def list_rollouts( """ # 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: @@ -1562,6 +1923,25 @@ async def get_rollout( ) -> cloud_deploy.Rollout: r"""Gets details of a single Rollout. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetRolloutRequest( + name="name_value", + ) + + # Make the request + response = client.get_rollout(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetRolloutRequest, dict]): The request object. GetRolloutRequest is the request @@ -1588,7 +1968,7 @@ async def get_rollout( """ # 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: @@ -1647,6 +2027,35 @@ async def create_rollout( r"""Creates a new Rollout in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + rollout = deploy_v1.Rollout() + rollout.target_id = "target_id_value" + + request = deploy_v1.CreateRolloutRequest( + parent="parent_value", + rollout_id="rollout_id_value", + rollout=rollout, + ) + + # Make the request + operation = client.create_rollout(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateRolloutRequest, dict]): The request object. CreateRolloutRequest is the request @@ -1688,7 +2097,7 @@ async def create_rollout( """ # 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, rollout, rollout_id]) if request is not None and has_flattened_params: @@ -1747,6 +2156,25 @@ async def get_config( ) -> cloud_deploy.Config: r"""Gets the configuration for a location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_config(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetConfigRequest, dict]): The request object. Request to get a configuration. @@ -1768,7 +2196,7 @@ async def get_config( Service-wide configuration. """ # 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/deploy_v1/services/cloud_deploy/client.py b/google/cloud/deploy_v1/services/cloud_deploy/client.py index d2d156e..8ce3264 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/client.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/client.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -14,23 +14,25 @@ # limitations under the License. # from collections import OrderedDict -from distutils import util import os import re from typing import Dict, Optional, Sequence, Tuple, Type, Union import pkg_resources -from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore +from google.api_core import client_options as client_options_lib +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport import mtls # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore from google.auth.exceptions import MutualTLSChannelError # type: ignore from google.oauth2 import service_account # type: ignore -OptionalRetry = Union[retries.Retry, object] +try: + OptionalRetry = Union[retries.Retry, gapic_v1.method._MethodDefault] +except AttributeError: # pragma: NO COVER + OptionalRetry = Union[retries.Retry, object] # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore @@ -362,6 +364,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, *, @@ -412,50 +481,22 @@ def __init__( if client_options is None: client_options = client_options_lib.ClientOptions() - # Create SSL credentials for mutual TLS if needed. - use_client_cert = bool( - util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false")) + 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, CloudDeployTransport): # transport is a CloudDeployTransport 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." @@ -467,6 +508,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, @@ -491,6 +541,27 @@ def list_delivery_pipelines( r"""Lists DeliveryPipelines in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_delivery_pipelines(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListDeliveryPipelinesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_delivery_pipelines(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListDeliveryPipelinesRequest, dict]): The request object. The request object for @@ -518,7 +589,7 @@ def list_delivery_pipelines( """ # 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: @@ -571,6 +642,25 @@ def get_delivery_pipeline( ) -> cloud_deploy.DeliveryPipeline: r"""Gets details of a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + response = client.get_delivery_pipeline(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetDeliveryPipelineRequest, dict]): The request object. The request object for @@ -599,7 +689,7 @@ def get_delivery_pipeline( """ # 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: @@ -649,6 +739,31 @@ def create_delivery_pipeline( r"""Creates a new DeliveryPipeline in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateDeliveryPipelineRequest( + parent="parent_value", + delivery_pipeline_id="delivery_pipeline_id_value", + ) + + # Make the request + operation = client.create_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateDeliveryPipelineRequest, dict]): The request object. The request object for @@ -691,7 +806,7 @@ def create_delivery_pipeline( """ # 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, delivery_pipeline, delivery_pipeline_id]) if request is not None and has_flattened_params: @@ -751,6 +866,28 @@ def update_delivery_pipeline( ) -> operation.Operation: r"""Updates the parameters of a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_update_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateDeliveryPipelineRequest( + ) + + # Make the request + operation = client.update_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.UpdateDeliveryPipelineRequest, dict]): The request object. The request object for @@ -792,7 +929,7 @@ def update_delivery_pipeline( """ # 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([delivery_pipeline, update_mask]) if request is not None and has_flattened_params: @@ -851,6 +988,29 @@ def delete_delivery_pipeline( ) -> operation.Operation: r"""Deletes a single DeliveryPipeline. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_delete_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.DeleteDeliveryPipelineRequest, dict]): The request object. The request object for @@ -889,7 +1049,7 @@ def delete_delivery_pipeline( """ # 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: @@ -944,6 +1104,26 @@ def list_targets( ) -> pagers.ListTargetsPager: r"""Lists Targets in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_targets(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListTargetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_targets(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListTargetsRequest, dict]): The request object. The request object for @@ -971,7 +1151,7 @@ def list_targets( """ # 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: @@ -1024,6 +1204,25 @@ def get_target( ) -> cloud_deploy.Target: r"""Gets details of a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetTargetRequest( + name="name_value", + ) + + # Make the request + response = client.get_target(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetTargetRequest, dict]): The request object. The request object for `GetTarget`. @@ -1049,7 +1248,7 @@ def get_target( """ # 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 +1297,30 @@ def create_target( ) -> operation.Operation: r"""Creates a new Target in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateTargetRequest( + parent="parent_value", + target_id="target_id_value", + ) + + # Make the request + operation = client.create_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateTargetRequest, dict]): The request object. The request object for @@ -1139,7 +1362,7 @@ def create_target( """ # 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, target, target_id]) if request is not None and has_flattened_params: @@ -1199,6 +1422,28 @@ def update_target( ) -> operation.Operation: r"""Updates the parameters of a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_update_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateTargetRequest( + ) + + # Make the request + operation = client.update_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.UpdateTargetRequest, dict]): The request object. The request object for @@ -1238,7 +1483,7 @@ def update_target( """ # 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([target, update_mask]) if request is not None and has_flattened_params: @@ -1297,6 +1542,29 @@ def delete_target( ) -> operation.Operation: r"""Deletes a single Target. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_delete_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteTargetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.DeleteTargetRequest, dict]): The request object. The request object for @@ -1335,7 +1603,7 @@ def delete_target( """ # 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: @@ -1390,6 +1658,26 @@ def list_releases( ) -> pagers.ListReleasesPager: r"""Lists Releases in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_releases(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListReleasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_releases(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListReleasesRequest, dict]): The request object. The request object for @@ -1416,7 +1704,7 @@ def list_releases( """ # 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: @@ -1469,6 +1757,25 @@ def get_release( ) -> cloud_deploy.Release: r"""Gets details of a single Release. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetReleaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_release(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetReleaseRequest, dict]): The request object. The request object for `GetRelease`. @@ -1494,7 +1801,7 @@ def get_release( """ # 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: @@ -1544,6 +1851,31 @@ def create_release( r"""Creates a new Release in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateReleaseRequest( + parent="parent_value", + release_id="release_id_value", + ) + + # Make the request + operation = client.create_release(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateReleaseRequest, dict]): The request object. The request object for @@ -1585,7 +1917,7 @@ def create_release( """ # 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, release, release_id]) if request is not None and has_flattened_params: @@ -1644,6 +1976,26 @@ def approve_rollout( ) -> cloud_deploy.ApproveRolloutResponse: r"""Approves a Rollout. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_approve_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ApproveRolloutRequest( + name="name_value", + approved=True, + ) + + # Make the request + response = client.approve_rollout(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ApproveRolloutRequest, dict]): The request object. The request object used by @@ -1668,7 +2020,7 @@ def approve_rollout( The response object from ApproveRollout. """ # 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: @@ -1715,6 +2067,26 @@ def list_rollouts( ) -> pagers.ListRolloutsPager: r"""Lists Rollouts in a given project and location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_list_rollouts(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListRolloutsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rollouts(request=request) + + # Handle the response + for response in page_result: + print(response) + Args: request (Union[google.cloud.deploy_v1.types.ListRolloutsRequest, dict]): The request object. ListRolloutsRequest is the request @@ -1742,7 +2114,7 @@ def list_rollouts( """ # 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: @@ -1795,6 +2167,25 @@ def get_rollout( ) -> cloud_deploy.Rollout: r"""Gets details of a single Rollout. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetRolloutRequest( + name="name_value", + ) + + # Make the request + response = client.get_rollout(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetRolloutRequest, dict]): The request object. GetRolloutRequest is the request @@ -1821,7 +2212,7 @@ def get_rollout( """ # 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: @@ -1871,6 +2262,35 @@ def create_rollout( r"""Creates a new Rollout in a given project and location. + + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_create_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + rollout = deploy_v1.Rollout() + rollout.target_id = "target_id_value" + + request = deploy_v1.CreateRolloutRequest( + parent="parent_value", + rollout_id="rollout_id_value", + rollout=rollout, + ) + + # Make the request + operation = client.create_rollout(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.CreateRolloutRequest, dict]): The request object. CreateRolloutRequest is the request @@ -1912,7 +2332,7 @@ def create_rollout( """ # 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, rollout, rollout_id]) if request is not None and has_flattened_params: @@ -1971,6 +2391,25 @@ def get_config( ) -> cloud_deploy.Config: r"""Gets the configuration for a location. + .. code-block:: python + + from google.cloud import deploy_v1 + + def sample_get_config(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_config(request=request) + + # Handle the response + print(response) + Args: request (Union[google.cloud.deploy_v1.types.GetConfigRequest, dict]): The request object. Request to get a configuration. @@ -1992,7 +2431,7 @@ def get_config( Service-wide configuration. """ # 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/deploy_v1/services/cloud_deploy/pagers.py b/google/cloud/deploy_v1/services/cloud_deploy/pagers.py index 5a51b5d..e59c525 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/pagers.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/pagers.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/services/cloud_deploy/transports/__init__.py b/google/cloud/deploy_v1/services/cloud_deploy/transports/__init__.py index 6155307..c85a569 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/transports/__init__.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/transports/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/services/cloud_deploy/transports/base.py b/google/cloud/deploy_v1/services/cloud_deploy/transports/base.py index 2a18f0f..194d5e5 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/transports/base.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/transports/base.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -18,11 +18,11 @@ import pkg_resources import google.auth # type: ignore -import google.api_core # type: ignore -from google.api_core import exceptions as core_exceptions # type: ignore -from google.api_core import gapic_v1 # type: ignore -from google.api_core import retry as retries # type: ignore -from google.api_core import operations_v1 # type: ignore +import google.api_core +from google.api_core import exceptions as core_exceptions +from google.api_core import gapic_v1 +from google.api_core import retry as retries +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore @@ -101,7 +101,6 @@ def __init__( credentials, _ = google.auth.load_credentials_from_file( credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) - elif credentials is None: credentials, _ = google.auth.default( **scopes_kwargs, quota_project_id=quota_project_id diff --git a/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc.py b/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc.py index fe432c4..46a0a8f 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -16,9 +16,9 @@ import warnings from typing import Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import grpc_helpers # type: ignore -from google.api_core import operations_v1 # type: ignore -from google.api_core import gapic_v1 # type: ignore +from google.api_core import grpc_helpers +from google.api_core import operations_v1 +from google.api_core import gapic_v1 import google.auth # type: ignore from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -163,8 +163,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, @@ -237,7 +240,7 @@ def operations_client(self) -> operations_v1.OperationsClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsClient(self.grpc_channel) diff --git a/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc_asyncio.py b/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc_asyncio.py index 1f019eb..5800b36 100644 --- a/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc_asyncio.py +++ b/google/cloud/deploy_v1/services/cloud_deploy/transports/grpc_asyncio.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -16,9 +16,9 @@ import warnings from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple, Union -from google.api_core import gapic_v1 # type: ignore -from google.api_core import grpc_helpers_async # type: ignore -from google.api_core import operations_v1 # type: ignore +from google.api_core import gapic_v1 +from google.api_core import grpc_helpers_async +from google.api_core import operations_v1 from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore @@ -208,8 +208,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, @@ -239,7 +242,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: This property caches on the instance; repeated calls return the same client. """ - # Sanity check: Only create a new client if we do not already have one. + # Quick check: Only create a new client if we do not already have one. if self._operations_client is None: self._operations_client = operations_v1.OperationsAsyncClient( self.grpc_channel diff --git a/google/cloud/deploy_v1/types/__init__.py b/google/cloud/deploy_v1/types/__init__.py index cd079fb..2ed4b17 100644 --- a/google/cloud/deploy_v1/types/__init__.py +++ b/google/cloud/deploy_v1/types/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/google/cloud/deploy_v1/types/cloud_deploy.py b/google/cloud/deploy_v1/types/cloud_deploy.py index 6badcd0..8da95ad 100644 --- a/google/cloud/deploy_v1/types/cloud_deploy.py +++ b/google/cloud/deploy_v1/types/cloud_deploy.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -110,6 +110,7 @@ class DeliveryPipeline(proto.Message): serial_pipeline (google.cloud.deploy_v1.types.SerialPipeline): SerialPipeline defines a sequential set of stages for a ``DeliveryPipeline``. + This field is a member of `oneof`_ ``pipeline``. condition (google.cloud.deploy_v1.types.PipelineCondition): Output only. Information around the state of @@ -495,6 +496,7 @@ class Target(proto.Message): updated. gke (google.cloud.deploy_v1.types.GkeCluster): Information specifying a GKE Cluster. + This field is a member of `oneof`_ ``deployment_target``. etag (str): Optional. This checksum is computed by the @@ -548,9 +550,11 @@ class ExecutionConfig(proto.Message): should be applied. default_pool (google.cloud.deploy_v1.types.DefaultPool): Optional. Use default Cloud Build pool. + This field is a member of `oneof`_ ``execution_environment``. private_pool (google.cloud.deploy_v1.types.PrivatePool): Optional. Use private Cloud Build pool. + This field is a member of `oneof`_ ``execution_environment``. """ @@ -993,9 +997,9 @@ class BuildArtifact(proto.Message): Image name in Skaffold configuration. tag (str): Image tag to use. This will generally be the - full path to an image, such as "gcr.io/my- - project/busybox:1.2.3" or "gcr.io/my- - project/busybox@sha256:abc123". + full path to an image, such as + "gcr.io/my-project/busybox:1.2.3" or + "gcr.io/my-project/busybox@sha256:abc123". """ image = proto.Field(proto.STRING, number=3,) @@ -1013,6 +1017,7 @@ class TargetArtifact(proto.Message): the artifacts. This contains deployment configuration used by Skaffold during a rollout, and all paths are relative to this location. + This field is a member of `oneof`_ ``uri``. skaffold_config_path (str): Output only. File path of the resolved diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_async.py new file mode 100644 index 0000000..fe9294f --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ApproveRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ApproveRollout_async] +from google.cloud import deploy_v1 + + +async def sample_approve_rollout(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.ApproveRolloutRequest( + name="name_value", + approved=True, + ) + + # Make the request + response = await client.approve_rollout(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ApproveRollout_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_sync.py new file mode 100644 index 0000000..06c9baf --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_approve_rollout_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ApproveRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ApproveRollout_sync] +from google.cloud import deploy_v1 + + +def sample_approve_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ApproveRolloutRequest( + name="name_value", + approved=True, + ) + + # Make the request + response = client.approve_rollout(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ApproveRollout_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_async.py new file mode 100644 index 0000000..56ca884 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_async] +from google.cloud import deploy_v1 + + +async def sample_create_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.CreateDeliveryPipelineRequest( + parent="parent_value", + delivery_pipeline_id="delivery_pipeline_id_value", + ) + + # Make the request + operation = client.create_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_sync.py new file mode 100644 index 0000000..9e9c0d5 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_sync] +from google.cloud import deploy_v1 + + +def sample_create_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateDeliveryPipelineRequest( + parent="parent_value", + delivery_pipeline_id="delivery_pipeline_id_value", + ) + + # Make the request + operation = client.create_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_async.py new file mode 100644 index 0000000..4075502 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateRelease +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateRelease_async] +from google.cloud import deploy_v1 + + +async def sample_create_release(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.CreateReleaseRequest( + parent="parent_value", + release_id="release_id_value", + ) + + # Make the request + operation = client.create_release(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateRelease_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_sync.py new file mode 100644 index 0000000..a217efe --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_release_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateRelease +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateRelease_sync] +from google.cloud import deploy_v1 + + +def sample_create_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateReleaseRequest( + parent="parent_value", + release_id="release_id_value", + ) + + # Make the request + operation = client.create_release(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateRelease_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_async.py new file mode 100644 index 0000000..3e1b02f --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_async.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateRollout_async] +from google.cloud import deploy_v1 + + +async def sample_create_rollout(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + rollout = deploy_v1.Rollout() + rollout.target_id = "target_id_value" + + request = deploy_v1.CreateRolloutRequest( + parent="parent_value", + rollout_id="rollout_id_value", + rollout=rollout, + ) + + # Make the request + operation = client.create_rollout(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateRollout_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_sync.py new file mode 100644 index 0000000..f58b0a0 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_rollout_sync.py @@ -0,0 +1,54 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateRollout_sync] +from google.cloud import deploy_v1 + + +def sample_create_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + rollout = deploy_v1.Rollout() + rollout.target_id = "target_id_value" + + request = deploy_v1.CreateRolloutRequest( + parent="parent_value", + rollout_id="rollout_id_value", + rollout=rollout, + ) + + # Make the request + operation = client.create_rollout(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateRollout_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_async.py new file mode 100644 index 0000000..a9684f3 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_async.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateTarget_async] +from google.cloud import deploy_v1 + + +async def sample_create_target(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.CreateTargetRequest( + parent="parent_value", + target_id="target_id_value", + ) + + # Make the request + operation = client.create_target(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateTarget_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_sync.py new file mode 100644 index 0000000..09ef227 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_create_target_sync.py @@ -0,0 +1,50 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for CreateTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_CreateTarget_sync] +from google.cloud import deploy_v1 + + +def sample_create_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.CreateTargetRequest( + parent="parent_value", + target_id="target_id_value", + ) + + # Make the request + operation = client.create_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_CreateTarget_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_async.py new file mode 100644 index 0000000..05fa2b1 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_async] +from google.cloud import deploy_v1 + + +async def sample_delete_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_sync.py new file mode 100644 index 0000000..bd608ba --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_sync] +from google.cloud import deploy_v1 + + +def sample_delete_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_async.py new file mode 100644 index 0000000..4e12412 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_async.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_DeleteTarget_async] +from google.cloud import deploy_v1 + + +async def sample_delete_target(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteTargetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_target(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_DeleteTarget_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_sync.py new file mode 100644 index 0000000..3986ecb --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_delete_target_sync.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for DeleteTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_DeleteTarget_sync] +from google.cloud import deploy_v1 + + +def sample_delete_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.DeleteTargetRequest( + name="name_value", + ) + + # Make the request + operation = client.delete_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_DeleteTarget_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_async.py new file mode 100644 index 0000000..1168e22 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetConfig +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetConfig_async] +from google.cloud import deploy_v1 + + +async def sample_get_config(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.GetConfigRequest( + name="name_value", + ) + + # Make the request + response = await client.get_config(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetConfig_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_sync.py new file mode 100644 index 0000000..642c5c5 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_config_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetConfig +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetConfig_sync] +from google.cloud import deploy_v1 + + +def sample_get_config(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetConfigRequest( + name="name_value", + ) + + # Make the request + response = client.get_config(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetConfig_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_async.py new file mode 100644 index 0000000..8c504a1 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_async] +from google.cloud import deploy_v1 + + +async def sample_get_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.GetDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + response = await client.get_delivery_pipeline(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_sync.py new file mode 100644 index 0000000..de60ba8 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_sync] +from google.cloud import deploy_v1 + + +def sample_get_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetDeliveryPipelineRequest( + name="name_value", + ) + + # Make the request + response = client.get_delivery_pipeline(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_async.py new file mode 100644 index 0000000..ea3ff6b --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetRelease +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetRelease_async] +from google.cloud import deploy_v1 + + +async def sample_get_release(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.GetReleaseRequest( + name="name_value", + ) + + # Make the request + response = await client.get_release(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetRelease_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_sync.py new file mode 100644 index 0000000..93bf538 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_release_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetRelease +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetRelease_sync] +from google.cloud import deploy_v1 + + +def sample_get_release(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetReleaseRequest( + name="name_value", + ) + + # Make the request + response = client.get_release(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetRelease_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_async.py new file mode 100644 index 0000000..e1a21be --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetRollout_async] +from google.cloud import deploy_v1 + + +async def sample_get_rollout(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.GetRolloutRequest( + name="name_value", + ) + + # Make the request + response = await client.get_rollout(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetRollout_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_sync.py new file mode 100644 index 0000000..0ea5523 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_rollout_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetRollout +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetRollout_sync] +from google.cloud import deploy_v1 + + +def sample_get_rollout(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetRolloutRequest( + name="name_value", + ) + + # Make the request + response = client.get_rollout(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetRollout_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_async.py new file mode 100644 index 0000000..a27df6b --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_async.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetTarget_async] +from google.cloud import deploy_v1 + + +async def sample_get_target(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.GetTargetRequest( + name="name_value", + ) + + # Make the request + response = await client.get_target(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetTarget_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_sync.py new file mode 100644 index 0000000..bf1229c --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_get_target_sync.py @@ -0,0 +1,45 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for GetTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_GetTarget_sync] +from google.cloud import deploy_v1 + + +def sample_get_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.GetTargetRequest( + name="name_value", + ) + + # Make the request + response = client.get_target(request=request) + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_GetTarget_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_async.py new file mode 100644 index 0000000..bb93c3c --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeliveryPipelines +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_async] +from google.cloud import deploy_v1 + + +async def sample_list_delivery_pipelines(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.ListDeliveryPipelinesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_delivery_pipelines(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_sync.py new file mode 100644 index 0000000..d11caf9 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListDeliveryPipelines +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_sync] +from google.cloud import deploy_v1 + + +def sample_list_delivery_pipelines(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListDeliveryPipelinesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_delivery_pipelines(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_async.py new file mode 100644 index 0000000..a1dc10f --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListReleases +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListReleases_async] +from google.cloud import deploy_v1 + + +async def sample_list_releases(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.ListReleasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_releases(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListReleases_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_sync.py new file mode 100644 index 0000000..b634624 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_releases_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListReleases +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListReleases_sync] +from google.cloud import deploy_v1 + + +def sample_list_releases(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListReleasesRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_releases(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListReleases_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_async.py new file mode 100644 index 0000000..3d2cbf3 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListRollouts +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListRollouts_async] +from google.cloud import deploy_v1 + + +async def sample_list_rollouts(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.ListRolloutsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rollouts(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListRollouts_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_sync.py new file mode 100644 index 0000000..6ef93e2 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_rollouts_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListRollouts +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListRollouts_sync] +from google.cloud import deploy_v1 + + +def sample_list_rollouts(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListRolloutsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_rollouts(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListRollouts_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_async.py new file mode 100644 index 0000000..08e1824 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_async.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTargets +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListTargets_async] +from google.cloud import deploy_v1 + + +async def sample_list_targets(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.ListTargetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_targets(request=request) + + # Handle the response + async for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListTargets_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_sync.py new file mode 100644 index 0000000..054360b --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_list_targets_sync.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for ListTargets +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_ListTargets_sync] +from google.cloud import deploy_v1 + + +def sample_list_targets(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.ListTargetsRequest( + parent="parent_value", + ) + + # Make the request + page_result = client.list_targets(request=request) + + # Handle the response + for response in page_result: + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_ListTargets_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_async.py new file mode 100644 index 0000000..cf094ce --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_async] +from google.cloud import deploy_v1 + + +async def sample_update_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateDeliveryPipelineRequest( + ) + + # Make the request + operation = client.update_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_sync.py new file mode 100644 index 0000000..473d9ac --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateDeliveryPipeline +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_sync] +from google.cloud import deploy_v1 + + +def sample_update_delivery_pipeline(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateDeliveryPipelineRequest( + ) + + # Make the request + operation = client.update_delivery_pipeline(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_sync] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_async.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_async.py new file mode 100644 index 0000000..5f1f88a --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_async.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_UpdateTarget_async] +from google.cloud import deploy_v1 + + +async def sample_update_target(): + # Create a client + client = deploy_v1.CloudDeployAsyncClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateTargetRequest( + ) + + # Make the request + operation = client.update_target(request=request) + + print("Waiting for operation to complete...") + + response = await operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_UpdateTarget_async] diff --git a/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_sync.py b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_sync.py new file mode 100644 index 0000000..cd1ead3 --- /dev/null +++ b/samples/generated_samples/clouddeploy_v1_generated_cloud_deploy_update_target_sync.py @@ -0,0 +1,48 @@ +# -*- coding: utf-8 -*- +# 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. +# +# Generated code. DO NOT EDIT! +# +# Snippet for UpdateTarget +# 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-deploy + + +# [START clouddeploy_v1_generated_CloudDeploy_UpdateTarget_sync] +from google.cloud import deploy_v1 + + +def sample_update_target(): + # Create a client + client = deploy_v1.CloudDeployClient() + + # Initialize request argument(s) + request = deploy_v1.UpdateTargetRequest( + ) + + # Make the request + operation = client.update_target(request=request) + + print("Waiting for operation to complete...") + + response = operation.result() + + # Handle the response + print(response) + +# [END clouddeploy_v1_generated_CloudDeploy_UpdateTarget_sync] diff --git a/samples/generated_samples/snippet_metadata_deploy_v1.json b/samples/generated_samples/snippet_metadata_deploy_v1.json new file mode 100644 index 0000000..9af08e4 --- /dev/null +++ b/samples/generated_samples/snippet_metadata_deploy_v1.json @@ -0,0 +1,1606 @@ +{ + "snippets": [ + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "ApproveRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_approve_rollout_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ApproveRollout_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": "CloudDeploy" + }, + "shortName": "ApproveRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_approve_rollout_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ApproveRollout_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": "CloudDeploy" + }, + "shortName": "CreateDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_delivery_pipeline_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateDeliveryPipeline_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateRelease" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_release_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateRelease_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateRelease" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_release_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateRelease_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_rollout_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateRollout_async", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_rollout_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateRollout_sync", + "segments": [ + { + "end": 53, + "start": 27, + "type": "FULL" + }, + { + "end": 53, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 43, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 50, + "start": 44, + "type": "REQUEST_EXECUTION" + }, + { + "end": 54, + "start": 51, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_target_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateTarget_async", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "CreateTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_create_target_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_CreateTarget_sync", + "segments": [ + { + "end": 49, + "start": 27, + "type": "FULL" + }, + { + "end": 49, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 39, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 46, + "start": 40, + "type": "REQUEST_EXECUTION" + }, + { + "end": 50, + "start": 47, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "DeleteDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "DeleteDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_delete_delivery_pipeline_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_DeleteDeliveryPipeline_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "DeleteTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_delete_target_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_DeleteTarget_async", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "DeleteTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_delete_target_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_DeleteTarget_sync", + "segments": [ + { + "end": 48, + "start": 27, + "type": "FULL" + }, + { + "end": 48, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 38, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 45, + "start": 39, + "type": "REQUEST_EXECUTION" + }, + { + "end": 49, + "start": 46, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "GetConfig" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_config_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetConfig_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": "CloudDeploy" + }, + "shortName": "GetConfig" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_config_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetConfig_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": "CloudDeploy" + }, + "shortName": "GetDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_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": "CloudDeploy" + }, + "shortName": "GetDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_delivery_pipeline_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetDeliveryPipeline_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": "CloudDeploy" + }, + "shortName": "GetRelease" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_release_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetRelease_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": "CloudDeploy" + }, + "shortName": "GetRelease" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_release_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetRelease_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": "CloudDeploy" + }, + "shortName": "GetRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_rollout_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetRollout_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": "CloudDeploy" + }, + "shortName": "GetRollout" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_rollout_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetRollout_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": "CloudDeploy" + }, + "shortName": "GetTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_target_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetTarget_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": "CloudDeploy" + }, + "shortName": "GetTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_get_target_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_GetTarget_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": "CloudDeploy" + }, + "shortName": "ListDeliveryPipelines" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_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": "CloudDeploy" + }, + "shortName": "ListDeliveryPipelines" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_delivery_pipelines_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListDeliveryPipelines_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": "CloudDeploy" + }, + "shortName": "ListReleases" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_releases_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListReleases_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": "CloudDeploy" + }, + "shortName": "ListReleases" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_releases_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListReleases_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": "CloudDeploy" + }, + "shortName": "ListRollouts" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_rollouts_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListRollouts_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": "CloudDeploy" + }, + "shortName": "ListRollouts" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_rollouts_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListRollouts_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": "CloudDeploy" + }, + "shortName": "ListTargets" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_targets_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListTargets_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": "CloudDeploy" + }, + "shortName": "ListTargets" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_list_targets_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_ListTargets_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": "CloudDeploy" + }, + "shortName": "UpdateDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "UpdateDeliveryPipeline" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_update_delivery_pipeline_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_UpdateDeliveryPipeline_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "async": true, + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "UpdateTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_update_target_async.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_UpdateTarget_async", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + }, + { + "clientMethod": { + "method": { + "service": { + "shortName": "CloudDeploy" + }, + "shortName": "UpdateTarget" + } + }, + "file": "clouddeploy_v1_generated_cloud_deploy_update_target_sync.py", + "regionTag": "clouddeploy_v1_generated_CloudDeploy_UpdateTarget_sync", + "segments": [ + { + "end": 47, + "start": 27, + "type": "FULL" + }, + { + "end": 47, + "start": 27, + "type": "SHORT" + }, + { + "end": 33, + "start": 31, + "type": "CLIENT_INITIALIZATION" + }, + { + "end": 37, + "start": 34, + "type": "REQUEST_INITIALIZATION" + }, + { + "end": 44, + "start": 38, + "type": "REQUEST_EXECUTION" + }, + { + "end": 48, + "start": 45, + "type": "RESPONSE_HANDLING" + } + ] + } + ] +} diff --git a/scripts/fixup_deploy_v1_keywords.py b/scripts/fixup_deploy_v1_keywords.py index 1055687..a76c3f9 100644 --- a/scripts/fixup_deploy_v1_keywords.py +++ b/scripts/fixup_deploy_v1_keywords.py @@ -1,6 +1,6 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/setup.py b/setup.py index 7bbccb1..e8eeeab 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ name = "google-cloud-deploy" description = "Google Cloud Deploy API client library" -version = "1.0.0" +version = "1.1.0" url = "https://github.com/googleapis/python-deploy" release_status = "Development Status :: 5 - Production/Stable" dependencies = [ diff --git a/tests/__init__.py b/tests/__init__.py index 4de6597..e8e1c38 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py index 4de6597..e8e1c38 100644 --- a/tests/unit/__init__.py +++ b/tests/unit/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py index 4de6597..e8e1c38 100644 --- a/tests/unit/gapic/__init__.py +++ b/tests/unit/gapic/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/tests/unit/gapic/deploy_v1/__init__.py b/tests/unit/gapic/deploy_v1/__init__.py index 4de6597..e8e1c38 100644 --- a/tests/unit/gapic/deploy_v1/__init__.py +++ b/tests/unit/gapic/deploy_v1/__init__.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. diff --git a/tests/unit/gapic/deploy_v1/test_cloud_deploy.py b/tests/unit/gapic/deploy_v1/test_cloud_deploy.py index 21cf0e2..96df274 100644 --- a/tests/unit/gapic/deploy_v1/test_cloud_deploy.py +++ b/tests/unit/gapic/deploy_v1/test_cloud_deploy.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2020 Google LLC +# 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. @@ -29,6 +29,7 @@ from google.api_core import gapic_v1 from google.api_core import grpc_helpers from google.api_core import grpc_helpers_async +from google.api_core import operation from google.api_core import operation_async # type: ignore from google.api_core import operations_v1 from google.api_core import path_template @@ -243,20 +244,20 @@ def test_cloud_deploy_client_client_options( # unsupported value. with mock.patch.dict(os.environ, {"GOOGLE_API_USE_MTLS_ENDPOINT": "Unsupported"}): with pytest.raises(MutualTLSChannelError): - client = client_class() + client = client_class(transport=transport_name) # Check the case GOOGLE_API_USE_CLIENT_CERTIFICATE has unsupported value. with mock.patch.dict( os.environ, {"GOOGLE_API_USE_CLIENT_CERTIFICATE": "Unsupported"} ): with pytest.raises(ValueError): - client = client_class() + client = client_class(transport=transport_name) # Check the case quota_project_id is provided options = client_options.ClientOptions(quota_project_id="octopus") with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -313,7 +314,7 @@ def test_cloud_deploy_client_mtls_env_auto( ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) if use_client_cert_env == "false": expected_client_cert_source = None @@ -390,6 +391,83 @@ def test_cloud_deploy_client_mtls_env_auto( ) +@pytest.mark.parametrize("client_class", [CloudDeployClient, CloudDeployAsyncClient]) +@mock.patch.object( + CloudDeployClient, "DEFAULT_ENDPOINT", modify_default_endpoint(CloudDeployClient) +) +@mock.patch.object( + CloudDeployAsyncClient, + "DEFAULT_ENDPOINT", + modify_default_endpoint(CloudDeployAsyncClient), +) +def test_cloud_deploy_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", [ @@ -408,7 +486,7 @@ def test_cloud_deploy_client_client_options_scopes( options = client_options.ClientOptions(scopes=["1", "2"],) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None - client = client_class(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file=None, @@ -422,24 +500,26 @@ def test_cloud_deploy_client_client_options_scopes( @pytest.mark.parametrize( - "client_class,transport_class,transport_name", + "client_class,transport_class,transport_name,grpc_helpers", [ - (CloudDeployClient, transports.CloudDeployGrpcTransport, "grpc"), + (CloudDeployClient, transports.CloudDeployGrpcTransport, "grpc", grpc_helpers), ( CloudDeployAsyncClient, transports.CloudDeployGrpcAsyncIOTransport, "grpc_asyncio", + grpc_helpers_async, ), ], ) def test_cloud_deploy_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(transport=transport_name, client_options=options) + client = client_class(client_options=options, transport=transport_name) patched.assert_called_once_with( credentials=None, credentials_file="credentials.json", @@ -470,9 +550,71 @@ def test_cloud_deploy_client_client_options_from_dict(): ) -def test_list_delivery_pipelines( - transport: str = "grpc", request_type=cloud_deploy.ListDeliveryPipelinesRequest +@pytest.mark.parametrize( + "client_class,transport_class,transport_name,grpc_helpers", + [ + (CloudDeployClient, transports.CloudDeployGrpcTransport, "grpc", grpc_helpers), + ( + CloudDeployAsyncClient, + transports.CloudDeployGrpcAsyncIOTransport, + "grpc_asyncio", + grpc_helpers_async, + ), + ], +) +def test_cloud_deploy_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( + "clouddeploy.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="clouddeploy.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "request_type", [cloud_deploy.ListDeliveryPipelinesRequest, dict,] +) +def test_list_delivery_pipelines(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -502,10 +644,6 @@ def test_list_delivery_pipelines( assert response.unreachable == ["unreachable_value"] -def test_list_delivery_pipelines_from_dict(): - test_list_delivery_pipelines(request_type=dict) - - def test_list_delivery_pipelines_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -637,7 +775,9 @@ def test_list_delivery_pipelines_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_delivery_pipelines_flattened_error(): @@ -673,7 +813,9 @@ async def test_list_delivery_pipelines_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -688,8 +830,10 @@ async def test_list_delivery_pipelines_flattened_error_async(): ) -def test_list_delivery_pipelines_pager(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_delivery_pipelines_pager(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -734,8 +878,10 @@ def test_list_delivery_pipelines_pager(): assert all(isinstance(i, cloud_deploy.DeliveryPipeline) for i in results) -def test_list_delivery_pipelines_pages(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_delivery_pipelines_pages(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -858,9 +1004,10 @@ async def test_list_delivery_pipelines_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_delivery_pipeline( - transport: str = "grpc", request_type=cloud_deploy.GetDeliveryPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_deploy.GetDeliveryPipelineRequest, dict,] +) +def test_get_delivery_pipeline(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -898,10 +1045,6 @@ def test_get_delivery_pipeline( assert response.etag == "etag_value" -def test_get_delivery_pipeline_from_dict(): - test_get_delivery_pipeline(request_type=dict) - - def test_get_delivery_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1037,7 +1180,9 @@ def test_get_delivery_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_delivery_pipeline_flattened_error(): @@ -1073,7 +1218,9 @@ async def test_get_delivery_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1088,9 +1235,10 @@ async def test_get_delivery_pipeline_flattened_error_async(): ) -def test_create_delivery_pipeline( - transport: str = "grpc", request_type=cloud_deploy.CreateDeliveryPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_deploy.CreateDeliveryPipelineRequest, dict,] +) +def test_create_delivery_pipeline(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1116,10 +1264,6 @@ def test_create_delivery_pipeline( assert isinstance(response, future.Future) -def test_create_delivery_pipeline_from_dict(): - test_create_delivery_pipeline(request_type=dict) - - def test_create_delivery_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1250,11 +1394,15 @@ def test_create_delivery_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].delivery_pipeline == cloud_deploy.DeliveryPipeline( - name="name_value" - ) - assert args[0].delivery_pipeline_id == "delivery_pipeline_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].delivery_pipeline + mock_val = cloud_deploy.DeliveryPipeline(name="name_value") + assert arg == mock_val + arg = args[0].delivery_pipeline_id + mock_val = "delivery_pipeline_id_value" + assert arg == mock_val def test_create_delivery_pipeline_flattened_error(): @@ -1297,11 +1445,15 @@ async def test_create_delivery_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].delivery_pipeline == cloud_deploy.DeliveryPipeline( - name="name_value" - ) - assert args[0].delivery_pipeline_id == "delivery_pipeline_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].delivery_pipeline + mock_val = cloud_deploy.DeliveryPipeline(name="name_value") + assert arg == mock_val + arg = args[0].delivery_pipeline_id + mock_val = "delivery_pipeline_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1319,9 +1471,10 @@ async def test_create_delivery_pipeline_flattened_error_async(): ) -def test_update_delivery_pipeline( - transport: str = "grpc", request_type=cloud_deploy.UpdateDeliveryPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_deploy.UpdateDeliveryPipelineRequest, dict,] +) +def test_update_delivery_pipeline(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1347,10 +1500,6 @@ def test_update_delivery_pipeline( assert isinstance(response, future.Future) -def test_update_delivery_pipeline_from_dict(): - test_update_delivery_pipeline(request_type=dict) - - def test_update_delivery_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1486,10 +1635,12 @@ def test_update_delivery_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].delivery_pipeline == cloud_deploy.DeliveryPipeline( - name="name_value" - ) - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].delivery_pipeline + mock_val = cloud_deploy.DeliveryPipeline(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_delivery_pipeline_flattened_error(): @@ -1530,10 +1681,12 @@ async def test_update_delivery_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].delivery_pipeline == cloud_deploy.DeliveryPipeline( - name="name_value" - ) - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].delivery_pipeline + mock_val = cloud_deploy.DeliveryPipeline(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -1550,9 +1703,10 @@ async def test_update_delivery_pipeline_flattened_error_async(): ) -def test_delete_delivery_pipeline( - transport: str = "grpc", request_type=cloud_deploy.DeleteDeliveryPipelineRequest -): +@pytest.mark.parametrize( + "request_type", [cloud_deploy.DeleteDeliveryPipelineRequest, dict,] +) +def test_delete_delivery_pipeline(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1578,10 +1732,6 @@ def test_delete_delivery_pipeline( assert isinstance(response, future.Future) -def test_delete_delivery_pipeline_from_dict(): - test_delete_delivery_pipeline(request_type=dict) - - def test_delete_delivery_pipeline_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1708,7 +1858,9 @@ def test_delete_delivery_pipeline_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_delivery_pipeline_flattened_error(): @@ -1744,7 +1896,9 @@ async def test_delete_delivery_pipeline_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1759,9 +1913,8 @@ async def test_delete_delivery_pipeline_flattened_error_async(): ) -def test_list_targets( - transport: str = "grpc", request_type=cloud_deploy.ListTargetsRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.ListTargetsRequest, dict,]) +def test_list_targets(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -1789,10 +1942,6 @@ def test_list_targets( assert response.unreachable == ["unreachable_value"] -def test_list_targets_from_dict(): - test_list_targets(request_type=dict) - - def test_list_targets_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -1913,7 +2062,9 @@ def test_list_targets_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_targets_flattened_error(): @@ -1947,7 +2098,9 @@ async def test_list_targets_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -1962,8 +2115,10 @@ async def test_list_targets_flattened_error_async(): ) -def test_list_targets_pager(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_targets_pager(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_targets), "__call__") as call: @@ -2000,8 +2155,10 @@ def test_list_targets_pager(): assert all(isinstance(i, cloud_deploy.Target) for i in results) -def test_list_targets_pages(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_targets_pages(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_targets), "__call__") as call: @@ -2100,9 +2257,8 @@ async def test_list_targets_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_target( - transport: str = "grpc", request_type=cloud_deploy.GetTargetRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.GetTargetRequest, dict,]) +def test_get_target(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2140,10 +2296,6 @@ def test_get_target( assert response.etag == "etag_value" -def test_get_target_from_dict(): - test_get_target(request_type=dict) - - def test_get_target_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2270,7 +2422,9 @@ def test_get_target_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_target_flattened_error(): @@ -2302,7 +2456,9 @@ async def test_get_target_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2317,9 +2473,8 @@ async def test_get_target_flattened_error_async(): ) -def test_create_target( - transport: str = "grpc", request_type=cloud_deploy.CreateTargetRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.CreateTargetRequest, dict,]) +def test_create_target(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2343,10 +2498,6 @@ def test_create_target( assert isinstance(response, future.Future) -def test_create_target_from_dict(): - test_create_target(request_type=dict) - - def test_create_target_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2466,9 +2617,15 @@ def test_create_target_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].target == cloud_deploy.Target(name="name_value") - assert args[0].target_id == "target_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].target + mock_val = cloud_deploy.Target(name="name_value") + assert arg == mock_val + arg = args[0].target_id + mock_val = "target_id_value" + assert arg == mock_val def test_create_target_flattened_error(): @@ -2509,9 +2666,15 @@ async def test_create_target_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].target == cloud_deploy.Target(name="name_value") - assert args[0].target_id == "target_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].target + mock_val = cloud_deploy.Target(name="name_value") + assert arg == mock_val + arg = args[0].target_id + mock_val = "target_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2529,9 +2692,8 @@ async def test_create_target_flattened_error_async(): ) -def test_update_target( - transport: str = "grpc", request_type=cloud_deploy.UpdateTargetRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.UpdateTargetRequest, dict,]) +def test_update_target(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2555,10 +2717,6 @@ def test_update_target( assert isinstance(response, future.Future) -def test_update_target_from_dict(): - test_update_target(request_type=dict) - - def test_update_target_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2677,8 +2835,12 @@ def test_update_target_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].target == cloud_deploy.Target(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].target + mock_val = cloud_deploy.Target(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val def test_update_target_flattened_error(): @@ -2717,8 +2879,12 @@ async def test_update_target_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].target == cloud_deploy.Target(name="name_value") - assert args[0].update_mask == field_mask_pb2.FieldMask(paths=["paths_value"]) + arg = args[0].target + mock_val = cloud_deploy.Target(name="name_value") + assert arg == mock_val + arg = args[0].update_mask + mock_val = field_mask_pb2.FieldMask(paths=["paths_value"]) + assert arg == mock_val @pytest.mark.asyncio @@ -2735,9 +2901,8 @@ async def test_update_target_flattened_error_async(): ) -def test_delete_target( - transport: str = "grpc", request_type=cloud_deploy.DeleteTargetRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.DeleteTargetRequest, dict,]) +def test_delete_target(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2761,10 +2926,6 @@ def test_delete_target( assert isinstance(response, future.Future) -def test_delete_target_from_dict(): - test_delete_target(request_type=dict) - - def test_delete_target_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -2880,7 +3041,9 @@ def test_delete_target_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_delete_target_flattened_error(): @@ -2914,7 +3077,9 @@ async def test_delete_target_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -2929,9 +3094,8 @@ async def test_delete_target_flattened_error_async(): ) -def test_list_releases( - transport: str = "grpc", request_type=cloud_deploy.ListReleasesRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.ListReleasesRequest, dict,]) +def test_list_releases(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -2959,10 +3123,6 @@ def test_list_releases( assert response.unreachable == ["unreachable_value"] -def test_list_releases_from_dict(): - test_list_releases(request_type=dict) - - def test_list_releases_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3083,7 +3243,9 @@ def test_list_releases_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_releases_flattened_error(): @@ -3117,7 +3279,9 @@ async def test_list_releases_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3132,8 +3296,10 @@ async def test_list_releases_flattened_error_async(): ) -def test_list_releases_pager(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_releases_pager(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_releases), "__call__") as call: @@ -3170,8 +3336,10 @@ def test_list_releases_pager(): assert all(isinstance(i, cloud_deploy.Release) for i in results) -def test_list_releases_pages(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_releases_pages(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_releases), "__call__") as call: @@ -3270,9 +3438,8 @@ async def test_list_releases_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_release( - transport: str = "grpc", request_type=cloud_deploy.GetReleaseRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.GetReleaseRequest, dict,]) +def test_get_release(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3313,10 +3480,6 @@ def test_get_release( assert response.skaffold_version == "skaffold_version_value" -def test_get_release_from_dict(): - test_get_release(request_type=dict) - - def test_get_release_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3449,7 +3612,9 @@ def test_get_release_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_release_flattened_error(): @@ -3483,7 +3648,9 @@ async def test_get_release_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3498,9 +3665,8 @@ async def test_get_release_flattened_error_async(): ) -def test_create_release( - transport: str = "grpc", request_type=cloud_deploy.CreateReleaseRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.CreateReleaseRequest, dict,]) +def test_create_release(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3524,10 +3690,6 @@ def test_create_release( assert isinstance(response, future.Future) -def test_create_release_from_dict(): - test_create_release(request_type=dict) - - def test_create_release_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3647,9 +3809,15 @@ def test_create_release_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].release == cloud_deploy.Release(name="name_value") - assert args[0].release_id == "release_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].release + mock_val = cloud_deploy.Release(name="name_value") + assert arg == mock_val + arg = args[0].release_id + mock_val = "release_id_value" + assert arg == mock_val def test_create_release_flattened_error(): @@ -3690,9 +3858,15 @@ async def test_create_release_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].release == cloud_deploy.Release(name="name_value") - assert args[0].release_id == "release_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].release + mock_val = cloud_deploy.Release(name="name_value") + assert arg == mock_val + arg = args[0].release_id + mock_val = "release_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3710,9 +3884,8 @@ async def test_create_release_flattened_error_async(): ) -def test_approve_rollout( - transport: str = "grpc", request_type=cloud_deploy.ApproveRolloutRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.ApproveRolloutRequest, dict,]) +def test_approve_rollout(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3736,10 +3909,6 @@ def test_approve_rollout( assert isinstance(response, cloud_deploy.ApproveRolloutResponse) -def test_approve_rollout_from_dict(): - test_approve_rollout(request_type=dict) - - def test_approve_rollout_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -3855,7 +4024,9 @@ def test_approve_rollout_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_approve_rollout_flattened_error(): @@ -3889,7 +4060,9 @@ async def test_approve_rollout_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -3904,9 +4077,8 @@ async def test_approve_rollout_flattened_error_async(): ) -def test_list_rollouts( - transport: str = "grpc", request_type=cloud_deploy.ListRolloutsRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.ListRolloutsRequest, dict,]) +def test_list_rollouts(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -3934,10 +4106,6 @@ def test_list_rollouts( assert response.unreachable == ["unreachable_value"] -def test_list_rollouts_from_dict(): - test_list_rollouts(request_type=dict) - - def test_list_rollouts_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4058,7 +4226,9 @@ def test_list_rollouts_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val def test_list_rollouts_flattened_error(): @@ -4092,7 +4262,9 @@ async def test_list_rollouts_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4107,8 +4279,10 @@ async def test_list_rollouts_flattened_error_async(): ) -def test_list_rollouts_pager(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_rollouts_pager(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_rollouts), "__call__") as call: @@ -4145,8 +4319,10 @@ def test_list_rollouts_pager(): assert all(isinstance(i, cloud_deploy.Rollout) for i in results) -def test_list_rollouts_pages(): - client = CloudDeployClient(credentials=ga_credentials.AnonymousCredentials,) +def test_list_rollouts_pages(transport_name: str = "grpc"): + client = CloudDeployClient( + credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_rollouts), "__call__") as call: @@ -4245,9 +4421,8 @@ async def test_list_rollouts_async_pages(): assert page_.raw_page.next_page_token == token -def test_get_rollout( - transport: str = "grpc", request_type=cloud_deploy.GetRolloutRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.GetRolloutRequest, dict,]) +def test_get_rollout(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4290,10 +4465,6 @@ def test_get_rollout( assert response.etag == "etag_value" -def test_get_rollout_from_dict(): - test_get_rollout(request_type=dict) - - def test_get_rollout_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4428,7 +4599,9 @@ def test_get_rollout_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_rollout_flattened_error(): @@ -4462,7 +4635,9 @@ async def test_get_rollout_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4477,9 +4652,8 @@ async def test_get_rollout_flattened_error_async(): ) -def test_create_rollout( - transport: str = "grpc", request_type=cloud_deploy.CreateRolloutRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.CreateRolloutRequest, dict,]) +def test_create_rollout(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4503,10 +4677,6 @@ def test_create_rollout( assert isinstance(response, future.Future) -def test_create_rollout_from_dict(): - test_create_rollout(request_type=dict) - - def test_create_rollout_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4626,9 +4796,15 @@ def test_create_rollout_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].rollout == cloud_deploy.Rollout(name="name_value") - assert args[0].rollout_id == "rollout_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].rollout + mock_val = cloud_deploy.Rollout(name="name_value") + assert arg == mock_val + arg = args[0].rollout_id + mock_val = "rollout_id_value" + assert arg == mock_val def test_create_rollout_flattened_error(): @@ -4669,9 +4845,15 @@ async def test_create_rollout_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].parent == "parent_value" - assert args[0].rollout == cloud_deploy.Rollout(name="name_value") - assert args[0].rollout_id == "rollout_id_value" + arg = args[0].parent + mock_val = "parent_value" + assert arg == mock_val + arg = args[0].rollout + mock_val = cloud_deploy.Rollout(name="name_value") + assert arg == mock_val + arg = args[0].rollout_id + mock_val = "rollout_id_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4689,9 +4871,8 @@ async def test_create_rollout_flattened_error_async(): ) -def test_get_config( - transport: str = "grpc", request_type=cloud_deploy.GetConfigRequest -): +@pytest.mark.parametrize("request_type", [cloud_deploy.GetConfigRequest, dict,]) +def test_get_config(request_type, transport: str = "grpc"): client = CloudDeployClient( credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) @@ -4720,10 +4901,6 @@ def test_get_config( assert response.default_skaffold_version == "default_skaffold_version_value" -def test_get_config_from_dict(): - test_get_config(request_type=dict) - - def test_get_config_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. @@ -4842,7 +5019,9 @@ def test_get_config_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val def test_get_config_flattened_error(): @@ -4874,7 +5053,9 @@ async def test_get_config_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].name == "name_value" + arg = args[0].name + mock_val = "name_value" + assert arg == mock_val @pytest.mark.asyncio @@ -4909,6 +5090,23 @@ def test_credentials_transport_error(): transport=transport, ) + # It is an error to provide an api_key and a transport instance. + transport = transports.CloudDeployGrpcTransport( + credentials=ga_credentials.AnonymousCredentials(), + ) + options = client_options.ClientOptions() + options.api_key = "api_key" + with pytest.raises(ValueError): + client = CloudDeployClient(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 = CloudDeployClient( + client_options=options, credentials=ga_credentials.AnonymousCredentials() + ) + # It is an error to provide scopes and a transport instance. transport = transports.CloudDeployGrpcTransport( credentials=ga_credentials.AnonymousCredentials(), @@ -5619,7 +5817,7 @@ def test_parse_common_location_path(): assert expected == actual -def test_client_withDEFAULT_CLIENT_INFO(): +def test_client_with_default_client_info(): client_info = gapic_v1.client_info.ClientInfo() with mock.patch.object( @@ -5684,3 +5882,33 @@ def test_client_ctx(): with client: pass close.assert_called() + + +@pytest.mark.parametrize( + "client_class,transport_class", + [ + (CloudDeployClient, transports.CloudDeployGrpcTransport), + (CloudDeployAsyncClient, transports.CloudDeployGrpcAsyncIOTransport), + ], +) +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, + )