diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml new file mode 100644 index 00000000..864c1765 --- /dev/null +++ b/.github/.OwlBot.lock.yaml @@ -0,0 +1,3 @@ +docker: + image: gcr.io/repo-automation-bots/owlbot-python:latest + digest: sha256:4c981a6b6f2b8914a448d7b3a01688365be03e3ed26dfee399a6aa77fb112eaa diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml new file mode 100644 index 00000000..e25d4bdf --- /dev/null +++ b/.github/.OwlBot.yaml @@ -0,0 +1,26 @@ +# Copyright 2021 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/repo-automation-bots/owlbot-python:latest + +deep-remove-regex: + - /owl-bot-staging + +deep-copy-regex: + - source: /google/devtools/cloudbuild/(v.*)/.*-py/(.*) + dest: /owl-bot-staging/$1/$2 + +begin-after-commit-hash: 0a3c7d272d697796db75857bac73905c68e498c3 + diff --git a/.github/header-checker-lint.yml b/.github/header-checker-lint.yml index fc281c05..6fe78aa7 100644 --- a/.github/header-checker-lint.yml +++ b/.github/header-checker-lint.yml @@ -1,6 +1,6 @@ {"allowedCopyrightHolders": ["Google LLC"], "allowedLicenses": ["Apache-2.0", "MIT", "BSD-3"], - "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt"], + "ignoreFiles": ["**/requirements.txt", "**/requirements-test.txt", "**/__init__.py", "samples/**/constraints.txt", "samples/**/constraints-test.txt"], "sourceFileExtensions": [ "ts", "js", diff --git a/.kokoro/release.sh b/.kokoro/release.sh index e0fb9e49..4d10112c 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_KEYSTORE_DIR}/73713_google_cloud_pypi_password") +TWINE_PASSWORD=$(cat "${KOKORO_GFILE_DIR}/secret_manager/google-cloud-pypi-token") cd github/python-cloudbuild python3 setup.py sdist bdist_wheel -twine upload --username gcloudpypi --password "${TWINE_PASSWORD}" dist/* +twine upload --username __token__ --password "${TWINE_PASSWORD}" dist/* diff --git a/.kokoro/release/common.cfg b/.kokoro/release/common.cfg index 41909982..7163be78 100644 --- a/.kokoro/release/common.cfg +++ b/.kokoro/release/common.cfg @@ -23,18 +23,8 @@ env_vars: { value: "github/python-cloudbuild/.kokoro/release.sh" } -# Fetch PyPI password -before_action { - fetch_keystore { - keystore_resource { - keystore_config_id: 73713 - keyname: "google_cloud_pypi_password" - } - } -} - # 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" -} \ No newline at end of file + value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem,google-cloud-pypi-token" +} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 32302e48..4f00c7cf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,3 +1,17 @@ +# Copyright 2021 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. +# # See https://pre-commit.com for more information # See https://pre-commit.com/hooks.html for more hooks repos: @@ -12,6 +26,6 @@ repos: hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 - rev: 3.9.0 + rev: 3.9.2 hooks: - id: flake8 diff --git a/.repo-metadata.json b/.repo-metadata.json index d62d7467..a55cb6bc 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -6,6 +6,7 @@ "issue_tracker": "https://issuetracker.google.com/savedsearches/5226584", "release_level": "ga", "language": "python", + "library_type": "GAPIC_AUTO", "repo": "googleapis/python-cloudbuild", "distribution_name": "google-cloud-build", "api_id": "cloudbuild.googleapis.com", diff --git a/CHANGELOG.md b/CHANGELOG.md index c5d2340e..ccbfda9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-build/#history +### [3.2.1](https://www.github.com/googleapis/python-cloudbuild/compare/v3.2.0...v3.2.1) (2021-05-16) + + +### Bug Fixes + +* **deps:** add packaging requirement ([#101](https://www.github.com/googleapis/python-cloudbuild/issues/101)) ([9563889](https://www.github.com/googleapis/python-cloudbuild/commit/956388912b5aab80375c1a2439d934f211627e3a)) + ## [3.2.0](https://www.github.com/googleapis/python-cloudbuild/compare/v3.1.1...v3.2.0) (2021-04-01) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 5909ed16..74adb841 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -160,21 +160,7 @@ Running System Tests auth settings and change some configuration in your project to run all the tests. -- System tests will be run against an actual project and - so you'll need to provide some environment variables to facilitate - authentication to your project: - - - ``GOOGLE_APPLICATION_CREDENTIALS``: The path to a JSON key file; - Such a file can be downloaded directly from the developer's console by clicking - "Generate new JSON key". See private key - `docs `__ - for more details. - -- Once you have downloaded your json keys, set the environment variable - ``GOOGLE_APPLICATION_CREDENTIALS`` to the absolute path of the json file:: - - $ export GOOGLE_APPLICATION_CREDENTIALS="/Users//path/to/app_credentials.json" - +- System tests will be run against an actual project. You should use local credentials from gcloud when possible. See `Best practices for application authentication `__. Some tests require a service account. For those tests see `Authenticating as a service account `__. ************* Test Coverage diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 00000000..8b58ae9c --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,7 @@ +# Security Policy + +To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). + +The Google Security Team will respond within 5 working days of your report on g.co/vulnz. + +We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. diff --git a/docs/_static/custom.css b/docs/_static/custom.css index bcd37bbd..b0a29546 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -1,9 +1,20 @@ div#python2-eol { border-color: red; border-width: medium; -} +} /* Ensure minimum width for 'Parameters' / 'Returns' column */ dl.field-list > dt { min-width: 100px } + +/* Insert space between methods for readability */ +dl.method { + padding-top: 10px; + padding-bottom: 10px +} + +/* Insert empty space between classes */ +dl.class { + padding-bottom: 50px +} diff --git a/docs/cloudbuild_v1/cloud_build.rst b/docs/cloudbuild_v1/cloud_build.rst index 9fdbf01c..be81dc5c 100644 --- a/docs/cloudbuild_v1/cloud_build.rst +++ b/docs/cloudbuild_v1/cloud_build.rst @@ -5,7 +5,6 @@ CloudBuild :members: :inherited-members: - .. automodule:: google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers :members: :inherited-members: diff --git a/docs/conf.py b/docs/conf.py index 19e74d36..1c18ee7a 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,17 @@ # -*- coding: utf-8 -*- +# Copyright 2021 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. # # google-cloud-build documentation build configuration file # diff --git a/google/cloud/devtools/cloudbuild/__init__.py b/google/cloud/devtools/cloudbuild/__init__.py index 7e31cc89..1096a76f 100644 --- a/google/cloud/devtools/cloudbuild/__init__.py +++ b/google/cloud/devtools/cloudbuild/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,12 +14,13 @@ # limitations under the License. # -from google.cloud.devtools.cloudbuild_v1.services.cloud_build.async_client import ( - CloudBuildAsyncClient, -) from google.cloud.devtools.cloudbuild_v1.services.cloud_build.client import ( CloudBuildClient, ) +from google.cloud.devtools.cloudbuild_v1.services.cloud_build.async_client import ( + CloudBuildAsyncClient, +) + from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ArtifactResult from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Artifacts from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Build @@ -46,17 +46,18 @@ from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import GitHubEventsConfig from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Hash from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import InlineSecret +from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListBuildsRequest +from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListBuildsResponse from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ( ListBuildTriggersRequest, ) from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ( ListBuildTriggersResponse, ) -from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListBuildsRequest -from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListBuildsResponse from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListWorkerPoolsRequest from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ListWorkerPoolsResponse from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Network +from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import PubsubConfig from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import PullRequestFilter from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import PushFilter from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ( @@ -75,6 +76,7 @@ from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import Source from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import SourceProvenance from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import StorageSource +from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import StorageSourceManifest from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import TimeSpan from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import ( UpdateBuildTriggerRequest, @@ -85,6 +87,8 @@ from google.cloud.devtools.cloudbuild_v1.types.cloudbuild import WorkerPool __all__ = ( + "CloudBuildClient", + "CloudBuildAsyncClient", "ArtifactResult", "Artifacts", "Build", @@ -94,8 +98,6 @@ "BuildTrigger", "BuiltImage", "CancelBuildRequest", - "CloudBuildAsyncClient", - "CloudBuildClient", "CreateBuildRequest", "CreateBuildTriggerRequest", "CreateWorkerPoolRequest", @@ -108,13 +110,14 @@ "GitHubEventsConfig", "Hash", "InlineSecret", - "ListBuildTriggersRequest", - "ListBuildTriggersResponse", "ListBuildsRequest", "ListBuildsResponse", + "ListBuildTriggersRequest", + "ListBuildTriggersResponse", "ListWorkerPoolsRequest", "ListWorkerPoolsResponse", "Network", + "PubsubConfig", "PullRequestFilter", "PushFilter", "ReceiveTriggerWebhookRequest", @@ -129,6 +132,7 @@ "Source", "SourceProvenance", "StorageSource", + "StorageSourceManifest", "TimeSpan", "UpdateBuildTriggerRequest", "UpdateWorkerPoolRequest", diff --git a/google/cloud/devtools/cloudbuild_v1/__init__.py b/google/cloud/devtools/cloudbuild_v1/__init__.py index 2244534f..4e05790c 100644 --- a/google/cloud/devtools/cloudbuild_v1/__init__.py +++ b/google/cloud/devtools/cloudbuild_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -16,6 +15,8 @@ # from .services.cloud_build import CloudBuildClient +from .services.cloud_build import CloudBuildAsyncClient + from .types.cloudbuild import ArtifactResult from .types.cloudbuild import Artifacts from .types.cloudbuild import Build @@ -37,13 +38,14 @@ from .types.cloudbuild import GitHubEventsConfig from .types.cloudbuild import Hash from .types.cloudbuild import InlineSecret -from .types.cloudbuild import ListBuildTriggersRequest -from .types.cloudbuild import ListBuildTriggersResponse from .types.cloudbuild import ListBuildsRequest from .types.cloudbuild import ListBuildsResponse +from .types.cloudbuild import ListBuildTriggersRequest +from .types.cloudbuild import ListBuildTriggersResponse from .types.cloudbuild import ListWorkerPoolsRequest from .types.cloudbuild import ListWorkerPoolsResponse from .types.cloudbuild import Network +from .types.cloudbuild import PubsubConfig from .types.cloudbuild import PullRequestFilter from .types.cloudbuild import PushFilter from .types.cloudbuild import ReceiveTriggerWebhookRequest @@ -58,6 +60,7 @@ from .types.cloudbuild import Source from .types.cloudbuild import SourceProvenance from .types.cloudbuild import StorageSource +from .types.cloudbuild import StorageSourceManifest from .types.cloudbuild import TimeSpan from .types.cloudbuild import UpdateBuildTriggerRequest from .types.cloudbuild import UpdateWorkerPoolRequest @@ -65,8 +68,8 @@ from .types.cloudbuild import WorkerConfig from .types.cloudbuild import WorkerPool - __all__ = ( + "CloudBuildAsyncClient", "ArtifactResult", "Artifacts", "Build", @@ -76,6 +79,7 @@ "BuildTrigger", "BuiltImage", "CancelBuildRequest", + "CloudBuildClient", "CreateBuildRequest", "CreateBuildTriggerRequest", "CreateWorkerPoolRequest", @@ -95,6 +99,7 @@ "ListWorkerPoolsRequest", "ListWorkerPoolsResponse", "Network", + "PubsubConfig", "PullRequestFilter", "PushFilter", "ReceiveTriggerWebhookRequest", @@ -109,11 +114,11 @@ "Source", "SourceProvenance", "StorageSource", + "StorageSourceManifest", "TimeSpan", "UpdateBuildTriggerRequest", "UpdateWorkerPoolRequest", "Volume", "WorkerConfig", "WorkerPool", - "CloudBuildClient", ) diff --git a/google/cloud/devtools/cloudbuild_v1/gapic_metadata.json b/google/cloud/devtools/cloudbuild_v1/gapic_metadata.json new file mode 100644 index 00000000..e2f307b5 --- /dev/null +++ b/google/cloud/devtools/cloudbuild_v1/gapic_metadata.json @@ -0,0 +1,193 @@ + { + "comment": "This file maps proto services/RPCs to the corresponding library clients/methods", + "language": "python", + "libraryPackage": "google.devtools.cloudbuild_v1", + "protoPackage": "google.devtools.cloudbuild.v1", + "schema": "1.0", + "services": { + "CloudBuild": { + "clients": { + "grpc": { + "libraryClient": "CloudBuildClient", + "rpcs": { + "CancelBuild": { + "methods": [ + "cancel_build" + ] + }, + "CreateBuild": { + "methods": [ + "create_build" + ] + }, + "CreateBuildTrigger": { + "methods": [ + "create_build_trigger" + ] + }, + "CreateWorkerPool": { + "methods": [ + "create_worker_pool" + ] + }, + "DeleteBuildTrigger": { + "methods": [ + "delete_build_trigger" + ] + }, + "DeleteWorkerPool": { + "methods": [ + "delete_worker_pool" + ] + }, + "GetBuild": { + "methods": [ + "get_build" + ] + }, + "GetBuildTrigger": { + "methods": [ + "get_build_trigger" + ] + }, + "GetWorkerPool": { + "methods": [ + "get_worker_pool" + ] + }, + "ListBuildTriggers": { + "methods": [ + "list_build_triggers" + ] + }, + "ListBuilds": { + "methods": [ + "list_builds" + ] + }, + "ListWorkerPools": { + "methods": [ + "list_worker_pools" + ] + }, + "ReceiveTriggerWebhook": { + "methods": [ + "receive_trigger_webhook" + ] + }, + "RetryBuild": { + "methods": [ + "retry_build" + ] + }, + "RunBuildTrigger": { + "methods": [ + "run_build_trigger" + ] + }, + "UpdateBuildTrigger": { + "methods": [ + "update_build_trigger" + ] + }, + "UpdateWorkerPool": { + "methods": [ + "update_worker_pool" + ] + } + } + }, + "grpc-async": { + "libraryClient": "CloudBuildAsyncClient", + "rpcs": { + "CancelBuild": { + "methods": [ + "cancel_build" + ] + }, + "CreateBuild": { + "methods": [ + "create_build" + ] + }, + "CreateBuildTrigger": { + "methods": [ + "create_build_trigger" + ] + }, + "CreateWorkerPool": { + "methods": [ + "create_worker_pool" + ] + }, + "DeleteBuildTrigger": { + "methods": [ + "delete_build_trigger" + ] + }, + "DeleteWorkerPool": { + "methods": [ + "delete_worker_pool" + ] + }, + "GetBuild": { + "methods": [ + "get_build" + ] + }, + "GetBuildTrigger": { + "methods": [ + "get_build_trigger" + ] + }, + "GetWorkerPool": { + "methods": [ + "get_worker_pool" + ] + }, + "ListBuildTriggers": { + "methods": [ + "list_build_triggers" + ] + }, + "ListBuilds": { + "methods": [ + "list_builds" + ] + }, + "ListWorkerPools": { + "methods": [ + "list_worker_pools" + ] + }, + "ReceiveTriggerWebhook": { + "methods": [ + "receive_trigger_webhook" + ] + }, + "RetryBuild": { + "methods": [ + "retry_build" + ] + }, + "RunBuildTrigger": { + "methods": [ + "run_build_trigger" + ] + }, + "UpdateBuildTrigger": { + "methods": [ + "update_build_trigger" + ] + }, + "UpdateWorkerPool": { + "methods": [ + "update_worker_pool" + ] + } + } + } + } + } + } +} diff --git a/google/cloud/devtools/cloudbuild_v1/services/__init__.py b/google/cloud/devtools/cloudbuild_v1/services/__init__.py index 42ffdf2b..4de65971 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/__init__.py +++ b/google/cloud/devtools/cloudbuild_v1/services/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/__init__.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/__init__.py index 51798087..5850e361 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/__init__.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .client import CloudBuildClient from .async_client import CloudBuildAsyncClient diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py index 83ef39ff..36b0532d 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict import functools import re @@ -22,19 +20,18 @@ import pkg_resources import google.api_core.client_options as ClientOptions # type: ignore -from google.api_core import exceptions # 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.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.oauth2 import service_account # type: ignore from google.api_core import operation # type: ignore from google.api_core import operation_async # type: ignore from google.cloud.devtools.cloudbuild_v1.services.cloud_build import pagers from google.cloud.devtools.cloudbuild_v1.types import cloudbuild -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import CloudBuildTransport, DEFAULT_CLIENT_INFO from .transports.grpc_asyncio import CloudBuildGrpcAsyncIOTransport from .client import CloudBuildClient @@ -68,25 +65,24 @@ class CloudBuildAsyncClient: parse_service_account_path = staticmethod( CloudBuildClient.parse_service_account_path ) - + subscription_path = staticmethod(CloudBuildClient.subscription_path) + parse_subscription_path = staticmethod(CloudBuildClient.parse_subscription_path) + topic_path = staticmethod(CloudBuildClient.topic_path) + parse_topic_path = staticmethod(CloudBuildClient.parse_topic_path) common_billing_account_path = staticmethod( CloudBuildClient.common_billing_account_path ) parse_common_billing_account_path = staticmethod( CloudBuildClient.parse_common_billing_account_path ) - common_folder_path = staticmethod(CloudBuildClient.common_folder_path) parse_common_folder_path = staticmethod(CloudBuildClient.parse_common_folder_path) - common_organization_path = staticmethod(CloudBuildClient.common_organization_path) parse_common_organization_path = staticmethod( CloudBuildClient.parse_common_organization_path ) - common_project_path = staticmethod(CloudBuildClient.common_project_path) parse_common_project_path = staticmethod(CloudBuildClient.parse_common_project_path) - common_location_path = staticmethod(CloudBuildClient.common_location_path) parse_common_location_path = staticmethod( CloudBuildClient.parse_common_location_path @@ -94,7 +90,8 @@ class CloudBuildAsyncClient: @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -109,7 +106,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -126,7 +123,7 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CloudBuildTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: CloudBuildTransport: The transport used by the client instance. @@ -140,12 +137,12 @@ def transport(self) -> CloudBuildTransport: def __init__( self, *, - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, transport: Union[str, CloudBuildTransport] = "grpc_asyncio", client_options: ClientOptions = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the cloud build client. + """Instantiates the cloud build client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -177,7 +174,6 @@ def __init__( google.auth.exceptions.MutualTlsChannelError: If mutual TLS transport creation failed for any reason. """ - self._client = CloudBuildClient( credentials=credentials, transport=transport, @@ -214,7 +210,6 @@ async def create_build( This corresponds to the ``build`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -266,7 +261,6 @@ async def create_build( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if build is not None: @@ -323,7 +317,6 @@ async def get_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -371,7 +364,6 @@ async def get_build( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -386,7 +378,8 @@ async def get_build( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -429,7 +422,6 @@ async def list_builds( This corresponds to the ``filter`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -458,7 +450,6 @@ async def list_builds( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if filter is not None: @@ -473,7 +464,8 @@ async def list_builds( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -518,7 +510,6 @@ async def cancel_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -566,7 +557,6 @@ async def cancel_build( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -642,7 +632,6 @@ async def retry_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -694,7 +683,6 @@ async def retry_build( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -752,7 +740,6 @@ async def create_build_trigger( This corresponds to the ``trigger`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -780,7 +767,6 @@ async def create_build_trigger( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger is not None: @@ -832,7 +818,6 @@ async def get_build_trigger( This corresponds to the ``trigger_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -860,7 +845,6 @@ async def get_build_trigger( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -875,7 +859,8 @@ async def get_build_trigger( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -913,7 +898,6 @@ async def list_build_triggers( This corresponds to the ``project_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -942,7 +926,6 @@ async def list_build_triggers( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id @@ -955,7 +938,8 @@ async def list_build_triggers( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -1004,7 +988,6 @@ async def delete_build_trigger( This corresponds to the ``trigger_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1025,7 +1008,6 @@ async def delete_build_trigger( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1040,7 +1022,8 @@ async def delete_build_trigger( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -1089,7 +1072,6 @@ async def update_build_trigger( This corresponds to the ``trigger`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1117,7 +1099,6 @@ async def update_build_trigger( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1171,7 +1152,6 @@ async def run_build_trigger( This corresponds to the ``source`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1223,7 +1203,6 @@ async def run_build_trigger( # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1269,7 +1248,6 @@ async def receive_trigger_webhook( The request object. ReceiveTriggerWebhookRequest [Experimental] is the request object accepted by the ReceiveTriggerWebhook method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1283,7 +1261,6 @@ async def receive_trigger_webhook( """ # Create or coerce a protobuf request object. - request = cloudbuild.ReceiveTriggerWebhookRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1317,7 +1294,6 @@ async def create_worker_pool( request (:class:`google.cloud.devtools.cloudbuild_v1.types.CreateWorkerPoolRequest`): The request object. Request to create a new `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1341,7 +1317,6 @@ async def create_worker_pool( """ # Create or coerce a protobuf request object. - request = cloudbuild.CreateWorkerPoolRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1374,7 +1349,6 @@ async def get_worker_pool( request (:class:`google.cloud.devtools.cloudbuild_v1.types.GetWorkerPoolRequest`): The request object. Request to get a `WorkerPool` with the specified name. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1398,7 +1372,6 @@ async def get_worker_pool( """ # Create or coerce a protobuf request object. - request = cloudbuild.GetWorkerPoolRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1410,7 +1383,8 @@ async def get_worker_pool( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -1439,7 +1413,6 @@ async def delete_worker_pool( Args: request (:class:`google.cloud.devtools.cloudbuild_v1.types.DeleteWorkerPoolRequest`): The request object. Request to delete a `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1447,7 +1420,6 @@ async def delete_worker_pool( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - request = cloudbuild.DeleteWorkerPoolRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1478,7 +1450,6 @@ async def update_worker_pool( Args: request (:class:`google.cloud.devtools.cloudbuild_v1.types.UpdateWorkerPoolRequest`): The request object. Request to update a `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1502,7 +1473,6 @@ async def update_worker_pool( """ # Create or coerce a protobuf request object. - request = cloudbuild.UpdateWorkerPoolRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1534,7 +1504,6 @@ async def list_worker_pools( Args: request (:class:`google.cloud.devtools.cloudbuild_v1.types.ListWorkerPoolsRequest`): The request object. Request to list `WorkerPools`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1546,7 +1515,6 @@ async def list_worker_pools( Response containing existing WorkerPools. """ # Create or coerce a protobuf request object. - request = cloudbuild.ListWorkerPoolsRequest(request) # Wrap the RPC method; this adds retry and timeout information, @@ -1558,7 +1526,8 @@ async def list_worker_pools( maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py index 3dfc50f1..6f3a91a3 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from distutils import util import os @@ -23,10 +21,10 @@ import pkg_resources from google.api_core import client_options as client_options_lib # type: ignore -from google.api_core import exceptions # 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.auth import credentials # type: ignore +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 @@ -36,9 +34,8 @@ from google.api_core import operation_async # type: ignore from google.cloud.devtools.cloudbuild_v1.services.cloud_build import pagers from google.cloud.devtools.cloudbuild_v1.types import cloudbuild -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore - +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore from .transports.base import CloudBuildTransport, DEFAULT_CLIENT_INFO from .transports.grpc import CloudBuildGrpcTransport from .transports.grpc_asyncio import CloudBuildGrpcAsyncIOTransport @@ -57,7 +54,7 @@ class CloudBuildClientMeta(type): _transport_registry["grpc_asyncio"] = CloudBuildGrpcAsyncIOTransport def get_transport_class(cls, label: str = None,) -> Type[CloudBuildTransport]: - """Return an appropriate transport class. + """Returns an appropriate transport class. Args: label: The name of the desired transport. If none is @@ -88,7 +85,8 @@ class CloudBuildClient(metaclass=CloudBuildClientMeta): @staticmethod def _get_default_mtls_endpoint(api_endpoint): - """Convert api endpoint to mTLS endpoint. + """Converts api endpoint to mTLS endpoint. + Convert "*.sandbox.googleapis.com" and "*.googleapis.com" to "*.mtls.sandbox.googleapis.com" and "*.mtls.googleapis.com" respectively. Args: @@ -122,7 +120,8 @@ def _get_default_mtls_endpoint(api_endpoint): @classmethod def from_service_account_info(cls, info: dict, *args, **kwargs): - """Creates an instance of this client using the provided credentials info. + """Creates an instance of this client using the provided credentials + info. Args: info (dict): The service account private key info. @@ -139,7 +138,7 @@ def from_service_account_info(cls, info: dict, *args, **kwargs): @classmethod def from_service_account_file(cls, filename: str, *args, **kwargs): """Creates an instance of this client using the provided credentials - file. + file. Args: filename (str): The path to the service account private key json @@ -158,47 +157,48 @@ def from_service_account_file(cls, filename: str, *args, **kwargs): @property def transport(self) -> CloudBuildTransport: - """Return the transport used by the client instance. + """Returns the transport used by the client instance. Returns: - CloudBuildTransport: The transport used by the client instance. + CloudBuildTransport: The transport used by the client + instance. """ return self._transport @staticmethod def build_path(project: str, build: str,) -> str: - """Return a fully-qualified build string.""" + """Returns a fully-qualified build string.""" return "projects/{project}/builds/{build}".format(project=project, build=build,) @staticmethod def parse_build_path(path: str) -> Dict[str, str]: - """Parse a build path into its component segments.""" + """Parses a build path into its component segments.""" m = re.match(r"^projects/(?P.+?)/builds/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def build_trigger_path(project: str, trigger: str,) -> str: - """Return a fully-qualified build_trigger string.""" + """Returns a fully-qualified build_trigger string.""" return "projects/{project}/triggers/{trigger}".format( project=project, trigger=trigger, ) @staticmethod def parse_build_trigger_path(path: str) -> Dict[str, str]: - """Parse a build_trigger path into its component segments.""" + """Parses a build_trigger path into its component segments.""" m = re.match(r"^projects/(?P.+?)/triggers/(?P.+?)$", path) return m.groupdict() if m else {} @staticmethod def crypto_key_path(project: str, location: str, keyring: str, key: str,) -> str: - """Return a fully-qualified crypto_key string.""" + """Returns a fully-qualified crypto_key string.""" return "projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}".format( project=project, location=location, keyring=keyring, key=key, ) @staticmethod def parse_crypto_key_path(path: str) -> Dict[str, str]: - """Parse a crypto_key path into its component segments.""" + """Parses a crypto_key path into its component segments.""" m = re.match( r"^projects/(?P.+?)/locations/(?P.+?)/keyRings/(?P.+?)/cryptoKeys/(?P.+?)$", path, @@ -207,14 +207,14 @@ def parse_crypto_key_path(path: str) -> Dict[str, str]: @staticmethod def secret_version_path(project: str, secret: str, version: str,) -> str: - """Return a fully-qualified secret_version string.""" + """Returns a fully-qualified secret_version string.""" return "projects/{project}/secrets/{secret}/versions/{version}".format( project=project, secret=secret, version=version, ) @staticmethod def parse_secret_version_path(path: str) -> Dict[str, str]: - """Parse a secret_version path into its component segments.""" + """Parses a secret_version path into its component segments.""" m = re.match( r"^projects/(?P.+?)/secrets/(?P.+?)/versions/(?P.+?)$", path, @@ -223,23 +223,49 @@ def parse_secret_version_path(path: str) -> Dict[str, str]: @staticmethod def service_account_path(project: str, service_account: str,) -> str: - """Return a fully-qualified service_account string.""" + """Returns a fully-qualified service_account string.""" return "projects/{project}/serviceAccounts/{service_account}".format( project=project, service_account=service_account, ) @staticmethod def parse_service_account_path(path: str) -> Dict[str, str]: - """Parse a service_account path into its component segments.""" + """Parses a service_account path into its component segments.""" m = re.match( r"^projects/(?P.+?)/serviceAccounts/(?P.+?)$", path, ) return m.groupdict() if m else {} + @staticmethod + def subscription_path(project: str, subscription: str,) -> str: + """Returns a fully-qualified subscription string.""" + return "projects/{project}/subscriptions/{subscription}".format( + project=project, subscription=subscription, + ) + + @staticmethod + def parse_subscription_path(path: str) -> Dict[str, str]: + """Parses a subscription path into its component segments.""" + m = re.match( + r"^projects/(?P.+?)/subscriptions/(?P.+?)$", path + ) + return m.groupdict() if m else {} + + @staticmethod + def topic_path(project: str, topic: str,) -> str: + """Returns a fully-qualified topic string.""" + return "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + + @staticmethod + def parse_topic_path(path: str) -> Dict[str, str]: + """Parses a topic path into its component segments.""" + m = re.match(r"^projects/(?P.+?)/topics/(?P.+?)$", path) + return m.groupdict() if m else {} + @staticmethod def common_billing_account_path(billing_account: str,) -> str: - """Return a fully-qualified billing_account string.""" + """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -252,7 +278,7 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: @staticmethod def common_folder_path(folder: str,) -> str: - """Return a fully-qualified folder string.""" + """Returns a fully-qualified folder string.""" return "folders/{folder}".format(folder=folder,) @staticmethod @@ -263,7 +289,7 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: @staticmethod def common_organization_path(organization: str,) -> str: - """Return a fully-qualified organization string.""" + """Returns a fully-qualified organization string.""" return "organizations/{organization}".format(organization=organization,) @staticmethod @@ -274,7 +300,7 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: @staticmethod def common_project_path(project: str,) -> str: - """Return a fully-qualified project string.""" + """Returns a fully-qualified project string.""" return "projects/{project}".format(project=project,) @staticmethod @@ -285,7 +311,7 @@ def parse_common_project_path(path: str) -> Dict[str, str]: @staticmethod def common_location_path(project: str, location: str,) -> str: - """Return a fully-qualified location string.""" + """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -299,12 +325,12 @@ def parse_common_location_path(path: str) -> Dict[str, str]: def __init__( self, *, - credentials: Optional[credentials.Credentials] = None, + credentials: Optional[ga_credentials.Credentials] = None, transport: Union[str, CloudBuildTransport, None] = None, client_options: Optional[client_options_lib.ClientOptions] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, ) -> None: - """Instantiate the cloud build client. + """Instantiates the cloud build client. Args: credentials (Optional[google.auth.credentials.Credentials]): The @@ -359,9 +385,10 @@ def __init__( client_cert_source_func = client_options.client_cert_source else: is_mtls = mtls.has_default_client_cert_source() - client_cert_source_func = ( - mtls.default_client_cert_source() if is_mtls else None - ) + 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: @@ -373,12 +400,14 @@ def __init__( elif use_mtls_env == "always": api_endpoint = self.DEFAULT_MTLS_ENDPOINT elif use_mtls_env == "auto": - api_endpoint = ( - self.DEFAULT_MTLS_ENDPOINT if is_mtls else self.DEFAULT_ENDPOINT - ) + 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" + "Unsupported GOOGLE_API_USE_MTLS_ENDPOINT value. Accepted " + "values: never, auto, always" ) # Save or instantiate the transport. @@ -393,8 +422,8 @@ def __init__( ) if client_options.scopes: raise ValueError( - "When providing a transport instance, " - "provide its scopes directly." + "When providing a transport instance, provide its scopes " + "directly." ) self._transport = transport else: @@ -438,7 +467,6 @@ def create_build( This corresponds to the ``build`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -492,10 +520,8 @@ def create_build( # there are no flattened fields. if not isinstance(request, cloudbuild.CreateBuildRequest): request = cloudbuild.CreateBuildRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if build is not None: @@ -548,7 +574,6 @@ def get_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -598,10 +623,8 @@ def get_build( # there are no flattened fields. if not isinstance(request, cloudbuild.GetBuildRequest): request = cloudbuild.GetBuildRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -646,7 +669,6 @@ def list_builds( This corresponds to the ``filter`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -677,10 +699,8 @@ def list_builds( # there are no flattened fields. if not isinstance(request, cloudbuild.ListBuildsRequest): request = cloudbuild.ListBuildsRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if filter is not None: @@ -727,7 +747,6 @@ def cancel_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -777,10 +796,8 @@ def cancel_build( # there are no flattened fields. if not isinstance(request, cloudbuild.CancelBuildRequest): request = cloudbuild.CancelBuildRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -852,7 +869,6 @@ def retry_build( This corresponds to the ``id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -906,10 +922,8 @@ def retry_build( # there are no flattened fields. if not isinstance(request, cloudbuild.RetryBuildRequest): request = cloudbuild.RetryBuildRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if id is not None: @@ -963,7 +977,6 @@ def create_build_trigger( This corresponds to the ``trigger`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -993,10 +1006,8 @@ def create_build_trigger( # there are no flattened fields. if not isinstance(request, cloudbuild.CreateBuildTriggerRequest): request = cloudbuild.CreateBuildTriggerRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger is not None: @@ -1044,7 +1055,6 @@ def get_build_trigger( This corresponds to the ``trigger_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1074,10 +1084,8 @@ def get_build_trigger( # there are no flattened fields. if not isinstance(request, cloudbuild.GetBuildTriggerRequest): request = cloudbuild.GetBuildTriggerRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1117,7 +1125,6 @@ def list_build_triggers( This corresponds to the ``project_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1148,10 +1155,8 @@ def list_build_triggers( # there are no flattened fields. if not isinstance(request, cloudbuild.ListBuildTriggersRequest): request = cloudbuild.ListBuildTriggersRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id @@ -1200,7 +1205,6 @@ def delete_build_trigger( This corresponds to the ``trigger_id`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1223,10 +1227,8 @@ def delete_build_trigger( # there are no flattened fields. if not isinstance(request, cloudbuild.DeleteBuildTriggerRequest): request = cloudbuild.DeleteBuildTriggerRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1277,7 +1279,6 @@ def update_build_trigger( This corresponds to the ``trigger`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1307,10 +1308,8 @@ def update_build_trigger( # there are no flattened fields. if not isinstance(request, cloudbuild.UpdateBuildTriggerRequest): request = cloudbuild.UpdateBuildTriggerRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1360,7 +1359,6 @@ def run_build_trigger( This corresponds to the ``source`` field on the ``request`` instance; if ``request`` is provided, this should not be set. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1414,10 +1412,8 @@ def run_build_trigger( # there are no flattened fields. if not isinstance(request, cloudbuild.RunBuildTriggerRequest): request = cloudbuild.RunBuildTriggerRequest(request) - # If we have keyword arguments corresponding to fields on the # request, apply these. - if project_id is not None: request.project_id = project_id if trigger_id is not None: @@ -1459,7 +1455,6 @@ def receive_trigger_webhook( The request object. ReceiveTriggerWebhookRequest [Experimental] is the request object accepted by the ReceiveTriggerWebhook method. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1473,7 +1468,6 @@ def receive_trigger_webhook( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.ReceiveTriggerWebhookRequest. # There's no risk of modifying the input as we've already verified @@ -1508,7 +1502,6 @@ def create_worker_pool( request (google.cloud.devtools.cloudbuild_v1.types.CreateWorkerPoolRequest): The request object. Request to create a new `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1532,7 +1525,6 @@ def create_worker_pool( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.CreateWorkerPoolRequest. # There's no risk of modifying the input as we've already verified @@ -1566,7 +1558,6 @@ def get_worker_pool( request (google.cloud.devtools.cloudbuild_v1.types.GetWorkerPoolRequest): The request object. Request to get a `WorkerPool` with the specified name. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1590,7 +1581,6 @@ def get_worker_pool( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.GetWorkerPoolRequest. # There's no risk of modifying the input as we've already verified @@ -1623,7 +1613,6 @@ def delete_worker_pool( Args: request (google.cloud.devtools.cloudbuild_v1.types.DeleteWorkerPoolRequest): The request object. Request to delete a `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1631,7 +1620,6 @@ def delete_worker_pool( sent along with the request as metadata. """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.DeleteWorkerPoolRequest. # There's no risk of modifying the input as we've already verified @@ -1663,7 +1651,6 @@ def update_worker_pool( Args: request (google.cloud.devtools.cloudbuild_v1.types.UpdateWorkerPoolRequest): The request object. Request to update a `WorkerPool`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1687,7 +1674,6 @@ def update_worker_pool( """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.UpdateWorkerPoolRequest. # There's no risk of modifying the input as we've already verified @@ -1720,7 +1706,6 @@ def list_worker_pools( Args: request (google.cloud.devtools.cloudbuild_v1.types.ListWorkerPoolsRequest): The request object. Request to list `WorkerPools`. - retry (google.api_core.retry.Retry): Designation of what errors, if any, should be retried. timeout (float): The timeout for this request. @@ -1732,7 +1717,6 @@ def list_worker_pools( Response containing existing WorkerPools. """ # Create or coerce a protobuf request object. - # Minor optimization to avoid making a copy if the user passes # in a cloudbuild.ListWorkerPoolsRequest. # There's no risk of modifying the input as we've already verified diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py index ea592e48..47cca6c1 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/pagers.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from typing import ( Any, AsyncIterable, @@ -117,7 +115,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and @@ -245,7 +243,7 @@ def __init__( *, metadata: Sequence[Tuple[str, str]] = () ): - """Instantiate the pager. + """Instantiates the pager. Args: method (Callable): The method that was originally called, and diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/__init__.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/__init__.py index e7b44965..93da597f 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/__init__.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from collections import OrderedDict from typing import Dict, Type diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/base.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/base.py index 12ec5e33..d17cd9ee 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/base.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/base.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,22 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import abc -import typing +from typing import Awaitable, Callable, Dict, Optional, Sequence, Union +import packaging.version import pkg_resources -from google import auth # type: ignore -from google.api_core import exceptions # type: ignore +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 -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.cloud.devtools.cloudbuild_v1.types import cloudbuild -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( @@ -40,27 +39,41 @@ except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() +try: + # google.auth.__version__ was added in 1.26.0 + _GOOGLE_AUTH_VERSION = google.auth.__version__ +except AttributeError: + try: # try pkg_resources if it is available + _GOOGLE_AUTH_VERSION = pkg_resources.get_distribution("google-auth").version + except pkg_resources.DistributionNotFound: # pragma: NO COVER + _GOOGLE_AUTH_VERSION = None + +_API_CORE_VERSION = google.api_core.__version__ + class CloudBuildTransport(abc.ABC): """Abstract transport class for CloudBuild.""" AUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + DEFAULT_HOST: str = "cloudbuild.googleapis.com" + def __init__( self, *, - host: str = "cloudbuild.googleapis.com", - credentials: credentials.Credentials = None, - credentials_file: typing.Optional[str] = None, - scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES, - quota_project_id: typing.Optional[str] = None, + host: str = DEFAULT_HOST, + credentials: ga_credentials.Credentials = None, + credentials_file: Optional[str] = None, + scopes: Optional[Sequence[str]] = None, + quota_project_id: Optional[str] = None, client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO, **kwargs, ) -> None: """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -69,7 +82,7 @@ def __init__( credentials_file (Optional[str]): A file with credentials that can be loaded with :func:`google.auth.load_credentials_from_file`. This argument is mutually exclusive with credentials. - scope (Optional[Sequence[str]]): A list of scopes. + scopes (Optional[Sequence[str]]): A list of scopes. quota_project_id (Optional[str]): An optional project to use for billing and quota. client_info (google.api_core.gapic_v1.client_info.ClientInfo): @@ -83,29 +96,76 @@ def __init__( host += ":443" self._host = host + scopes_kwargs = self._get_scopes_kwargs(self._host, scopes) + # Save the scopes. self._scopes = scopes or self.AUTH_SCOPES # If no credentials are provided, then determine the appropriate # defaults. if credentials and credentials_file: - raise exceptions.DuplicateCredentialArgs( + raise core_exceptions.DuplicateCredentialArgs( "'credentials_file' and 'credentials' are mutually exclusive" ) if credentials_file is not None: - credentials, _ = auth.load_credentials_from_file( - credentials_file, scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.load_credentials_from_file( + credentials_file, **scopes_kwargs, quota_project_id=quota_project_id ) elif credentials is None: - credentials, _ = auth.default( - scopes=self._scopes, quota_project_id=quota_project_id + credentials, _ = google.auth.default( + **scopes_kwargs, quota_project_id=quota_project_id ) # Save the credentials. self._credentials = credentials + # TODO(busunkim): These two class methods are in the base transport + # to avoid duplicating code across the transport classes. These functions + # should be deleted once the minimum required versions of google-api-core + # and google-auth are increased. + + # TODO: Remove this function once google-auth >= 1.25.0 is required + @classmethod + def _get_scopes_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Optional[Sequence[str]]]: + """Returns scopes kwargs to pass to google-auth methods depending on the google-auth version""" + + scopes_kwargs = {} + + if _GOOGLE_AUTH_VERSION and ( + packaging.version.parse(_GOOGLE_AUTH_VERSION) + >= packaging.version.parse("1.25.0") + ): + scopes_kwargs = {"scopes": scopes, "default_scopes": cls.AUTH_SCOPES} + else: + scopes_kwargs = {"scopes": scopes or cls.AUTH_SCOPES} + + return scopes_kwargs + + # TODO: Remove this function once google-api-core >= 1.26.0 is required + @classmethod + def _get_self_signed_jwt_kwargs( + cls, host: str, scopes: Optional[Sequence[str]] + ) -> Dict[str, Union[Optional[Sequence[str]], str]]: + """Returns kwargs to pass to grpc_helpers.create_channel depending on the google-api-core version""" + + self_signed_jwt_kwargs: Dict[str, Union[Optional[Sequence[str]], str]] = {} + + if _API_CORE_VERSION and ( + packaging.version.parse(_API_CORE_VERSION) + >= packaging.version.parse("1.26.0") + ): + self_signed_jwt_kwargs["default_scopes"] = cls.AUTH_SCOPES + self_signed_jwt_kwargs["scopes"] = scopes + self_signed_jwt_kwargs["default_host"] = cls.DEFAULT_HOST + else: + self_signed_jwt_kwargs["scopes"] = scopes or cls.AUTH_SCOPES + + return self_signed_jwt_kwargs + def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { @@ -119,7 +179,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -133,7 +194,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -158,7 +220,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -172,7 +235,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -186,7 +250,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -216,7 +281,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -236,7 +302,8 @@ def _prep_wrapped_messages(self, client_info): maximum=60.0, multiplier=1.3, predicate=retries.if_exception_type( - exceptions.DeadlineExceeded, exceptions.ServiceUnavailable, + core_exceptions.DeadlineExceeded, + core_exceptions.ServiceUnavailable, ), deadline=600.0, ), @@ -253,81 +320,74 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_build( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.CreateBuildRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def get_build( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.GetBuildRequest], - typing.Union[cloudbuild.Build, typing.Awaitable[cloudbuild.Build]], + Union[cloudbuild.Build, Awaitable[cloudbuild.Build]], ]: raise NotImplementedError() @property def list_builds( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.ListBuildsRequest], - typing.Union[ - cloudbuild.ListBuildsResponse, - typing.Awaitable[cloudbuild.ListBuildsResponse], - ], + Union[cloudbuild.ListBuildsResponse, Awaitable[cloudbuild.ListBuildsResponse]], ]: raise NotImplementedError() @property def cancel_build( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.CancelBuildRequest], - typing.Union[cloudbuild.Build, typing.Awaitable[cloudbuild.Build]], + Union[cloudbuild.Build, Awaitable[cloudbuild.Build]], ]: raise NotImplementedError() @property def retry_build( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.RetryBuildRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def create_build_trigger( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.CreateBuildTriggerRequest], - typing.Union[ - cloudbuild.BuildTrigger, typing.Awaitable[cloudbuild.BuildTrigger] - ], + Union[cloudbuild.BuildTrigger, Awaitable[cloudbuild.BuildTrigger]], ]: raise NotImplementedError() @property def get_build_trigger( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.GetBuildTriggerRequest], - typing.Union[ - cloudbuild.BuildTrigger, typing.Awaitable[cloudbuild.BuildTrigger] - ], + Union[cloudbuild.BuildTrigger, Awaitable[cloudbuild.BuildTrigger]], ]: raise NotImplementedError() @property def list_build_triggers( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.ListBuildTriggersRequest], - typing.Union[ + Union[ cloudbuild.ListBuildTriggersResponse, - typing.Awaitable[cloudbuild.ListBuildTriggersResponse], + Awaitable[cloudbuild.ListBuildTriggersResponse], ], ]: raise NotImplementedError() @@ -335,40 +395,38 @@ def list_build_triggers( @property def delete_build_trigger( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.DeleteBuildTriggerRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_build_trigger( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.UpdateBuildTriggerRequest], - typing.Union[ - cloudbuild.BuildTrigger, typing.Awaitable[cloudbuild.BuildTrigger] - ], + Union[cloudbuild.BuildTrigger, Awaitable[cloudbuild.BuildTrigger]], ]: raise NotImplementedError() @property def run_build_trigger( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.RunBuildTriggerRequest], - typing.Union[operations.Operation, typing.Awaitable[operations.Operation]], + Union[operations_pb2.Operation, Awaitable[operations_pb2.Operation]], ]: raise NotImplementedError() @property def receive_trigger_webhook( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.ReceiveTriggerWebhookRequest], - typing.Union[ + Union[ cloudbuild.ReceiveTriggerWebhookResponse, - typing.Awaitable[cloudbuild.ReceiveTriggerWebhookResponse], + Awaitable[cloudbuild.ReceiveTriggerWebhookResponse], ], ]: raise NotImplementedError() @@ -376,47 +434,47 @@ def receive_trigger_webhook( @property def create_worker_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.CreateWorkerPoolRequest], - typing.Union[cloudbuild.WorkerPool, typing.Awaitable[cloudbuild.WorkerPool]], + Union[cloudbuild.WorkerPool, Awaitable[cloudbuild.WorkerPool]], ]: raise NotImplementedError() @property def get_worker_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.GetWorkerPoolRequest], - typing.Union[cloudbuild.WorkerPool, typing.Awaitable[cloudbuild.WorkerPool]], + Union[cloudbuild.WorkerPool, Awaitable[cloudbuild.WorkerPool]], ]: raise NotImplementedError() @property def delete_worker_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.DeleteWorkerPoolRequest], - typing.Union[empty.Empty, typing.Awaitable[empty.Empty]], + Union[empty_pb2.Empty, Awaitable[empty_pb2.Empty]], ]: raise NotImplementedError() @property def update_worker_pool( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.UpdateWorkerPoolRequest], - typing.Union[cloudbuild.WorkerPool, typing.Awaitable[cloudbuild.WorkerPool]], + Union[cloudbuild.WorkerPool, Awaitable[cloudbuild.WorkerPool]], ]: raise NotImplementedError() @property def list_worker_pools( self, - ) -> typing.Callable[ + ) -> Callable[ [cloudbuild.ListWorkerPoolsRequest], - typing.Union[ + Union[ cloudbuild.ListWorkerPoolsResponse, - typing.Awaitable[cloudbuild.ListWorkerPoolsResponse], + Awaitable[cloudbuild.ListWorkerPoolsResponse], ], ]: raise NotImplementedError() diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py index 9f5e27f4..ea16a6b4 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,23 +13,21 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Callable, Dict, Optional, Sequence, Tuple +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 import auth # type: ignore -from google.auth import credentials # type: ignore +import google.auth # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore import grpc # type: ignore from google.cloud.devtools.cloudbuild_v1.types import cloudbuild -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import CloudBuildTransport, DEFAULT_CLIENT_INFO @@ -60,7 +57,7 @@ def __init__( self, *, host: str = "cloudbuild.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Sequence[str] = None, channel: grpc.Channel = None, @@ -74,7 +71,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -185,7 +183,7 @@ def __init__( def create_channel( cls, host: str = "cloudbuild.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: str = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -216,13 +214,15 @@ def create_channel( google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials`` and ``credentials_file`` are passed. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -249,7 +249,7 @@ def operations_client(self) -> operations_v1.OperationsClient: @property def create_build( self, - ) -> Callable[[cloudbuild.CreateBuildRequest], operations.Operation]: + ) -> Callable[[cloudbuild.CreateBuildRequest], operations_pb2.Operation]: r"""Return a callable for the create build method over gRPC. Starts a build with the specified configuration. @@ -272,7 +272,7 @@ def create_build( self._stubs["create_build"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuild", request_serializer=cloudbuild.CreateBuildRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_build"] @@ -361,7 +361,7 @@ def cancel_build( @property def retry_build( self, - ) -> Callable[[cloudbuild.RetryBuildRequest], operations.Operation]: + ) -> Callable[[cloudbuild.RetryBuildRequest], operations_pb2.Operation]: r"""Return a callable for the retry build method over gRPC. Creates a new build based on the specified build. @@ -409,7 +409,7 @@ def retry_build( self._stubs["retry_build"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RetryBuild", request_serializer=cloudbuild.RetryBuildRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["retry_build"] @@ -502,7 +502,7 @@ def list_build_triggers( @property def delete_build_trigger( self, - ) -> Callable[[cloudbuild.DeleteBuildTriggerRequest], empty.Empty]: + ) -> Callable[[cloudbuild.DeleteBuildTriggerRequest], empty_pb2.Empty]: r"""Return a callable for the delete build trigger method over gRPC. Deletes a ``BuildTrigger`` by its project ID and trigger ID. @@ -523,7 +523,7 @@ def delete_build_trigger( self._stubs["delete_build_trigger"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteBuildTrigger", request_serializer=cloudbuild.DeleteBuildTriggerRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_build_trigger"] @@ -558,7 +558,7 @@ def update_build_trigger( @property def run_build_trigger( self, - ) -> Callable[[cloudbuild.RunBuildTriggerRequest], operations.Operation]: + ) -> Callable[[cloudbuild.RunBuildTriggerRequest], operations_pb2.Operation]: r"""Return a callable for the run build trigger method over gRPC. Runs a ``BuildTrigger`` at a particular source revision. @@ -577,7 +577,7 @@ def run_build_trigger( self._stubs["run_build_trigger"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RunBuildTrigger", request_serializer=cloudbuild.RunBuildTriggerRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["run_build_trigger"] @@ -671,7 +671,7 @@ def get_worker_pool( @property def delete_worker_pool( self, - ) -> Callable[[cloudbuild.DeleteWorkerPoolRequest], empty.Empty]: + ) -> Callable[[cloudbuild.DeleteWorkerPoolRequest], empty_pb2.Empty]: r"""Return a callable for the delete worker pool method over gRPC. Deletes a ``WorkerPool`` by its project ID and WorkerPool name. @@ -692,7 +692,7 @@ def delete_worker_pool( self._stubs["delete_worker_pool"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteWorkerPool", request_serializer=cloudbuild.DeleteWorkerPoolRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_worker_pool"] diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py index 78696796..1baf0d5e 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/transports/grpc_asyncio.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,24 +13,22 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import warnings -from typing import Awaitable, Callable, Dict, Optional, Sequence, Tuple +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 import auth # type: ignore -from google.auth import credentials # type: ignore +from google.auth import credentials as ga_credentials # type: ignore from google.auth.transport.grpc import SslCredentials # type: ignore +import packaging.version import grpc # type: ignore from grpc.experimental import aio # type: ignore from google.cloud.devtools.cloudbuild_v1.types import cloudbuild -from google.longrunning import operations_pb2 as operations # type: ignore -from google.protobuf import empty_pb2 as empty # type: ignore - +from google.longrunning import operations_pb2 # type: ignore +from google.protobuf import empty_pb2 # type: ignore from .base import CloudBuildTransport, DEFAULT_CLIENT_INFO from .grpc import CloudBuildGrpcTransport @@ -63,7 +60,7 @@ class CloudBuildGrpcAsyncIOTransport(CloudBuildTransport): def create_channel( cls, host: str = "cloudbuild.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, quota_project_id: Optional[str] = None, @@ -90,13 +87,15 @@ def create_channel( Returns: aio.Channel: A gRPC AsyncIO channel object. """ - scopes = scopes or cls.AUTH_SCOPES + + self_signed_jwt_kwargs = cls._get_self_signed_jwt_kwargs(host, scopes) + return grpc_helpers_async.create_channel( host, credentials=credentials, credentials_file=credentials_file, - scopes=scopes, quota_project_id=quota_project_id, + **self_signed_jwt_kwargs, **kwargs, ) @@ -104,7 +103,7 @@ def __init__( self, *, host: str = "cloudbuild.googleapis.com", - credentials: credentials.Credentials = None, + credentials: ga_credentials.Credentials = None, credentials_file: Optional[str] = None, scopes: Optional[Sequence[str]] = None, channel: aio.Channel = None, @@ -118,7 +117,8 @@ def __init__( """Instantiate the transport. Args: - host (Optional[str]): The hostname to connect to. + host (Optional[str]): + The hostname to connect to. credentials (Optional[google.auth.credentials.Credentials]): The authorization credentials to attach to requests. These credentials identify the application to the service; if none @@ -177,7 +177,6 @@ def __init__( # If a channel was explicitly provided, set it. self._grpc_channel = channel self._ssl_channel_credentials = None - else: if api_mtls_endpoint: host = api_mtls_endpoint @@ -255,7 +254,7 @@ def operations_client(self) -> operations_v1.OperationsAsyncClient: @property def create_build( self, - ) -> Callable[[cloudbuild.CreateBuildRequest], Awaitable[operations.Operation]]: + ) -> Callable[[cloudbuild.CreateBuildRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the create build method over gRPC. Starts a build with the specified configuration. @@ -278,7 +277,7 @@ def create_build( self._stubs["create_build"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/CreateBuild", request_serializer=cloudbuild.CreateBuildRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["create_build"] @@ -371,7 +370,7 @@ def cancel_build( @property def retry_build( self, - ) -> Callable[[cloudbuild.RetryBuildRequest], Awaitable[operations.Operation]]: + ) -> Callable[[cloudbuild.RetryBuildRequest], Awaitable[operations_pb2.Operation]]: r"""Return a callable for the retry build method over gRPC. Creates a new build based on the specified build. @@ -419,7 +418,7 @@ def retry_build( self._stubs["retry_build"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RetryBuild", request_serializer=cloudbuild.RetryBuildRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["retry_build"] @@ -517,7 +516,7 @@ def list_build_triggers( @property def delete_build_trigger( self, - ) -> Callable[[cloudbuild.DeleteBuildTriggerRequest], Awaitable[empty.Empty]]: + ) -> Callable[[cloudbuild.DeleteBuildTriggerRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete build trigger method over gRPC. Deletes a ``BuildTrigger`` by its project ID and trigger ID. @@ -538,7 +537,7 @@ def delete_build_trigger( self._stubs["delete_build_trigger"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteBuildTrigger", request_serializer=cloudbuild.DeleteBuildTriggerRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_build_trigger"] @@ -575,7 +574,9 @@ def update_build_trigger( @property def run_build_trigger( self, - ) -> Callable[[cloudbuild.RunBuildTriggerRequest], Awaitable[operations.Operation]]: + ) -> Callable[ + [cloudbuild.RunBuildTriggerRequest], Awaitable[operations_pb2.Operation] + ]: r"""Return a callable for the run build trigger method over gRPC. Runs a ``BuildTrigger`` at a particular source revision. @@ -594,7 +595,7 @@ def run_build_trigger( self._stubs["run_build_trigger"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/RunBuildTrigger", request_serializer=cloudbuild.RunBuildTriggerRequest.serialize, - response_deserializer=operations.Operation.FromString, + response_deserializer=operations_pb2.Operation.FromString, ) return self._stubs["run_build_trigger"] @@ -690,7 +691,7 @@ def get_worker_pool( @property def delete_worker_pool( self, - ) -> Callable[[cloudbuild.DeleteWorkerPoolRequest], Awaitable[empty.Empty]]: + ) -> Callable[[cloudbuild.DeleteWorkerPoolRequest], Awaitable[empty_pb2.Empty]]: r"""Return a callable for the delete worker pool method over gRPC. Deletes a ``WorkerPool`` by its project ID and WorkerPool name. @@ -711,7 +712,7 @@ def delete_worker_pool( self._stubs["delete_worker_pool"] = self.grpc_channel.unary_unary( "/google.devtools.cloudbuild.v1.CloudBuild/DeleteWorkerPool", request_serializer=cloudbuild.DeleteWorkerPoolRequest.serialize, - response_deserializer=empty.Empty.FromString, + response_deserializer=empty_pb2.Empty.FromString, ) return self._stubs["delete_worker_pool"] diff --git a/google/cloud/devtools/cloudbuild_v1/types/__init__.py b/google/cloud/devtools/cloudbuild_v1/types/__init__.py index 7a307ea5..be5de0af 100644 --- a/google/cloud/devtools/cloudbuild_v1/types/__init__.py +++ b/google/cloud/devtools/cloudbuild_v1/types/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - from .cloudbuild import ( ArtifactResult, Artifacts, @@ -44,6 +42,7 @@ ListWorkerPoolsRequest, ListWorkerPoolsResponse, Network, + PubsubConfig, PullRequestFilter, PushFilter, ReceiveTriggerWebhookRequest, @@ -58,6 +57,7 @@ Source, SourceProvenance, StorageSource, + StorageSourceManifest, TimeSpan, UpdateBuildTriggerRequest, UpdateWorkerPoolRequest, @@ -95,6 +95,7 @@ "ListWorkerPoolsRequest", "ListWorkerPoolsResponse", "Network", + "PubsubConfig", "PullRequestFilter", "PushFilter", "ReceiveTriggerWebhookRequest", @@ -109,6 +110,7 @@ "Source", "SourceProvenance", "StorageSource", + "StorageSourceManifest", "TimeSpan", "UpdateBuildTriggerRequest", "UpdateWorkerPoolRequest", diff --git a/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py b/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py index 05fdf497..da5aadf6 100644 --- a/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py +++ b/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,13 +13,11 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import proto # type: ignore - -from google.api import httpbody_pb2 as httpbody # type: ignore -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.api import httpbody_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore __protobuf__ = proto.module( @@ -30,6 +27,7 @@ "RunBuildTriggerRequest", "StorageSource", "RepoSource", + "StorageSourceManifest", "Source", "BuiltImage", "BuildStep", @@ -54,6 +52,7 @@ "CancelBuildRequest", "BuildTrigger", "GitHubEventsConfig", + "PubsubConfig", "PullRequestFilter", "PushFilter", "CreateBuildTriggerRequest", @@ -80,7 +79,6 @@ class RetryBuildRequest(proto.Message): r"""Specifies a build to retry. - Attributes: name (str): The name of the ``Build`` to retry. Format: @@ -91,16 +89,13 @@ class RetryBuildRequest(proto.Message): Required. Build ID of the original build. """ - name = proto.Field(proto.STRING, number=3) - - project_id = proto.Field(proto.STRING, number=1) - - id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=3,) + project_id = proto.Field(proto.STRING, number=1,) + id = proto.Field(proto.STRING, number=2,) class RunBuildTriggerRequest(proto.Message): r"""Specifies a build trigger to run and the source to use. - Attributes: project_id (str): Required. ID of the project. @@ -110,10 +105,8 @@ class RunBuildTriggerRequest(proto.Message): Source to build against this trigger. """ - project_id = proto.Field(proto.STRING, number=1) - - trigger_id = proto.Field(proto.STRING, number=2) - + project_id = proto.Field(proto.STRING, number=1,) + trigger_id = proto.Field(proto.STRING, number=2,) source = proto.Field(proto.MESSAGE, number=3, message="RepoSource",) @@ -137,16 +130,13 @@ class StorageSource(proto.Message): generation will be used. """ - bucket = proto.Field(proto.STRING, number=1) - - object_ = proto.Field(proto.STRING, number=2) - - generation = proto.Field(proto.INT64, number=3) + bucket = proto.Field(proto.STRING, number=1,) + object_ = proto.Field(proto.STRING, number=2,) + generation = proto.Field(proto.INT64, number=3,) class RepoSource(proto.Message): r"""Location of the source in a Google Cloud Source Repository. - Attributes: project_id (str): ID of the project that owns the Cloud Source @@ -181,26 +171,42 @@ class RepoSource(proto.Message): Should only be used with RunBuildTrigger """ - project_id = proto.Field(proto.STRING, number=1) - - repo_name = proto.Field(proto.STRING, number=2) + project_id = proto.Field(proto.STRING, number=1,) + repo_name = proto.Field(proto.STRING, number=2,) + branch_name = proto.Field(proto.STRING, number=3, oneof="revision",) + tag_name = proto.Field(proto.STRING, number=4, oneof="revision",) + commit_sha = proto.Field(proto.STRING, number=5, oneof="revision",) + dir_ = proto.Field(proto.STRING, number=7,) + invert_regex = proto.Field(proto.BOOL, number=8,) + substitutions = proto.MapField(proto.STRING, proto.STRING, number=9,) - branch_name = proto.Field(proto.STRING, number=3, oneof="revision") - tag_name = proto.Field(proto.STRING, number=4, oneof="revision") +class StorageSourceManifest(proto.Message): + r"""Location of the source manifest in Google Cloud Storage. + This feature is in Preview. - commit_sha = proto.Field(proto.STRING, number=5, oneof="revision") - - dir_ = proto.Field(proto.STRING, number=7) - - invert_regex = proto.Field(proto.BOOL, number=8) + Attributes: + bucket (str): + Google Cloud Storage bucket containing the source manifest + (see `Bucket Name + Requirements `__). + object_ (str): + Google Cloud Storage object containing the + source manifest. + This object must be a JSON file. + generation (int): + Google Cloud Storage generation for the + object. If the generation is omitted, the latest + generation will be used. + """ - substitutions = proto.MapField(proto.STRING, proto.STRING, number=9) + bucket = proto.Field(proto.STRING, number=1,) + object_ = proto.Field(proto.STRING, number=2,) + generation = proto.Field(proto.INT64, number=3,) class Source(proto.Message): r"""Location of the source in a supported storage service. - Attributes: storage_source (google.cloud.devtools.cloudbuild_v1.types.StorageSource): If provided, get the source from this @@ -208,20 +214,25 @@ class Source(proto.Message): repo_source (google.cloud.devtools.cloudbuild_v1.types.RepoSource): If provided, get the source from this location in a Cloud Source Repository. + storage_source_manifest (google.cloud.devtools.cloudbuild_v1.types.StorageSourceManifest): + If provided, get the source from this + manifest in Google Cloud Storage. This feature + is in Preview. """ storage_source = proto.Field( proto.MESSAGE, number=2, oneof="source", message="StorageSource", ) - repo_source = proto.Field( proto.MESSAGE, number=3, oneof="source", message="RepoSource", ) + storage_source_manifest = proto.Field( + proto.MESSAGE, number=8, oneof="source", message="StorageSourceManifest", + ) class BuiltImage(proto.Message): r"""An image built by the pipeline. - Attributes: name (str): Name used to push the container image to Google Container @@ -233,16 +244,13 @@ class BuiltImage(proto.Message): pushing the specified image. """ - name = proto.Field(proto.STRING, number=1) - - digest = proto.Field(proto.STRING, number=3) - + name = proto.Field(proto.STRING, number=1,) + digest = proto.Field(proto.STRING, number=3,) push_timing = proto.Field(proto.MESSAGE, number=4, message="TimeSpan",) class BuildStep(proto.Message): r"""A step in the build pipeline. - Attributes: name (str): Required. The name of the container image that will run this @@ -336,30 +344,18 @@ class BuildStep(proto.Message): real-time as the build progresses. """ - name = proto.Field(proto.STRING, number=1) - - env = proto.RepeatedField(proto.STRING, number=2) - - args = proto.RepeatedField(proto.STRING, number=3) - - dir_ = proto.Field(proto.STRING, number=4) - - id = proto.Field(proto.STRING, number=5) - - wait_for = proto.RepeatedField(proto.STRING, number=6) - - entrypoint = proto.Field(proto.STRING, number=7) - - secret_env = proto.RepeatedField(proto.STRING, number=8) - + name = proto.Field(proto.STRING, number=1,) + env = proto.RepeatedField(proto.STRING, number=2,) + args = proto.RepeatedField(proto.STRING, number=3,) + dir_ = proto.Field(proto.STRING, number=4,) + id = proto.Field(proto.STRING, number=5,) + wait_for = proto.RepeatedField(proto.STRING, number=6,) + entrypoint = proto.Field(proto.STRING, number=7,) + secret_env = proto.RepeatedField(proto.STRING, number=8,) volumes = proto.RepeatedField(proto.MESSAGE, number=9, message="Volume",) - timing = proto.Field(proto.MESSAGE, number=10, message="TimeSpan",) - pull_timing = proto.Field(proto.MESSAGE, number=13, message="TimeSpan",) - - timeout = proto.Field(proto.MESSAGE, number=11, message=duration.Duration,) - + timeout = proto.Field(proto.MESSAGE, number=11, message=duration_pb2.Duration,) status = proto.Field(proto.ENUM, number=12, enum="Build.Status",) @@ -382,14 +378,12 @@ class Volume(proto.Message): with certain reserved volume paths. """ - name = proto.Field(proto.STRING, number=1) - - path = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=1,) + path = proto.Field(proto.STRING, number=2,) class Results(proto.Message): r"""Artifacts created by the build pipeline. - Attributes: images (Sequence[google.cloud.devtools.cloudbuild_v1.types.BuiltImage]): Container images that were built as a part of @@ -417,15 +411,10 @@ class Results(proto.Message): """ images = proto.RepeatedField(proto.MESSAGE, number=2, message="BuiltImage",) - - build_step_images = proto.RepeatedField(proto.STRING, number=3) - - artifact_manifest = proto.Field(proto.STRING, number=4) - - num_artifacts = proto.Field(proto.INT64, number=5) - - build_step_outputs = proto.RepeatedField(proto.BYTES, number=6) - + build_step_images = proto.RepeatedField(proto.STRING, number=3,) + artifact_manifest = proto.Field(proto.STRING, number=4,) + num_artifacts = proto.Field(proto.INT64, number=5,) + build_step_outputs = proto.RepeatedField(proto.BYTES, number=6,) artifact_timing = proto.Field(proto.MESSAGE, number=7, message="TimeSpan",) @@ -442,8 +431,7 @@ class ArtifactResult(proto.Message): The file hash of the artifact. """ - location = proto.Field(proto.STRING, number=1) - + location = proto.Field(proto.STRING, number=1,) file_hash = proto.RepeatedField(proto.MESSAGE, number=2, message="FileHashes",) @@ -594,58 +582,33 @@ class Status(proto.Enum): CANCELLED = 7 EXPIRED = 9 - name = proto.Field(proto.STRING, number=45) - - id = proto.Field(proto.STRING, number=1) - - project_id = proto.Field(proto.STRING, number=16) - + name = proto.Field(proto.STRING, number=45,) + id = proto.Field(proto.STRING, number=1,) + project_id = proto.Field(proto.STRING, number=16,) status = proto.Field(proto.ENUM, number=2, enum=Status,) - - status_detail = proto.Field(proto.STRING, number=24) - + status_detail = proto.Field(proto.STRING, number=24,) source = proto.Field(proto.MESSAGE, number=3, message="Source",) - steps = proto.RepeatedField(proto.MESSAGE, number=11, message="BuildStep",) - results = proto.Field(proto.MESSAGE, number=10, message="Results",) - - create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp.Timestamp,) - - start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp.Timestamp,) - - finish_time = proto.Field(proto.MESSAGE, number=8, message=timestamp.Timestamp,) - - timeout = proto.Field(proto.MESSAGE, number=12, message=duration.Duration,) - - images = proto.RepeatedField(proto.STRING, number=13) - - queue_ttl = proto.Field(proto.MESSAGE, number=40, message=duration.Duration,) - + create_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) + finish_time = proto.Field(proto.MESSAGE, number=8, message=timestamp_pb2.Timestamp,) + timeout = proto.Field(proto.MESSAGE, number=12, message=duration_pb2.Duration,) + images = proto.RepeatedField(proto.STRING, number=13,) + queue_ttl = proto.Field(proto.MESSAGE, number=40, message=duration_pb2.Duration,) artifacts = proto.Field(proto.MESSAGE, number=37, message="Artifacts",) - - logs_bucket = proto.Field(proto.STRING, number=19) - + logs_bucket = proto.Field(proto.STRING, number=19,) source_provenance = proto.Field( proto.MESSAGE, number=21, message="SourceProvenance", ) - - build_trigger_id = proto.Field(proto.STRING, number=22) - + build_trigger_id = proto.Field(proto.STRING, number=22,) options = proto.Field(proto.MESSAGE, number=23, message="BuildOptions",) - - log_url = proto.Field(proto.STRING, number=25) - - substitutions = proto.MapField(proto.STRING, proto.STRING, number=29) - - tags = proto.RepeatedField(proto.STRING, number=31) - + log_url = proto.Field(proto.STRING, number=25,) + substitutions = proto.MapField(proto.STRING, proto.STRING, number=29,) + tags = proto.RepeatedField(proto.STRING, number=31,) secrets = proto.RepeatedField(proto.MESSAGE, number=32, message="Secret",) - timing = proto.MapField(proto.STRING, proto.MESSAGE, number=33, message="TimeSpan",) - - service_account = proto.Field(proto.STRING, number=42) - + service_account = proto.Field(proto.STRING, number=42,) available_secrets = proto.Field(proto.MESSAGE, number=47, message="Secrets",) @@ -702,20 +665,16 @@ class ArtifactObjects(proto.Message): pushing all artifact objects. """ - location = proto.Field(proto.STRING, number=1) - - paths = proto.RepeatedField(proto.STRING, number=2) - + location = proto.Field(proto.STRING, number=1,) + paths = proto.RepeatedField(proto.STRING, number=2,) timing = proto.Field(proto.MESSAGE, number=3, message="TimeSpan",) - images = proto.RepeatedField(proto.STRING, number=1) - + images = proto.RepeatedField(proto.STRING, number=1,) objects = proto.Field(proto.MESSAGE, number=2, message=ArtifactObjects,) class TimeSpan(proto.Message): r"""Start and end times for a build execution phase. - Attributes: start_time (google.protobuf.timestamp_pb2.Timestamp): Start of time span. @@ -723,14 +682,12 @@ class TimeSpan(proto.Message): End of time span. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp.Timestamp,) - - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp.Timestamp,) + start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) + end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) class BuildOperationMetadata(proto.Message): r"""Metadata for build operations. - Attributes: build (google.cloud.devtools.cloudbuild_v1.types.Build): The build that the operation is tracking. @@ -750,6 +707,10 @@ class SourceProvenance(proto.Message): resolved_repo_source (google.cloud.devtools.cloudbuild_v1.types.RepoSource): A copy of the build's ``source.repo_source``, if exists, with any revisions resolved. + resolved_storage_source_manifest (google.cloud.devtools.cloudbuild_v1.types.StorageSourceManifest): + A copy of the build's ``source.storage_source_manifest``, if + exists, with any revisions resolved. This feature is in + Preview. file_hashes (Sequence[google.cloud.devtools.cloudbuild_v1.types.SourceProvenance.FileHashesEntry]): Output only. Hash(es) of the build source, which can be used to verify that the original source integrity was maintained @@ -768,9 +729,10 @@ class SourceProvenance(proto.Message): resolved_storage_source = proto.Field( proto.MESSAGE, number=3, message="StorageSource", ) - resolved_repo_source = proto.Field(proto.MESSAGE, number=6, message="RepoSource",) - + resolved_storage_source_manifest = proto.Field( + proto.MESSAGE, number=9, message="StorageSourceManifest", + ) file_hashes = proto.MapField( proto.STRING, proto.MESSAGE, number=4, message="FileHashes", ) @@ -791,7 +753,6 @@ class FileHashes(proto.Message): class Hash(proto.Message): r"""Container message for hash values. - Attributes: type_ (google.cloud.devtools.cloudbuild_v1.types.Hash.HashType): The type of hash that was performed. @@ -806,13 +767,11 @@ class HashType(proto.Enum): MD5 = 2 type_ = proto.Field(proto.ENUM, number=1, enum=HashType,) - - value = proto.Field(proto.BYTES, number=2) + value = proto.Field(proto.BYTES, number=2,) class Secrets(proto.Message): r"""Secrets and secret environment variables. - Attributes: secret_manager (Sequence[google.cloud.devtools.cloudbuild_v1.types.SecretManagerSecret]): Secrets in Secret Manager and associated @@ -825,7 +784,6 @@ class Secrets(proto.Message): secret_manager = proto.RepeatedField( proto.MESSAGE, number=1, message="SecretManagerSecret", ) - inline = proto.RepeatedField(proto.MESSAGE, number=2, message="InlineSecret",) @@ -849,9 +807,8 @@ class InlineSecret(proto.Message): secret values across all of a build's secrets. """ - kms_key_name = proto.Field(proto.STRING, number=1) - - env_map = proto.MapField(proto.STRING, proto.BYTES, number=2) + kms_key_name = proto.Field(proto.STRING, number=1,) + env_map = proto.MapField(proto.STRING, proto.BYTES, number=2,) class SecretManagerSecret(proto.Message): @@ -869,9 +826,8 @@ class SecretManagerSecret(proto.Message): be used by at least one build step. """ - version_name = proto.Field(proto.STRING, number=1) - - env = proto.Field(proto.STRING, number=2) + version_name = proto.Field(proto.STRING, number=1,) + env = proto.Field(proto.STRING, number=2,) class Secret(proto.Message): @@ -895,14 +851,12 @@ class Secret(proto.Message): secret values across all of a build's secrets. """ - kms_key_name = proto.Field(proto.STRING, number=1) - - secret_env = proto.MapField(proto.STRING, proto.BYTES, number=3) + kms_key_name = proto.Field(proto.STRING, number=1,) + secret_env = proto.MapField(proto.STRING, proto.BYTES, number=3,) class CreateBuildRequest(proto.Message): r"""Request to create a new build. - Attributes: parent (str): The parent resource where this build will be created. @@ -913,16 +867,13 @@ class CreateBuildRequest(proto.Message): Required. Build resource to create. """ - parent = proto.Field(proto.STRING, number=4) - - project_id = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=4,) + project_id = proto.Field(proto.STRING, number=1,) build = proto.Field(proto.MESSAGE, number=2, message="Build",) class GetBuildRequest(proto.Message): r"""Request to get a build. - Attributes: name (str): The name of the ``Build`` to retrieve. Format: @@ -933,16 +884,13 @@ class GetBuildRequest(proto.Message): Required. ID of the build. """ - name = proto.Field(proto.STRING, number=4) - - project_id = proto.Field(proto.STRING, number=1) - - id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=4,) + project_id = proto.Field(proto.STRING, number=1,) + id = proto.Field(proto.STRING, number=2,) class ListBuildsRequest(proto.Message): r"""Request to list builds. - Attributes: parent (str): The parent of the collection of ``Builds``. Format: @@ -966,20 +914,15 @@ class ListBuildsRequest(proto.Message): The raw filter text to constrain the results. """ - parent = proto.Field(proto.STRING, number=9) - - project_id = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) - - filter = proto.Field(proto.STRING, number=8) + parent = proto.Field(proto.STRING, number=9,) + project_id = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) + filter = proto.Field(proto.STRING, number=8,) class ListBuildsResponse(proto.Message): r"""Response including listed builds. - Attributes: builds (Sequence[google.cloud.devtools.cloudbuild_v1.types.Build]): Builds will be sorted by ``create_time``, descending. @@ -994,13 +937,11 @@ def raw_page(self): return self builds = proto.RepeatedField(proto.MESSAGE, number=1, message="Build",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class CancelBuildRequest(proto.Message): r"""Request to cancel an ongoing build. - Attributes: name (str): The name of the ``Build`` to cancel. Format: @@ -1011,11 +952,9 @@ class CancelBuildRequest(proto.Message): Required. ID of the build. """ - name = proto.Field(proto.STRING, number=4) - - project_id = proto.Field(proto.STRING, number=1) - - id = proto.Field(proto.STRING, number=2) + name = proto.Field(proto.STRING, number=4,) + project_id = proto.Field(proto.STRING, number=1,) + id = proto.Field(proto.STRING, number=2,) class BuildTrigger(proto.Message): @@ -1052,6 +991,10 @@ class BuildTrigger(proto.Message): that creates a build whenever a GitHub event is received. Mutually exclusive with ``trigger_template``. + pubsub_config (google.cloud.devtools.cloudbuild_v1.types.PubsubConfig): + Optional. PubsubConfig describes the + configuration of a trigger that creates a build + whenever a Pub/Sub message is published. build (google.cloud.devtools.cloudbuild_v1.types.Build): Contents of the build template. filename (str): @@ -1088,35 +1031,28 @@ class BuildTrigger(proto.Message): ignored_files filter and included_files is not empty, then we make sure that at least one of those files matches a included_files glob. If not, then we do not trigger a build. + filter (str): + Optional. A Common Expression Language + string. """ - id = proto.Field(proto.STRING, number=1) - - description = proto.Field(proto.STRING, number=10) - - name = proto.Field(proto.STRING, number=21) - - tags = proto.RepeatedField(proto.STRING, number=19) - + id = proto.Field(proto.STRING, number=1,) + description = proto.Field(proto.STRING, number=10,) + name = proto.Field(proto.STRING, number=21,) + tags = proto.RepeatedField(proto.STRING, number=19,) trigger_template = proto.Field(proto.MESSAGE, number=7, message="RepoSource",) - github = proto.Field(proto.MESSAGE, number=13, message="GitHubEventsConfig",) - + pubsub_config = proto.Field(proto.MESSAGE, number=29, message="PubsubConfig",) build = proto.Field( proto.MESSAGE, number=4, oneof="build_template", message="Build", ) - - filename = proto.Field(proto.STRING, number=8, oneof="build_template") - - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp.Timestamp,) - - disabled = proto.Field(proto.BOOL, number=9) - - substitutions = proto.MapField(proto.STRING, proto.STRING, number=11) - - ignored_files = proto.RepeatedField(proto.STRING, number=15) - - included_files = proto.RepeatedField(proto.STRING, number=16) + filename = proto.Field(proto.STRING, number=8, oneof="build_template",) + create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) + disabled = proto.Field(proto.BOOL, number=9,) + substitutions = proto.MapField(proto.STRING, proto.STRING, number=11,) + ignored_files = proto.RepeatedField(proto.STRING, number=15,) + included_files = proto.RepeatedField(proto.STRING, number=16,) + filter = proto.Field(proto.STRING, number=30,) class GitHubEventsConfig(proto.Message): @@ -1145,19 +1081,52 @@ class GitHubEventsConfig(proto.Message): branches, tags. """ - installation_id = proto.Field(proto.INT64, number=1) - - owner = proto.Field(proto.STRING, number=6) - - name = proto.Field(proto.STRING, number=7) - + installation_id = proto.Field(proto.INT64, number=1,) + owner = proto.Field(proto.STRING, number=6,) + name = proto.Field(proto.STRING, number=7,) pull_request = proto.Field( proto.MESSAGE, number=4, oneof="event", message="PullRequestFilter", ) - push = proto.Field(proto.MESSAGE, number=5, oneof="event", message="PushFilter",) +class PubsubConfig(proto.Message): + r"""PubsubConfig describes the configuration of a trigger that + creates a build whenever a Pub/Sub message is published. + + Attributes: + subscription (str): + Output only. Name of the subscription. Format is + ``projects/{project}/subscriptions/{subscription}``. + topic (str): + The name of the topic from which this subscription is + receiving messages. Format is + ``projects/{project}/topics/{topic}``. + service_account_email (str): + Service account that will make the push + request. + state (google.cloud.devtools.cloudbuild_v1.types.PubsubConfig.State): + Potential issues with the underlying Pub/Sub + subscription configuration. Only populated on + get requests. + """ + + class State(proto.Enum): + r"""Enumerates potential issues with the underlying Pub/Sub + subscription configuration. + """ + STATE_UNSPECIFIED = 0 + OK = 1 + SUBSCRIPTION_DELETED = 2 + TOPIC_DELETED = 3 + SUBSCRIPTION_MISCONFIGURED = 4 + + subscription = proto.Field(proto.STRING, number=1,) + topic = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field(proto.STRING, number=3,) + state = proto.Field(proto.ENUM, number=4, enum=State,) + + class PullRequestFilter(proto.Message): r"""PullRequestFilter contains filter properties for matching GitHub Pull Requests. @@ -1182,11 +1151,9 @@ class CommentControl(proto.Enum): COMMENTS_ENABLED = 1 COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY = 2 - branch = proto.Field(proto.STRING, number=2, oneof="git_ref") - + branch = proto.Field(proto.STRING, number=2, oneof="git_ref",) comment_control = proto.Field(proto.ENUM, number=5, enum=CommentControl,) - - invert_regex = proto.Field(proto.BOOL, number=6) + invert_regex = proto.Field(proto.BOOL, number=6,) class PushFilter(proto.Message): @@ -1209,16 +1176,13 @@ class PushFilter(proto.Message): NOT match the git_ref regex. """ - branch = proto.Field(proto.STRING, number=2, oneof="git_ref") - - tag = proto.Field(proto.STRING, number=3, oneof="git_ref") - - invert_regex = proto.Field(proto.BOOL, number=4) + branch = proto.Field(proto.STRING, number=2, oneof="git_ref",) + tag = proto.Field(proto.STRING, number=3, oneof="git_ref",) + invert_regex = proto.Field(proto.BOOL, number=4,) class CreateBuildTriggerRequest(proto.Message): r"""Request to create a new ``BuildTrigger``. - Attributes: project_id (str): Required. ID of the project for which to @@ -1227,14 +1191,12 @@ class CreateBuildTriggerRequest(proto.Message): Required. ``BuildTrigger`` to create. """ - project_id = proto.Field(proto.STRING, number=1) - + project_id = proto.Field(proto.STRING, number=1,) trigger = proto.Field(proto.MESSAGE, number=2, message="BuildTrigger",) class GetBuildTriggerRequest(proto.Message): r"""Returns the ``BuildTrigger`` with the specified ID. - Attributes: project_id (str): Required. ID of the project that owns the @@ -1244,14 +1206,12 @@ class GetBuildTriggerRequest(proto.Message): ``BuildTrigger`` to get. """ - project_id = proto.Field(proto.STRING, number=1) - - trigger_id = proto.Field(proto.STRING, number=2) + project_id = proto.Field(proto.STRING, number=1,) + trigger_id = proto.Field(proto.STRING, number=2,) class ListBuildTriggersRequest(proto.Message): r"""Request to list existing ``BuildTriggers``. - Attributes: project_id (str): Required. ID of the project for which to list @@ -1263,16 +1223,13 @@ class ListBuildTriggersRequest(proto.Message): in the list. """ - project_id = proto.Field(proto.STRING, number=1) - - page_size = proto.Field(proto.INT32, number=2) - - page_token = proto.Field(proto.STRING, number=3) + project_id = proto.Field(proto.STRING, number=1,) + page_size = proto.Field(proto.INT32, number=2,) + page_token = proto.Field(proto.STRING, number=3,) class ListBuildTriggersResponse(proto.Message): r"""Response containing existing ``BuildTriggers``. - Attributes: triggers (Sequence[google.cloud.devtools.cloudbuild_v1.types.BuildTrigger]): ``BuildTriggers`` for the project, sorted by ``create_time`` @@ -1286,13 +1243,11 @@ def raw_page(self): return self triggers = proto.RepeatedField(proto.MESSAGE, number=1, message="BuildTrigger",) - - next_page_token = proto.Field(proto.STRING, number=2) + next_page_token = proto.Field(proto.STRING, number=2,) class DeleteBuildTriggerRequest(proto.Message): r"""Request to delete a ``BuildTrigger``. - Attributes: project_id (str): Required. ID of the project that owns the @@ -1301,14 +1256,12 @@ class DeleteBuildTriggerRequest(proto.Message): Required. ID of the ``BuildTrigger`` to delete. """ - project_id = proto.Field(proto.STRING, number=1) - - trigger_id = proto.Field(proto.STRING, number=2) + project_id = proto.Field(proto.STRING, number=1,) + trigger_id = proto.Field(proto.STRING, number=2,) class UpdateBuildTriggerRequest(proto.Message): r"""Request to update an existing ``BuildTrigger``. - Attributes: project_id (str): Required. ID of the project that owns the @@ -1319,16 +1272,13 @@ class UpdateBuildTriggerRequest(proto.Message): Required. ``BuildTrigger`` to update. """ - project_id = proto.Field(proto.STRING, number=1) - - trigger_id = proto.Field(proto.STRING, number=2) - + project_id = proto.Field(proto.STRING, number=1,) + trigger_id = proto.Field(proto.STRING, number=2,) trigger = proto.Field(proto.MESSAGE, number=3, message="BuildTrigger",) class BuildOptions(proto.Message): r"""Optional arguments to enable specific features of builds. - Attributes: source_provenance_hash (Sequence[google.cloud.devtools.cloudbuild_v1.types.Hash.HashType]): Requested hash for SourceProvenance. @@ -1444,27 +1394,16 @@ class LoggingMode(proto.Enum): source_provenance_hash = proto.RepeatedField( proto.ENUM, number=1, enum="Hash.HashType", ) - requested_verify_option = proto.Field(proto.ENUM, number=2, enum=VerifyOption,) - machine_type = proto.Field(proto.ENUM, number=3, enum=MachineType,) - - disk_size_gb = proto.Field(proto.INT64, number=6) - + disk_size_gb = proto.Field(proto.INT64, number=6,) substitution_option = proto.Field(proto.ENUM, number=4, enum=SubstitutionOption,) - - dynamic_substitutions = proto.Field(proto.BOOL, number=17) - + dynamic_substitutions = proto.Field(proto.BOOL, number=17,) log_streaming_option = proto.Field(proto.ENUM, number=5, enum=LogStreamingOption,) - - worker_pool = proto.Field(proto.STRING, number=7) - + worker_pool = proto.Field(proto.STRING, number=7,) logging = proto.Field(proto.ENUM, number=11, enum=LoggingMode,) - - env = proto.RepeatedField(proto.STRING, number=12) - - secret_env = proto.RepeatedField(proto.STRING, number=13) - + env = proto.RepeatedField(proto.STRING, number=12,) + secret_env = proto.RepeatedField(proto.STRING, number=13,) volumes = proto.RepeatedField(proto.MESSAGE, number=14, message="Volume",) @@ -1485,19 +1424,16 @@ class ReceiveTriggerWebhookRequest(proto.Message): OAuth token isn't provided. """ - body = proto.Field(proto.MESSAGE, number=1, message=httpbody.HttpBody,) - - project_id = proto.Field(proto.STRING, number=2) - - trigger = proto.Field(proto.STRING, number=3) - - secret = proto.Field(proto.STRING, number=4) + body = proto.Field(proto.MESSAGE, number=1, message=httpbody_pb2.HttpBody,) + project_id = proto.Field(proto.STRING, number=2,) + trigger = proto.Field(proto.STRING, number=3,) + secret = proto.Field(proto.STRING, number=4,) class ReceiveTriggerWebhookResponse(proto.Message): r"""ReceiveTriggerWebhookResponse [Experimental] is the response object for the ReceiveTriggerWebhook method. - """ + """ class WorkerPool(proto.Message): @@ -1561,24 +1497,21 @@ class Status(proto.Enum): DELETING = 3 DELETED = 4 - name = proto.Field(proto.STRING, number=14) - - project_id = proto.Field(proto.STRING, number=2) - - service_account_email = proto.Field(proto.STRING, number=3) - - worker_count = proto.Field(proto.INT64, number=4) - + name = proto.Field(proto.STRING, number=14,) + project_id = proto.Field(proto.STRING, number=2,) + service_account_email = proto.Field(proto.STRING, number=3,) + worker_count = proto.Field(proto.INT64, number=4,) worker_config = proto.Field(proto.MESSAGE, number=16, message="WorkerConfig",) - regions = proto.RepeatedField(proto.ENUM, number=9, enum=Region,) - - create_time = proto.Field(proto.MESSAGE, number=11, message=timestamp.Timestamp,) - - update_time = proto.Field(proto.MESSAGE, number=17, message=timestamp.Timestamp,) - - delete_time = proto.Field(proto.MESSAGE, number=12, message=timestamp.Timestamp,) - + create_time = proto.Field( + proto.MESSAGE, number=11, message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, number=17, message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, number=12, message=timestamp_pb2.Timestamp, + ) status = proto.Field(proto.ENUM, number=13, enum=Status,) @@ -1616,18 +1549,14 @@ class WorkerConfig(proto.Message): ``worker``. """ - machine_type = proto.Field(proto.STRING, number=1) - - disk_size_gb = proto.Field(proto.INT64, number=2) - + machine_type = proto.Field(proto.STRING, number=1,) + disk_size_gb = proto.Field(proto.INT64, number=2,) network = proto.Field(proto.MESSAGE, number=3, message="Network",) - - tag = proto.Field(proto.STRING, number=4) + tag = proto.Field(proto.STRING, number=4,) class Network(proto.Message): r"""Network describes the GCP network used to create workers in. - Attributes: project_id (str): Project id containing the defined network and subnetwork. @@ -1644,16 +1573,13 @@ class Network(proto.Message): "default" subnetwork is used if empty. """ - project_id = proto.Field(proto.STRING, number=1) - - network = proto.Field(proto.STRING, number=2) - - subnetwork = proto.Field(proto.STRING, number=3) + project_id = proto.Field(proto.STRING, number=1,) + network = proto.Field(proto.STRING, number=2,) + subnetwork = proto.Field(proto.STRING, number=3,) class CreateWorkerPoolRequest(proto.Message): r"""Request to create a new ``WorkerPool``. - Attributes: parent (str): ID of the parent project. @@ -1661,14 +1587,12 @@ class CreateWorkerPoolRequest(proto.Message): ``WorkerPool`` resource to create. """ - parent = proto.Field(proto.STRING, number=1) - + parent = proto.Field(proto.STRING, number=1,) worker_pool = proto.Field(proto.MESSAGE, number=2, message="WorkerPool",) class GetWorkerPoolRequest(proto.Message): r"""Request to get a ``WorkerPool`` with the specified name. - Attributes: name (str): The field will contain name of the resource @@ -1676,12 +1600,11 @@ class GetWorkerPoolRequest(proto.Message): "projects/project-1/workerPools/workerpool-name". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class DeleteWorkerPoolRequest(proto.Message): r"""Request to delete a ``WorkerPool``. - Attributes: name (str): The field will contain name of the resource @@ -1689,12 +1612,11 @@ class DeleteWorkerPoolRequest(proto.Message): "projects/project-1/workerPools/workerpool-name". """ - name = proto.Field(proto.STRING, number=1) + name = proto.Field(proto.STRING, number=1,) class UpdateWorkerPoolRequest(proto.Message): r"""Request to update a ``WorkerPool``. - Attributes: name (str): The field will contain name of the resource @@ -1704,25 +1626,22 @@ class UpdateWorkerPoolRequest(proto.Message): ``WorkerPool`` resource to update. """ - name = proto.Field(proto.STRING, number=2) - + name = proto.Field(proto.STRING, number=2,) worker_pool = proto.Field(proto.MESSAGE, number=3, message="WorkerPool",) class ListWorkerPoolsRequest(proto.Message): r"""Request to list ``WorkerPools``. - Attributes: parent (str): ID of the parent project. """ - parent = proto.Field(proto.STRING, number=1) + parent = proto.Field(proto.STRING, number=1,) class ListWorkerPoolsResponse(proto.Message): r"""Response containing existing ``WorkerPools``. - Attributes: worker_pools (Sequence[google.cloud.devtools.cloudbuild_v1.types.WorkerPool]): ``WorkerPools`` for the project. diff --git a/noxfile.py b/noxfile.py index 09285f41..ba47def1 100644 --- a/noxfile.py +++ b/noxfile.py @@ -62,16 +62,9 @@ def lint(session): session.run("flake8", "google", "tests") -@nox.session(python="3.6") +@nox.session(python=DEFAULT_PYTHON_VERSION) def blacken(session): - """Run black. - - Format code to uniform standard. - - This currently uses Python 3.6 due to the automated Kokoro run of synthtool. - That run uses an image that doesn't have 3.6 installed. Before updating this - check the state of the `gcp_ubuntu_config` we use for that Kokoro run. - """ + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( "black", *BLACK_PATHS, @@ -131,9 +124,6 @@ def system(session): # Check the value of `RUN_SYSTEM_TESTS` env var. It defaults to true. if os.environ.get("RUN_SYSTEM_TESTS", "true") == "false": session.skip("RUN_SYSTEM_TESTS is set to false, skipping") - # Sanity check: Only run tests if the environment variable is set. - if not os.environ.get("GOOGLE_APPLICATION_CREDENTIALS", ""): - session.skip("Credentials must be set via environment variable") # Install pyopenssl for mTLS testing. if os.environ.get("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false") == "true": session.install("pyopenssl") diff --git a/owlbot.py b/owlbot.py new file mode 100644 index 00000000..005bac3d --- /dev/null +++ b/owlbot.py @@ -0,0 +1,80 @@ +# Copyright 2019 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""This script is used to synthesize generated parts of this library.""" + +import synthtool as s +from synthtool import gcp + +common = gcp.CommonTemplates() + +default_version = "v1" + +for library in s.get_staging_dirs(default_version): + # Fix namespace + s.replace( + library / f"google/devtools/**/*.py", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + s.replace( + library / f"tests/unit/gapic/**/*.py", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + s.replace( + library / f"docs/**/*.rst", + f"google.devtools.cloudbuild_{library.name}", + f"google.cloud.devtools.cloudbuild_{library.name}", + ) + + # Rename package to `google-cloud-build` + s.replace( + [library / "**/*.rst", library / "*/**/*.py", library / "**/*.md"], + "google-cloud-devtools-cloudbuild", + "google-cloud-build" + ) + + s.move(library / "google/devtools/cloudbuild", "google/cloud/devtools/cloudbuild") + s.move( + library / f"google/devtools/cloudbuild_{library.name}", + f"google/cloud/devtools/cloudbuild_{library.name}" + ) + s.move(library / "tests") + s.move(library / "scripts") + s.move(library / "docs", excludes=["index.rst"]) + +s.remove_staging_dirs() + +# ---------------------------------------------------------------------------- +# Add templated files +# ---------------------------------------------------------------------------- +templated_files = common.py_library( + samples=False, # set to True only if there are samples + microgenerator=True, + cov_level=99, +) +s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file + +# TODO(busunkim): Use latest sphinx after microgenerator transition +s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') + +s.replace( + "noxfile.py", + "google.cloud.cloudbuild", + "google.cloud.devtools.cloudbuild", +) + + +s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/renovate.json b/renovate.json index f08bc22c..c0489556 100644 --- a/renovate.json +++ b/renovate.json @@ -2,5 +2,8 @@ "extends": [ "config:base", ":preserveSemverRanges" ], - "ignorePaths": [".pre-commit-config.yaml"] + "ignorePaths": [".pre-commit-config.yaml"], + "pip_requirements": { + "fileMatch": ["requirements-test.txt", "samples/[\\S/]*constraints.txt", "samples/[\\S/]*constraints-test.txt"] + } } diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 3413ad1c..11b890fa 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==6.0.1 \ No newline at end of file +pytest==6.2.4 \ No newline at end of file diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index d4940b99..3584b5c7 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-build==3.1.1 -google-auth==1.28.0 \ No newline at end of file +google-cloud-build==3.2.0 +google-auth==1.30.0 \ No newline at end of file diff --git a/scripts/fixup_cloudbuild_v1_keywords.py b/scripts/fixup_cloudbuild_v1_keywords.py index 61e295a7..97755811 100644 --- a/scripts/fixup_cloudbuild_v1_keywords.py +++ b/scripts/fixup_cloudbuild_v1_keywords.py @@ -1,6 +1,5 @@ #! /usr/bin/env python3 # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -15,7 +14,6 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import argparse import os import libcst as cst @@ -41,24 +39,23 @@ def partition( class cloudbuildCallTransformer(cst.CSTTransformer): CTRL_PARAMS: Tuple[str] = ('retry', 'timeout', 'metadata') METHOD_TO_PARAMS: Dict[str, Tuple[str]] = { - 'cancel_build': ('project_id', 'id', 'name', ), - 'create_build': ('project_id', 'build', 'parent', ), - 'create_build_trigger': ('project_id', 'trigger', ), - 'create_worker_pool': ('parent', 'worker_pool', ), - 'delete_build_trigger': ('project_id', 'trigger_id', ), - 'delete_worker_pool': ('name', ), - 'get_build': ('project_id', 'id', 'name', ), - 'get_build_trigger': ('project_id', 'trigger_id', ), - 'get_worker_pool': ('name', ), - 'list_builds': ('project_id', 'parent', 'page_size', 'page_token', 'filter', ), - 'list_build_triggers': ('project_id', 'page_size', 'page_token', ), - 'list_worker_pools': ('parent', ), - 'receive_trigger_webhook': ('body', 'project_id', 'trigger', 'secret', ), - 'retry_build': ('project_id', 'id', 'name', ), - 'run_build_trigger': ('project_id', 'trigger_id', 'source', ), - 'update_build_trigger': ('project_id', 'trigger_id', 'trigger', ), - 'update_worker_pool': ('name', 'worker_pool', ), - + 'cancel_build': ('project_id', 'id', 'name', ), + 'create_build': ('project_id', 'build', 'parent', ), + 'create_build_trigger': ('project_id', 'trigger', ), + 'create_worker_pool': ('parent', 'worker_pool', ), + 'delete_build_trigger': ('project_id', 'trigger_id', ), + 'delete_worker_pool': ('name', ), + 'get_build': ('project_id', 'id', 'name', ), + 'get_build_trigger': ('project_id', 'trigger_id', ), + 'get_worker_pool': ('name', ), + 'list_builds': ('project_id', 'parent', 'page_size', 'page_token', 'filter', ), + 'list_build_triggers': ('project_id', 'page_size', 'page_token', ), + 'list_worker_pools': ('parent', ), + 'receive_trigger_webhook': ('body', 'project_id', 'trigger', 'secret', ), + 'retry_build': ('project_id', 'id', 'name', ), + 'run_build_trigger': ('project_id', 'trigger_id', 'source', ), + 'update_build_trigger': ('project_id', 'trigger_id', 'trigger', ), + 'update_worker_pool': ('name', 'worker_pool', ), } def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: @@ -89,7 +86,7 @@ def leave_Call(self, original: cst.Call, updated: cst.Call) -> cst.CSTNode: value=cst.Dict([ cst.DictElement( cst.SimpleString("'{}'".format(name)), - cst.Element(value=arg.value) +cst.Element(value=arg.value) ) # Note: the args + kwargs looks silly, but keep in mind that # the control parameters had to be stripped out, and that diff --git a/setup.py b/setup.py index 3745b384..a20d18e5 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ name = "google-cloud-build" description = "Google Cloud Build API client library" -version = "3.2.0" +version = "3.2.1" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' @@ -30,6 +30,7 @@ dependencies = [ "google-api-core[grpc] >= 1.22.2, < 2.0.0dev", "proto-plus >= 0.4.0", + "packaging >= 14.3", ] extras = {"libcst": "libcst >= 0.2.5"} diff --git a/synth.metadata b/synth.metadata deleted file mode 100644 index a6878a70..00000000 --- a/synth.metadata +++ /dev/null @@ -1,37 +0,0 @@ -{ - "sources": [ - { - "git": { - "name": ".", - "remote": "git@github.com:googleapis/python-cloudbuild.git", - "sha": "1dee797ae62c2050bde2c90da15325468648c7bb" - } - }, - { - "git": { - "name": "googleapis", - "remote": "https://github.com/googleapis/googleapis.git", - "sha": "f6b491910e5ebbb7f3bb9b13f53294b6e94b2f48", - "internalRef": "366337595" - } - }, - { - "git": { - "name": "synthtool", - "remote": "https://github.com/googleapis/synthtool.git", - "sha": "6d76df2138f8f841e5a5b9ac427f81def520c15f" - } - } - ], - "destinations": [ - { - "client": { - "source": "googleapis", - "apiName": "cloudbuild", - "apiVersion": "v1", - "language": "python", - "generator": "bazel" - } - } - ] -} \ No newline at end of file diff --git a/synth.py b/synth.py deleted file mode 100644 index d69dd421..00000000 --- a/synth.py +++ /dev/null @@ -1,93 +0,0 @@ -# Copyright 2019 Google LLC -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -"""This script is used to synthesize generated parts of this library.""" - -import synthtool as s -from synthtool import gcp - -gapic = gcp.GAPICBazel() -common = gcp.CommonTemplates() -version = 'v1' - -# ---------------------------------------------------------------------------- -# Generate cloudbuild GAPIC layer -# ---------------------------------------------------------------------------- -library = gapic.py_library( - service='cloudbuild', - version=version, - bazel_target=f"//google/devtools/cloudbuild/{version}:devtools-cloudbuild-{version}-py", - include_protos=True, - proto_output_path=f"google/devtools/cloudbuild_{version}/proto", -) - -s.move(library / "google/devtools/cloudbuild", "google/cloud/devtools/cloudbuild") -s.move( - library / f"google/devtools/cloudbuild_{version}", - f"google/cloud/devtools/cloudbuild_{version}" -) -s.move(library / "tests") -s.move(library / "scripts") -s.move(library / "docs", excludes=[library / "docs/index.rst"]) - -# Fix namespace -s.replace( - f"google/cloud/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"tests/unit/gapic/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"google/cloud/**/*.py", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) -s.replace( - f"docs/**/*.rst", - f"google.devtools.cloudbuild_{version}", - f"google.cloud.devtools.cloudbuild_{version}", -) - -# Rename package to `google-cloud-build` -s.replace( - ["**/*.rst", "*/**/*.py", "**/*.md"], - "google-cloud-devtools-cloudbuild", - "google-cloud-build" -) - -# ---------------------------------------------------------------------------- -# Add templated files -# ---------------------------------------------------------------------------- -templated_files = common.py_library( - samples=False, # set to True only if there are samples - microgenerator=True, - cov_level=99, -) -s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file - -# TODO(busunkim): Use latest sphinx after microgenerator transition -s.replace("noxfile.py", """['"]sphinx['"]""", '"sphinx<3.0.0"') - -s.replace( - "noxfile.py", - "google.cloud.cloudbuild", - "google.cloud.devtools.cloudbuild", -) - - -s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/testing/constraints-3.6.txt b/testing/constraints-3.6.txt index 2a5b1cbf..594b2117 100644 --- a/testing/constraints-3.6.txt +++ b/testing/constraints-3.6.txt @@ -8,3 +8,4 @@ google-api-core==1.22.2 proto-plus==0.4.0 libcst==0.2.5 +packaging==14.3 diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..4de65971 --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 00000000..4de65971 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/__init__.py b/tests/unit/gapic/__init__.py new file mode 100644 index 00000000..4de65971 --- /dev/null +++ b/tests/unit/gapic/__init__.py @@ -0,0 +1,15 @@ +# -*- coding: utf-8 -*- +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# diff --git a/tests/unit/gapic/cloudbuild_v1/__init__.py b/tests/unit/gapic/cloudbuild_v1/__init__.py index 42ffdf2b..4de65971 100644 --- a/tests/unit/gapic/cloudbuild_v1/__init__.py +++ b/tests/unit/gapic/cloudbuild_v1/__init__.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py b/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py index 9aa7dec4..f3e4aa2b 100644 --- a/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py +++ b/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py @@ -1,5 +1,4 @@ # -*- coding: utf-8 -*- - # Copyright 2020 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -14,9 +13,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # - import os import mock +import packaging.version import grpc from grpc.experimental import aio @@ -24,17 +23,17 @@ import pytest from proto.marshal.rules.dates import DurationRule, TimestampRule -from google import auth -from google.api import httpbody_pb2 as httpbody # type: ignore + +from google.api import httpbody_pb2 # type: ignore from google.api_core import client_options -from google.api_core import exceptions +from google.api_core import exceptions as core_exceptions from google.api_core import future 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_async # type: ignore from google.api_core import operations_v1 -from google.auth import credentials +from google.auth import credentials as ga_credentials from google.auth.exceptions import MutualTLSChannelError from google.cloud.devtools.cloudbuild_v1.services.cloud_build import ( CloudBuildAsyncClient, @@ -42,12 +41,42 @@ from google.cloud.devtools.cloudbuild_v1.services.cloud_build import CloudBuildClient from google.cloud.devtools.cloudbuild_v1.services.cloud_build import pagers from google.cloud.devtools.cloudbuild_v1.services.cloud_build import transports +from google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.base import ( + _API_CORE_VERSION, +) +from google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.base import ( + _GOOGLE_AUTH_VERSION, +) from google.cloud.devtools.cloudbuild_v1.types import cloudbuild from google.longrunning import operations_pb2 from google.oauth2 import service_account -from google.protobuf import any_pb2 as gp_any # type: ignore -from google.protobuf import duration_pb2 as duration # type: ignore -from google.protobuf import timestamp_pb2 as timestamp # type: ignore +from google.protobuf import any_pb2 # type: ignore +from google.protobuf import duration_pb2 # type: ignore +from google.protobuf import timestamp_pb2 # type: ignore +import google.auth + + +# TODO(busunkim): Once google-api-core >= 1.26.0 is required: +# - Delete all the api-core and auth "less than" test cases +# - Delete these pytest markers (Make the "greater than or equal to" tests the default). +requires_google_auth_lt_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) >= packaging.version.parse("1.25.0"), + reason="This test requires google-auth < 1.25.0", +) +requires_google_auth_gte_1_25_0 = pytest.mark.skipif( + packaging.version.parse(_GOOGLE_AUTH_VERSION) < packaging.version.parse("1.25.0"), + reason="This test requires google-auth >= 1.25.0", +) + +requires_api_core_lt_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) >= packaging.version.parse("1.26.0"), + reason="This test requires google-api-core < 1.26.0", +) + +requires_api_core_gte_1_26_0 = pytest.mark.skipif( + packaging.version.parse(_API_CORE_VERSION) < packaging.version.parse("1.26.0"), + reason="This test requires google-api-core >= 1.26.0", +) def client_cert_source_callback(): @@ -93,7 +122,7 @@ def test__get_default_mtls_endpoint(): @pytest.mark.parametrize("client_class", [CloudBuildClient, CloudBuildAsyncClient,]) def test_cloud_build_client_from_service_account_info(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: @@ -108,7 +137,7 @@ def test_cloud_build_client_from_service_account_info(client_class): @pytest.mark.parametrize("client_class", [CloudBuildClient, CloudBuildAsyncClient,]) def test_cloud_build_client_from_service_account_file(client_class): - creds = credentials.AnonymousCredentials() + creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: @@ -159,7 +188,7 @@ def test_cloud_build_client_client_options( ): # Check that if channel is provided we won't create a new one. with mock.patch.object(CloudBuildClient, "get_transport_class") as gtc: - transport = transport_class(credentials=credentials.AnonymousCredentials()) + transport = transport_class(credentials=ga_credentials.AnonymousCredentials()) client = client_class(transport=transport) gtc.assert_not_called() @@ -443,7 +472,7 @@ def test_create_build( transport: str = "grpc", request_type=cloudbuild.CreateBuildRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -454,13 +483,11 @@ def test_create_build( with mock.patch.object(type(client.transport.create_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.create_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildRequest() # Establish that the response is the type that we expect. @@ -475,7 +502,7 @@ def test_create_build_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -483,7 +510,6 @@ def test_create_build_empty_call(): client.create_build() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildRequest() @@ -492,7 +518,7 @@ async def test_create_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateBuildRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -505,13 +531,11 @@ async def test_create_build_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.create_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildRequest() # Establish that the response is the type that we expect. @@ -524,13 +548,12 @@ async def test_create_build_async_from_dict(): def test_create_build_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_build( @@ -541,14 +564,12 @@ def test_create_build_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].build == cloudbuild.Build(name="name_value") def test_create_build_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -562,7 +583,7 @@ def test_create_build_flattened_error(): @pytest.mark.asyncio async def test_create_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.create_build), "__call__") as call: @@ -582,15 +603,13 @@ async def test_create_build_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].build == cloudbuild.Build(name="name_value") @pytest.mark.asyncio async def test_create_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -604,7 +623,7 @@ async def test_create_build_flattened_error_async(): def test_get_build(transport: str = "grpc", request_type=cloudbuild.GetBuildRequest): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -627,39 +646,25 @@ def test_get_build(transport: str = "grpc", request_type=cloudbuild.GetBuildRequ tags=["tags_value"], service_account="service_account_value", ) - response = client.get_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.Build) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.project_id == "project_id_value" - assert response.status == cloudbuild.Build.Status.QUEUED - assert response.status_detail == "status_detail_value" - assert response.images == ["images_value"] - assert response.logs_bucket == "logs_bucket_value" - assert response.build_trigger_id == "build_trigger_id_value" - assert response.log_url == "log_url_value" - assert response.tags == ["tags_value"] - assert response.service_account == "service_account_value" @@ -671,7 +676,7 @@ def test_get_build_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -679,7 +684,6 @@ def test_get_build_empty_call(): client.get_build() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildRequest() @@ -688,7 +692,7 @@ async def test_get_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetBuildRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -713,38 +717,25 @@ async def test_get_build_async( service_account="service_account_value", ) ) - response = await client.get_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.Build) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.project_id == "project_id_value" - assert response.status == cloudbuild.Build.Status.QUEUED - assert response.status_detail == "status_detail_value" - assert response.images == ["images_value"] - assert response.logs_bucket == "logs_bucket_value" - assert response.build_trigger_id == "build_trigger_id_value" - assert response.log_url == "log_url_value" - assert response.tags == ["tags_value"] - assert response.service_account == "service_account_value" @@ -754,13 +745,12 @@ async def test_get_build_async_from_dict(): def test_get_build_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.Build() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_build( @@ -771,14 +761,12 @@ def test_get_build_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" def test_get_build_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -790,7 +778,7 @@ def test_get_build_flattened_error(): @pytest.mark.asyncio async def test_get_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_build), "__call__") as call: @@ -806,15 +794,13 @@ async def test_get_build_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" @pytest.mark.asyncio async def test_get_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -828,7 +814,7 @@ def test_list_builds( transport: str = "grpc", request_type=cloudbuild.ListBuildsRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -841,19 +827,15 @@ def test_list_builds( call.return_value = cloudbuild.ListBuildsResponse( next_page_token="next_page_token_value", ) - response = client.list_builds(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBuildsPager) - assert response.next_page_token == "next_page_token_value" @@ -865,7 +847,7 @@ def test_list_builds_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -873,7 +855,6 @@ def test_list_builds_empty_call(): client.list_builds() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildsRequest() @@ -882,7 +863,7 @@ async def test_list_builds_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListBuildsRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -895,18 +876,15 @@ async def test_list_builds_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( cloudbuild.ListBuildsResponse(next_page_token="next_page_token_value",) ) - response = await client.list_builds(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildsRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListBuildsAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -916,13 +894,12 @@ async def test_list_builds_async_from_dict(): def test_list_builds_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_builds), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.ListBuildsResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_builds( @@ -933,14 +910,12 @@ def test_list_builds_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].filter == "filter_value" def test_list_builds_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -954,7 +929,7 @@ def test_list_builds_flattened_error(): @pytest.mark.asyncio async def test_list_builds_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_builds), "__call__") as call: @@ -974,15 +949,13 @@ async def test_list_builds_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].filter == "filter_value" @pytest.mark.asyncio async def test_list_builds_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -995,7 +968,7 @@ async def test_list_builds_flattened_error_async(): def test_list_builds_pager(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_builds), "__call__") as call: @@ -1026,7 +999,7 @@ def test_list_builds_pager(): def test_list_builds_pages(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.list_builds), "__call__") as call: @@ -1052,7 +1025,7 @@ def test_list_builds_pages(): @pytest.mark.asyncio async def test_list_builds_async_pager(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1085,7 +1058,7 @@ async def test_list_builds_async_pager(): @pytest.mark.asyncio async def test_list_builds_async_pages(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1117,7 +1090,7 @@ def test_cancel_build( transport: str = "grpc", request_type=cloudbuild.CancelBuildRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1140,39 +1113,25 @@ def test_cancel_build( tags=["tags_value"], service_account="service_account_value", ) - response = client.cancel_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CancelBuildRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.Build) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.project_id == "project_id_value" - assert response.status == cloudbuild.Build.Status.QUEUED - assert response.status_detail == "status_detail_value" - assert response.images == ["images_value"] - assert response.logs_bucket == "logs_bucket_value" - assert response.build_trigger_id == "build_trigger_id_value" - assert response.log_url == "log_url_value" - assert response.tags == ["tags_value"] - assert response.service_account == "service_account_value" @@ -1184,7 +1143,7 @@ def test_cancel_build_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1192,7 +1151,6 @@ def test_cancel_build_empty_call(): client.cancel_build() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CancelBuildRequest() @@ -1201,7 +1159,7 @@ async def test_cancel_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CancelBuildRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1226,38 +1184,25 @@ async def test_cancel_build_async( service_account="service_account_value", ) ) - response = await client.cancel_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CancelBuildRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.Build) - assert response.name == "name_value" - assert response.id == "id_value" - assert response.project_id == "project_id_value" - assert response.status == cloudbuild.Build.Status.QUEUED - assert response.status_detail == "status_detail_value" - assert response.images == ["images_value"] - assert response.logs_bucket == "logs_bucket_value" - assert response.build_trigger_id == "build_trigger_id_value" - assert response.log_url == "log_url_value" - assert response.tags == ["tags_value"] - assert response.service_account == "service_account_value" @@ -1267,13 +1212,12 @@ async def test_cancel_build_async_from_dict(): def test_cancel_build_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.Build() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_build( @@ -1284,14 +1228,12 @@ def test_cancel_build_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" def test_cancel_build_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1305,7 +1247,7 @@ def test_cancel_build_flattened_error(): @pytest.mark.asyncio async def test_cancel_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.cancel_build), "__call__") as call: @@ -1323,15 +1265,13 @@ async def test_cancel_build_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" @pytest.mark.asyncio async def test_cancel_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1347,7 +1287,7 @@ def test_retry_build( transport: str = "grpc", request_type=cloudbuild.RetryBuildRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1358,13 +1298,11 @@ def test_retry_build( with mock.patch.object(type(client.transport.retry_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.retry_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RetryBuildRequest() # Establish that the response is the type that we expect. @@ -1379,7 +1317,7 @@ def test_retry_build_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1387,7 +1325,6 @@ def test_retry_build_empty_call(): client.retry_build() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RetryBuildRequest() @@ -1396,7 +1333,7 @@ async def test_retry_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.RetryBuildRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1409,13 +1346,11 @@ async def test_retry_build_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.retry_build(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RetryBuildRequest() # Establish that the response is the type that we expect. @@ -1428,13 +1363,12 @@ async def test_retry_build_async_from_dict(): def test_retry_build_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.retry_build), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retry_build( @@ -1445,14 +1379,12 @@ def test_retry_build_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" def test_retry_build_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1466,7 +1398,7 @@ def test_retry_build_flattened_error(): @pytest.mark.asyncio async def test_retry_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.retry_build), "__call__") as call: @@ -1486,15 +1418,13 @@ async def test_retry_build_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].id == "id_value" @pytest.mark.asyncio async def test_retry_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1510,7 +1440,7 @@ def test_create_build_trigger( transport: str = "grpc", request_type=cloudbuild.CreateBuildTriggerRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1530,34 +1460,26 @@ def test_create_build_trigger( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", build=cloudbuild.Build(name="name_value"), ) - response = client.create_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildTriggerRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" def test_create_build_trigger_from_dict(): @@ -1568,7 +1490,7 @@ def test_create_build_trigger_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1578,7 +1500,6 @@ def test_create_build_trigger_empty_call(): client.create_build_trigger() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildTriggerRequest() @@ -1587,7 +1508,7 @@ async def test_create_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1608,33 +1529,26 @@ async def test_create_build_trigger_async( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", ) ) - response = await client.create_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateBuildTriggerRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" @pytest.mark.asyncio @@ -1643,7 +1557,7 @@ async def test_create_build_trigger_async_from_dict(): def test_create_build_trigger_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1651,7 +1565,6 @@ def test_create_build_trigger_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.BuildTrigger() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_build_trigger( @@ -1663,14 +1576,12 @@ def test_create_build_trigger_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger == cloudbuild.BuildTrigger(id="id_value") def test_create_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1684,7 +1595,7 @@ def test_create_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_create_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1707,15 +1618,13 @@ async def test_create_build_trigger_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger == cloudbuild.BuildTrigger(id="id_value") @pytest.mark.asyncio async def test_create_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1731,7 +1640,7 @@ def test_get_build_trigger( transport: str = "grpc", request_type=cloudbuild.GetBuildTriggerRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1751,34 +1660,26 @@ def test_get_build_trigger( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", build=cloudbuild.Build(name="name_value"), ) - response = client.get_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildTriggerRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" def test_get_build_trigger_from_dict(): @@ -1789,7 +1690,7 @@ def test_get_build_trigger_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1799,7 +1700,6 @@ def test_get_build_trigger_empty_call(): client.get_build_trigger() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildTriggerRequest() @@ -1808,7 +1708,7 @@ async def test_get_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1829,33 +1729,26 @@ async def test_get_build_trigger_async( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", ) ) - response = await client.get_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetBuildTriggerRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" @pytest.mark.asyncio @@ -1864,7 +1757,7 @@ async def test_get_build_trigger_async_from_dict(): def test_get_build_trigger_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1872,7 +1765,6 @@ def test_get_build_trigger_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.BuildTrigger() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_build_trigger( @@ -1883,14 +1775,12 @@ def test_get_build_trigger_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" def test_get_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1904,7 +1794,7 @@ def test_get_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_get_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1926,15 +1816,13 @@ async def test_get_build_trigger_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" @pytest.mark.asyncio async def test_get_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1950,7 +1838,7 @@ def test_list_build_triggers( transport: str = "grpc", request_type=cloudbuild.ListBuildTriggersRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1965,19 +1853,15 @@ def test_list_build_triggers( call.return_value = cloudbuild.ListBuildTriggersResponse( next_page_token="next_page_token_value", ) - response = client.list_build_triggers(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildTriggersRequest() # Establish that the response is the type that we expect. - assert isinstance(response, pagers.ListBuildTriggersPager) - assert response.next_page_token == "next_page_token_value" @@ -1989,7 +1873,7 @@ def test_list_build_triggers_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1999,7 +1883,6 @@ def test_list_build_triggers_empty_call(): client.list_build_triggers() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildTriggersRequest() @@ -2008,7 +1891,7 @@ async def test_list_build_triggers_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListBuildTriggersRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2025,18 +1908,15 @@ async def test_list_build_triggers_async( next_page_token="next_page_token_value", ) ) - response = await client.list_build_triggers(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListBuildTriggersRequest() # Establish that the response is the type that we expect. assert isinstance(response, pagers.ListBuildTriggersAsyncPager) - assert response.next_page_token == "next_page_token_value" @@ -2046,7 +1926,7 @@ async def test_list_build_triggers_async_from_dict(): def test_list_build_triggers_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2054,7 +1934,6 @@ def test_list_build_triggers_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.ListBuildTriggersResponse() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_build_triggers(project_id="project_id_value",) @@ -2063,12 +1942,11 @@ def test_list_build_triggers_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" def test_list_build_triggers_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2080,7 +1958,7 @@ def test_list_build_triggers_flattened_error(): @pytest.mark.asyncio async def test_list_build_triggers_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2100,13 +1978,12 @@ async def test_list_build_triggers_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" @pytest.mark.asyncio async def test_list_build_triggers_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2117,7 +1994,7 @@ async def test_list_build_triggers_flattened_error_async(): def test_list_build_triggers_pager(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2154,7 +2031,7 @@ def test_list_build_triggers_pager(): def test_list_build_triggers_pages(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2186,7 +2063,7 @@ def test_list_build_triggers_pages(): @pytest.mark.asyncio async def test_list_build_triggers_async_pager(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2225,7 +2102,7 @@ async def test_list_build_triggers_async_pager(): @pytest.mark.asyncio async def test_list_build_triggers_async_pages(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2263,7 +2140,7 @@ def test_delete_build_trigger( transport: str = "grpc", request_type=cloudbuild.DeleteBuildTriggerRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2276,13 +2153,11 @@ def test_delete_build_trigger( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteBuildTriggerRequest() # Establish that the response is the type that we expect. @@ -2297,7 +2172,7 @@ def test_delete_build_trigger_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2307,7 +2182,6 @@ def test_delete_build_trigger_empty_call(): client.delete_build_trigger() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteBuildTriggerRequest() @@ -2316,7 +2190,7 @@ async def test_delete_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.DeleteBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2329,13 +2203,11 @@ async def test_delete_build_trigger_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteBuildTriggerRequest() # Establish that the response is the type that we expect. @@ -2348,7 +2220,7 @@ async def test_delete_build_trigger_async_from_dict(): def test_delete_build_trigger_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2356,7 +2228,6 @@ def test_delete_build_trigger_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = None - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_build_trigger( @@ -2367,14 +2238,12 @@ def test_delete_build_trigger_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" def test_delete_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2388,7 +2257,7 @@ def test_delete_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_delete_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2408,15 +2277,13 @@ async def test_delete_build_trigger_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" @pytest.mark.asyncio async def test_delete_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2432,7 +2299,7 @@ def test_update_build_trigger( transport: str = "grpc", request_type=cloudbuild.UpdateBuildTriggerRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2452,34 +2319,26 @@ def test_update_build_trigger( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", build=cloudbuild.Build(name="name_value"), ) - response = client.update_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateBuildTriggerRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" def test_update_build_trigger_from_dict(): @@ -2490,7 +2349,7 @@ def test_update_build_trigger_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2500,7 +2359,6 @@ def test_update_build_trigger_empty_call(): client.update_build_trigger() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateBuildTriggerRequest() @@ -2509,7 +2367,7 @@ async def test_update_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.UpdateBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2530,33 +2388,26 @@ async def test_update_build_trigger_async( disabled=True, ignored_files=["ignored_files_value"], included_files=["included_files_value"], + filter="filter_value", ) ) - response = await client.update_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateBuildTriggerRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.BuildTrigger) - assert response.id == "id_value" - assert response.description == "description_value" - assert response.name == "name_value" - assert response.tags == ["tags_value"] - assert response.disabled is True - assert response.ignored_files == ["ignored_files_value"] - assert response.included_files == ["included_files_value"] + assert response.filter == "filter_value" @pytest.mark.asyncio @@ -2565,7 +2416,7 @@ async def test_update_build_trigger_async_from_dict(): def test_update_build_trigger_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2573,7 +2424,6 @@ def test_update_build_trigger_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.BuildTrigger() - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.update_build_trigger( @@ -2586,16 +2436,13 @@ def test_update_build_trigger_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" - assert args[0].trigger == cloudbuild.BuildTrigger(id="id_value") def test_update_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2610,7 +2457,7 @@ def test_update_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_update_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2634,17 +2481,14 @@ async def test_update_build_trigger_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" - assert args[0].trigger == cloudbuild.BuildTrigger(id="id_value") @pytest.mark.asyncio async def test_update_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2661,7 +2505,7 @@ def test_run_build_trigger( transport: str = "grpc", request_type=cloudbuild.RunBuildTriggerRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2674,13 +2518,11 @@ def test_run_build_trigger( ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/spam") - response = client.run_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RunBuildTriggerRequest() # Establish that the response is the type that we expect. @@ -2695,7 +2537,7 @@ def test_run_build_trigger_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2705,7 +2547,6 @@ def test_run_build_trigger_empty_call(): client.run_build_trigger() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RunBuildTriggerRequest() @@ -2714,7 +2555,7 @@ async def test_run_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.RunBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2729,13 +2570,11 @@ async def test_run_build_trigger_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( operations_pb2.Operation(name="operations/spam") ) - response = await client.run_build_trigger(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.RunBuildTriggerRequest() # Establish that the response is the type that we expect. @@ -2748,7 +2587,7 @@ async def test_run_build_trigger_async_from_dict(): def test_run_build_trigger_flattened(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2756,7 +2595,6 @@ def test_run_build_trigger_flattened(): ) as call: # Designate an appropriate return value for the call. call.return_value = operations_pb2.Operation(name="operations/op") - # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.run_build_trigger( @@ -2769,16 +2607,13 @@ def test_run_build_trigger_flattened(): # request object values. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" - assert args[0].source == cloudbuild.RepoSource(project_id="project_id_value") def test_run_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2793,7 +2628,7 @@ def test_run_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_run_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2817,17 +2652,14 @@ async def test_run_build_trigger_flattened_async(): # request object values. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0].project_id == "project_id_value" - assert args[0].trigger_id == "trigger_id_value" - assert args[0].source == cloudbuild.RepoSource(project_id="project_id_value") @pytest.mark.asyncio async def test_run_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2844,7 +2676,7 @@ def test_receive_trigger_webhook( transport: str = "grpc", request_type=cloudbuild.ReceiveTriggerWebhookRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2857,17 +2689,14 @@ def test_receive_trigger_webhook( ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.ReceiveTriggerWebhookResponse() - response = client.receive_trigger_webhook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ReceiveTriggerWebhookRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.ReceiveTriggerWebhookResponse) @@ -2879,7 +2708,7 @@ def test_receive_trigger_webhook_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2889,7 +2718,6 @@ def test_receive_trigger_webhook_empty_call(): client.receive_trigger_webhook() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ReceiveTriggerWebhookRequest() @@ -2899,7 +2727,7 @@ async def test_receive_trigger_webhook_async( request_type=cloudbuild.ReceiveTriggerWebhookRequest, ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2914,13 +2742,11 @@ async def test_receive_trigger_webhook_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( cloudbuild.ReceiveTriggerWebhookResponse() ) - response = await client.receive_trigger_webhook(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ReceiveTriggerWebhookRequest() # Establish that the response is the type that we expect. @@ -2936,7 +2762,7 @@ def test_create_worker_pool( transport: str = "grpc", request_type=cloudbuild.CreateWorkerPoolRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2956,29 +2782,20 @@ def test_create_worker_pool( regions=[cloudbuild.WorkerPool.Region.US_CENTRAL1], status=cloudbuild.WorkerPool.Status.CREATING, ) - response = client.create_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateWorkerPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -2990,7 +2807,7 @@ def test_create_worker_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3000,7 +2817,6 @@ def test_create_worker_pool_empty_call(): client.create_worker_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateWorkerPoolRequest() @@ -3009,7 +2825,7 @@ async def test_create_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3031,28 +2847,20 @@ async def test_create_worker_pool_async( status=cloudbuild.WorkerPool.Status.CREATING, ) ) - response = await client.create_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.CreateWorkerPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -3065,7 +2873,7 @@ def test_get_worker_pool( transport: str = "grpc", request_type=cloudbuild.GetWorkerPoolRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3083,29 +2891,20 @@ def test_get_worker_pool( regions=[cloudbuild.WorkerPool.Region.US_CENTRAL1], status=cloudbuild.WorkerPool.Status.CREATING, ) - response = client.get_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetWorkerPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -3117,7 +2916,7 @@ def test_get_worker_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3125,7 +2924,6 @@ def test_get_worker_pool_empty_call(): client.get_worker_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetWorkerPoolRequest() @@ -3134,7 +2932,7 @@ async def test_get_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3154,28 +2952,20 @@ async def test_get_worker_pool_async( status=cloudbuild.WorkerPool.Status.CREATING, ) ) - response = await client.get_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.GetWorkerPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -3188,7 +2978,7 @@ def test_delete_worker_pool( transport: str = "grpc", request_type=cloudbuild.DeleteWorkerPoolRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3201,13 +2991,11 @@ def test_delete_worker_pool( ) as call: # Designate an appropriate return value for the call. call.return_value = None - response = client.delete_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteWorkerPoolRequest() # Establish that the response is the type that we expect. @@ -3222,7 +3010,7 @@ def test_delete_worker_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3232,7 +3020,6 @@ def test_delete_worker_pool_empty_call(): client.delete_worker_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteWorkerPoolRequest() @@ -3241,7 +3028,7 @@ async def test_delete_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.DeleteWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3254,13 +3041,11 @@ async def test_delete_worker_pool_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) - response = await client.delete_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.DeleteWorkerPoolRequest() # Establish that the response is the type that we expect. @@ -3276,7 +3061,7 @@ def test_update_worker_pool( transport: str = "grpc", request_type=cloudbuild.UpdateWorkerPoolRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3296,29 +3081,20 @@ def test_update_worker_pool( regions=[cloudbuild.WorkerPool.Region.US_CENTRAL1], status=cloudbuild.WorkerPool.Status.CREATING, ) - response = client.update_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateWorkerPoolRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -3330,7 +3106,7 @@ def test_update_worker_pool_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3340,7 +3116,6 @@ def test_update_worker_pool_empty_call(): client.update_worker_pool() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateWorkerPoolRequest() @@ -3349,7 +3124,7 @@ async def test_update_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.UpdateWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3371,28 +3146,20 @@ async def test_update_worker_pool_async( status=cloudbuild.WorkerPool.Status.CREATING, ) ) - response = await client.update_worker_pool(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.UpdateWorkerPoolRequest() # Establish that the response is the type that we expect. assert isinstance(response, cloudbuild.WorkerPool) - assert response.name == "name_value" - assert response.project_id == "project_id_value" - assert response.service_account_email == "service_account_email_value" - assert response.worker_count == 1314 - assert response.regions == [cloudbuild.WorkerPool.Region.US_CENTRAL1] - assert response.status == cloudbuild.WorkerPool.Status.CREATING @@ -3405,7 +3172,7 @@ def test_list_worker_pools( transport: str = "grpc", request_type=cloudbuild.ListWorkerPoolsRequest ): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3418,17 +3185,14 @@ def test_list_worker_pools( ) as call: # Designate an appropriate return value for the call. call.return_value = cloudbuild.ListWorkerPoolsResponse() - response = client.list_worker_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) == 1 _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListWorkerPoolsRequest() # Establish that the response is the type that we expect. - assert isinstance(response, cloudbuild.ListWorkerPoolsResponse) @@ -3440,7 +3204,7 @@ def test_list_worker_pools_empty_call(): # This test is a coverage failsafe to make sure that totally empty calls, # i.e. request == None and no flattened fields passed, work. client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3450,7 +3214,6 @@ def test_list_worker_pools_empty_call(): client.list_worker_pools() call.assert_called() _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListWorkerPoolsRequest() @@ -3459,7 +3222,7 @@ async def test_list_worker_pools_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListWorkerPoolsRequest ): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3474,13 +3237,11 @@ async def test_list_worker_pools_async( call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( cloudbuild.ListWorkerPoolsResponse() ) - response = await client.list_worker_pools(request) # Establish that the underlying gRPC stub method was called. assert len(call.mock_calls) _, args, _ = call.mock_calls[0] - assert args[0] == cloudbuild.ListWorkerPoolsRequest() # Establish that the response is the type that we expect. @@ -3495,16 +3256,16 @@ async def test_list_worker_pools_async_from_dict(): def test_credentials_transport_error(): # It is an error to provide credentials and a transport instance. transport = transports.CloudBuildGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), transport=transport, ) # It is an error to provide a credentials file and a transport instance. transport = transports.CloudBuildGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CloudBuildClient( @@ -3514,7 +3275,7 @@ def test_credentials_transport_error(): # It is an error to provide scopes and a transport instance. transport = transports.CloudBuildGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) with pytest.raises(ValueError): client = CloudBuildClient( @@ -3525,7 +3286,7 @@ def test_credentials_transport_error(): def test_transport_instance(): # A client may be instantiated with a custom transport instance. transport = transports.CloudBuildGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) client = CloudBuildClient(transport=transport) assert client.transport is transport @@ -3534,13 +3295,13 @@ def test_transport_instance(): def test_transport_get_channel(): # A client may be instantiated with a custom transport instance. transport = transports.CloudBuildGrpcTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel transport = transports.CloudBuildGrpcAsyncIOTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) channel = transport.grpc_channel assert channel @@ -3552,23 +3313,23 @@ def test_transport_get_channel(): ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default") as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport_class() adc.assert_called_once() def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudBuildClient(credentials=credentials.AnonymousCredentials(),) + client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) assert isinstance(client.transport, transports.CloudBuildGrpcTransport,) def test_cloud_build_base_transport_error(): # Passing both a credentials object and credentials_file should raise an error - with pytest.raises(exceptions.DuplicateCredentialArgs): + with pytest.raises(core_exceptions.DuplicateCredentialArgs): transport = transports.CloudBuildTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), credentials_file="credentials.json", ) @@ -3580,7 +3341,7 @@ def test_cloud_build_base_transport(): ) as Transport: Transport.return_value = None transport = transports.CloudBuildTransport( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), ) # Every method on the transport should just blindly @@ -3614,15 +3375,37 @@ def test_cloud_build_base_transport(): transport.operations_client +@requires_google_auth_gte_1_25_0 def test_cloud_build_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file with mock.patch.object( - auth, "load_credentials_from_file" + google.auth, "load_credentials_from_file", autospec=True + ) as load_creds, mock.patch( + "google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.CloudBuildTransport._prep_wrapped_messages" + ) as Transport: + Transport.return_value = None + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) + transport = transports.CloudBuildTransport( + credentials_file="credentials.json", quota_project_id="octopus", + ) + load_creds.assert_called_once_with( + "credentials.json", + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", + ) + + +@requires_google_auth_lt_1_25_0 +def test_cloud_build_base_transport_with_credentials_file_old_google_auth(): + # Instantiate the base transport with a credentials file + with mock.patch.object( + google.auth, "load_credentials_from_file", autospec=True ) as load_creds, mock.patch( "google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.CloudBuildTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - load_creds.return_value = (credentials.AnonymousCredentials(), None) + load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudBuildTransport( credentials_file="credentials.json", quota_project_id="octopus", ) @@ -3635,19 +3418,33 @@ def test_cloud_build_base_transport_with_credentials_file(): def test_cloud_build_base_transport_with_adc(): # Test the default credentials are used if credentials and credentials_file are None. - with mock.patch.object(auth, "default") as adc, mock.patch( + with mock.patch.object(google.auth, "default", autospec=True) as adc, mock.patch( "google.cloud.devtools.cloudbuild_v1.services.cloud_build.transports.CloudBuildTransport._prep_wrapped_messages" ) as Transport: Transport.return_value = None - adc.return_value = (credentials.AnonymousCredentials(), None) + adc.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudBuildTransport() adc.assert_called_once() +@requires_google_auth_gte_1_25_0 def test_cloud_build_auth_adc(): # If no credentials are provided, we should use ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + CloudBuildClient() + adc.assert_called_once_with( + scopes=None, + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id=None, + ) + + +@requires_google_auth_lt_1_25_0 +def test_cloud_build_auth_adc_old_google_auth(): + # If no credentials are provided, we should use ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) CloudBuildClient() adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), @@ -3655,26 +3452,156 @@ def test_cloud_build_auth_adc(): ) -def test_cloud_build_transport_auth_adc(): +@pytest.mark.parametrize( + "transport_class", + [transports.CloudBuildGrpcTransport, transports.CloudBuildGrpcAsyncIOTransport,], +) +@requires_google_auth_gte_1_25_0 +def test_cloud_build_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use # ADC credentials. - with mock.patch.object(auth, "default") as adc: - adc.return_value = (credentials.AnonymousCredentials(), None) - transports.CloudBuildGrpcTransport( - host="squid.clam.whelk", quota_project_id="octopus" + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + adc.assert_called_once_with( + scopes=["1", "2"], + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + quota_project_id="octopus", ) + + +@pytest.mark.parametrize( + "transport_class", + [transports.CloudBuildGrpcTransport, transports.CloudBuildGrpcAsyncIOTransport,], +) +@requires_google_auth_lt_1_25_0 +def test_cloud_build_transport_auth_adc_old_google_auth(transport_class): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object(google.auth, "default", autospec=True) as adc: + adc.return_value = (ga_credentials.AnonymousCredentials(), None) + transport_class(quota_project_id="octopus") adc.assert_called_once_with( scopes=("https://www.googleapis.com/auth/cloud-platform",), quota_project_id="octopus", ) +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CloudBuildGrpcTransport, grpc_helpers), + (transports.CloudBuildGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_gte_1_26_0 +def test_cloud_build_transport_create_channel(transport_class, grpc_helpers): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "cloudbuild.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + default_scopes=("https://www.googleapis.com/auth/cloud-platform",), + scopes=["1", "2"], + default_host="cloudbuild.googleapis.com", + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CloudBuildGrpcTransport, grpc_helpers), + (transports.CloudBuildGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_cloud_build_transport_create_channel_old_api_core( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + transport_class(quota_project_id="octopus") + + create_channel.assert_called_with( + "cloudbuild.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=("https://www.googleapis.com/auth/cloud-platform",), + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + +@pytest.mark.parametrize( + "transport_class,grpc_helpers", + [ + (transports.CloudBuildGrpcTransport, grpc_helpers), + (transports.CloudBuildGrpcAsyncIOTransport, grpc_helpers_async), + ], +) +@requires_api_core_lt_1_26_0 +def test_cloud_build_transport_create_channel_user_scopes( + transport_class, grpc_helpers +): + # If credentials and host are not provided, the transport class should use + # ADC credentials. + with mock.patch.object( + google.auth, "default", autospec=True + ) as adc, mock.patch.object( + grpc_helpers, "create_channel", autospec=True + ) as create_channel: + creds = ga_credentials.AnonymousCredentials() + adc.return_value = (creds, None) + + transport_class(quota_project_id="octopus", scopes=["1", "2"]) + + create_channel.assert_called_with( + "cloudbuild.googleapis.com:443", + credentials=creds, + credentials_file=None, + quota_project_id="octopus", + scopes=["1", "2"], + ssl_credentials=None, + options=[ + ("grpc.max_send_message_length", -1), + ("grpc.max_receive_message_length", -1), + ], + ) + + @pytest.mark.parametrize( "transport_class", [transports.CloudBuildGrpcTransport, transports.CloudBuildGrpcAsyncIOTransport], ) def test_cloud_build_grpc_transport_client_cert_source_for_mtls(transport_class): - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() # Check ssl_channel_credentials is used if provided. with mock.patch.object(transport_class, "create_channel") as mock_create_channel: @@ -3713,7 +3640,7 @@ def test_cloud_build_grpc_transport_client_cert_source_for_mtls(transport_class) def test_cloud_build_host_no_port(): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudbuild.googleapis.com" ), @@ -3723,7 +3650,7 @@ def test_cloud_build_host_no_port(): def test_cloud_build_host_with_port(): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), + credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudbuild.googleapis.com:8000" ), @@ -3774,9 +3701,9 @@ def test_cloud_build_transport_channel_mtls_with_client_cert_source(transport_cl mock_grpc_channel = mock.Mock() grpc_create_channel.return_value = mock_grpc_channel - cred = credentials.AnonymousCredentials() + cred = ga_credentials.AnonymousCredentials() with pytest.warns(DeprecationWarning): - with mock.patch.object(auth, "default") as adc: + with mock.patch.object(google.auth, "default") as adc: adc.return_value = (cred, None) transport = transport_class( host="squid.clam.whelk", @@ -3849,7 +3776,7 @@ def test_cloud_build_transport_channel_mtls_with_adc(transport_class): def test_cloud_build_grpc_lro_client(): client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc", ) transport = client.transport @@ -3862,7 +3789,7 @@ def test_cloud_build_grpc_lro_client(): def test_cloud_build_grpc_lro_async_client(): client = CloudBuildAsyncClient( - credentials=credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", ) transport = client.transport @@ -3876,7 +3803,6 @@ def test_cloud_build_grpc_lro_async_client(): def test_build_path(): project = "squid" build = "clam" - expected = "projects/{project}/builds/{build}".format(project=project, build=build,) actual = CloudBuildClient.build_path(project, build) assert expected == actual @@ -3897,7 +3823,6 @@ def test_parse_build_path(): def test_build_trigger_path(): project = "oyster" trigger = "nudibranch" - expected = "projects/{project}/triggers/{trigger}".format( project=project, trigger=trigger, ) @@ -3922,7 +3847,6 @@ def test_crypto_key_path(): location = "nautilus" keyring = "scallop" key = "abalone" - expected = "projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}".format( project=project, location=location, keyring=keyring, key=key, ) @@ -3948,7 +3872,6 @@ def test_secret_version_path(): project = "oyster" secret = "nudibranch" version = "cuttlefish" - expected = "projects/{project}/secrets/{secret}/versions/{version}".format( project=project, secret=secret, version=version, ) @@ -3972,7 +3895,6 @@ def test_parse_secret_version_path(): def test_service_account_path(): project = "scallop" service_account = "abalone" - expected = "projects/{project}/serviceAccounts/{service_account}".format( project=project, service_account=service_account, ) @@ -3992,9 +3914,50 @@ def test_parse_service_account_path(): assert expected == actual -def test_common_billing_account_path(): - billing_account = "whelk" +def test_subscription_path(): + project = "whelk" + subscription = "octopus" + expected = "projects/{project}/subscriptions/{subscription}".format( + project=project, subscription=subscription, + ) + actual = CloudBuildClient.subscription_path(project, subscription) + assert expected == actual + + +def test_parse_subscription_path(): + expected = { + "project": "oyster", + "subscription": "nudibranch", + } + path = CloudBuildClient.subscription_path(**expected) + + # Check that the path construction is reversible. + actual = CloudBuildClient.parse_subscription_path(path) + assert expected == actual + + +def test_topic_path(): + project = "cuttlefish" + topic = "mussel" + expected = "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + actual = CloudBuildClient.topic_path(project, topic) + assert expected == actual + + +def test_parse_topic_path(): + expected = { + "project": "winkle", + "topic": "nautilus", + } + path = CloudBuildClient.topic_path(**expected) + + # Check that the path construction is reversible. + actual = CloudBuildClient.parse_topic_path(path) + assert expected == actual + +def test_common_billing_account_path(): + billing_account = "scallop" expected = "billingAccounts/{billing_account}".format( billing_account=billing_account, ) @@ -4004,7 +3967,7 @@ def test_common_billing_account_path(): def test_parse_common_billing_account_path(): expected = { - "billing_account": "octopus", + "billing_account": "abalone", } path = CloudBuildClient.common_billing_account_path(**expected) @@ -4014,8 +3977,7 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): - folder = "oyster" - + folder = "squid" expected = "folders/{folder}".format(folder=folder,) actual = CloudBuildClient.common_folder_path(folder) assert expected == actual @@ -4023,7 +3985,7 @@ def test_common_folder_path(): def test_parse_common_folder_path(): expected = { - "folder": "nudibranch", + "folder": "clam", } path = CloudBuildClient.common_folder_path(**expected) @@ -4033,8 +3995,7 @@ def test_parse_common_folder_path(): def test_common_organization_path(): - organization = "cuttlefish" - + organization = "whelk" expected = "organizations/{organization}".format(organization=organization,) actual = CloudBuildClient.common_organization_path(organization) assert expected == actual @@ -4042,7 +4003,7 @@ def test_common_organization_path(): def test_parse_common_organization_path(): expected = { - "organization": "mussel", + "organization": "octopus", } path = CloudBuildClient.common_organization_path(**expected) @@ -4052,8 +4013,7 @@ def test_parse_common_organization_path(): def test_common_project_path(): - project = "winkle" - + project = "oyster" expected = "projects/{project}".format(project=project,) actual = CloudBuildClient.common_project_path(project) assert expected == actual @@ -4061,7 +4021,7 @@ def test_common_project_path(): def test_parse_common_project_path(): expected = { - "project": "nautilus", + "project": "nudibranch", } path = CloudBuildClient.common_project_path(**expected) @@ -4071,9 +4031,8 @@ def test_parse_common_project_path(): def test_common_location_path(): - project = "scallop" - location = "abalone" - + project = "cuttlefish" + location = "mussel" expected = "projects/{project}/locations/{location}".format( project=project, location=location, ) @@ -4083,8 +4042,8 @@ def test_common_location_path(): def test_parse_common_location_path(): expected = { - "project": "squid", - "location": "clam", + "project": "winkle", + "location": "nautilus", } path = CloudBuildClient.common_location_path(**expected) @@ -4100,7 +4059,7 @@ def test_client_withDEFAULT_CLIENT_INFO(): transports.CloudBuildTransport, "_prep_wrapped_messages" ) as prep: client = CloudBuildClient( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -4109,6 +4068,6 @@ def test_client_withDEFAULT_CLIENT_INFO(): ) as prep: transport_class = CloudBuildClient.get_transport_class() transport = transport_class( - credentials=credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, ) prep.assert_called_once_with(client_info)