diff --git a/.flake8 b/.flake8 index 29227d4c..2e438749 100644 --- a/.flake8 +++ b/.flake8 @@ -16,7 +16,7 @@ # Generated by synthtool. DO NOT EDIT! [flake8] -ignore = E203, E266, E501, W503 +ignore = E203, E231, E266, E501, W503 exclude = # Exclude generated code. **/proto/** diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index 44c78f7c..b631901e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,4 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-python:latest - digest: sha256:4e1991042fe54b991db9ca17c8fb386e61b22fe4d1472a568bf0fcac85dcf5d3 + digest: sha256:f792ee1320e03eda2d13a5281a2989f7ed8a9e50b73ef6da97fac7e1e850b149 +# created: 2022-05-05T15:17:27.599381182Z diff --git a/.github/auto-label.yaml b/.github/auto-label.yaml new file mode 100644 index 00000000..41bff0b5 --- /dev/null +++ b/.github/auto-label.yaml @@ -0,0 +1,15 @@ +# Copyright 2022 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +requestsize: + enabled: true diff --git a/.github/release-please.yml b/.github/release-please.yml index 466597e5..5161ab34 100644 --- a/.github/release-please.yml +++ b/.github/release-please.yml @@ -1,2 +1,14 @@ releaseType: python handleGHRelease: true +# NOTE: this section is generated by synthtool.languages.python +# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py +branches: +- branch: v2 + handleGHRelease: true + releaseType: python +- branch: v1 + handleGHRelease: true + releaseType: python +- branch: v0 + handleGHRelease: true + releaseType: python diff --git a/.kokoro/docker/docs/Dockerfile b/.kokoro/docker/docs/Dockerfile index 4e1b1fb8..238b87b9 100644 --- a/.kokoro/docker/docs/Dockerfile +++ b/.kokoro/docker/docs/Dockerfile @@ -12,7 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -from ubuntu:20.04 +from ubuntu:22.04 ENV DEBIAN_FRONTEND noninteractive @@ -60,8 +60,24 @@ RUN apt-get update \ && rm -rf /var/lib/apt/lists/* \ && rm -f /var/cache/apt/archives/*.deb +###################### Install python 3.8.11 + +# Download python 3.8.11 +RUN wget https://www.python.org/ftp/python/3.8.11/Python-3.8.11.tgz + +# Extract files +RUN tar -xvf Python-3.8.11.tgz + +# Install python 3.8.11 +RUN ./Python-3.8.11/configure --enable-optimizations +RUN make altinstall + +###################### Install pip RUN wget -O /tmp/get-pip.py 'https://bootstrap.pypa.io/get-pip.py' \ - && python3.8 /tmp/get-pip.py \ + && python3 /tmp/get-pip.py \ && rm /tmp/get-pip.py +# Test pip +RUN python3 -m pip + CMD ["python3.8"] diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 62eb5a77..46d23716 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -22,7 +22,7 @@ repos: - id: end-of-file-fixer - id: check-yaml - repo: https://github.com/psf/black - rev: 19.10b0 + rev: 22.3.0 hooks: - id: black - repo: https://gitlab.com/pycqa/flake8 diff --git a/CHANGELOG.md b/CHANGELOG.md index 99411ebe..f441abeb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,13 @@ [1]: https://pypi.org/project/google-cloud-build/#history +### [3.8.2](https://github.com/googleapis/python-cloudbuild/compare/v3.8.1...v3.8.2) (2022-05-05) + + +### Documentation + +* fix type in docstring for map fields ([3a4be49](https://github.com/googleapis/python-cloudbuild/commit/3a4be49489628fd07a7377085d90e4ec6b06d76a)) + ### [3.8.1](https://github.com/googleapis/python-cloudbuild/compare/v3.8.0...v3.8.1) (2022-03-05) diff --git a/docs/conf.py b/docs/conf.py index 2e05bb00..1a733835 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -314,7 +314,13 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - (root_doc, "google-cloud-build", "google-cloud-build Documentation", [author], 1,) + ( + root_doc, + "google-cloud-build", + "google-cloud-build Documentation", + [author], + 1, + ) ] # If true, show URL addresses after external links. @@ -355,7 +361,10 @@ intersphinx_mapping = { "python": ("https://python.readthedocs.org/en/latest/", None), "google-auth": ("https://googleapis.dev/python/google-auth/latest/", None), - "google.api_core": ("https://googleapis.dev/python/google-api-core/latest/", None,), + "google.api_core": ( + "https://googleapis.dev/python/google-api-core/latest/", + None, + ), "grpc": ("https://grpc.github.io/grpc/python/", None), "proto-plus": ("https://proto-plus-python.readthedocs.io/en/latest/", None), "protobuf": ("https://googleapis.dev/python/protobuf/latest/", None), diff --git a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/async_client.py index b4a7d27a..603d444d 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 @@ -16,7 +16,7 @@ from collections import OrderedDict import functools import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core.client_options import ClientOptions @@ -244,14 +244,13 @@ async def create_build( the build ID. Pass the build ID to ``GetBuild`` to determine the build status (such as ``SUCCESS`` or ``FAILURE``). - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_create_build(): + async def sample_create_build(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.CreateBuildRequest( @@ -263,7 +262,7 @@ def sample_create_build(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -345,8 +344,21 @@ def sample_create_build(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -375,14 +387,13 @@ async def get_build( ``SUCCESS``, ``FAILURE``, or ``WORKING``), and timing information. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_get_build(): + async def sample_get_build(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.GetBuildRequest( @@ -391,7 +402,7 @@ def sample_get_build(): ) # Make the request - response = client.get_build(request=request) + response = await client.get_build(request=request) # Handle the response print(response) @@ -479,8 +490,24 @@ def sample_get_build(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -499,14 +526,13 @@ async def list_builds( Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_list_builds(): + async def sample_list_builds(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.ListBuildsRequest( @@ -517,7 +543,7 @@ def sample_list_builds(): page_result = client.list_builds(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -586,13 +612,29 @@ def sample_list_builds(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListBuildsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -614,9 +656,9 @@ async def cancel_build( from google.cloud.devtools import cloudbuild_v1 - def sample_cancel_build(): + async def sample_cancel_build(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.CancelBuildRequest( @@ -625,7 +667,7 @@ def sample_cancel_build(): ) # Make the request - response = client.cancel_build(request=request) + response = await client.cancel_build(request=request) # Handle the response print(response) @@ -703,8 +745,24 @@ def sample_cancel_build(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -750,14 +808,13 @@ async def retry_build( available depending on the bucket's lifecycle management settings. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_retry_build(): + async def sample_retry_build(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.RetryBuildRequest( @@ -770,7 +827,7 @@ def sample_retry_build(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -854,8 +911,24 @@ def sample_retry_build(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -884,14 +957,13 @@ async def approve_build( If rejected, the returned LRO will be immediately done. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_approve_build(): + async def sample_approve_build(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.ApproveBuildRequest( @@ -903,7 +975,7 @@ def sample_approve_build(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -995,7 +1067,12 @@ def sample_approve_build(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1022,14 +1099,13 @@ async def create_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_create_build_trigger(): + async def sample_create_build_trigger(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) trigger = cloudbuild_v1.BuildTrigger() @@ -1041,7 +1117,7 @@ def sample_create_build_trigger(): ) # Make the request - response = client.create_build_trigger(request=request) + response = await client.create_build_trigger(request=request) # Handle the response print(response) @@ -1102,8 +1178,21 @@ def sample_create_build_trigger(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1122,14 +1211,13 @@ async def get_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_get_build_trigger(): + async def sample_get_build_trigger(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.GetBuildTriggerRequest( @@ -1138,7 +1226,7 @@ def sample_get_build_trigger(): ) # Make the request - response = client.get_build_trigger(request=request) + response = await client.get_build_trigger(request=request) # Handle the response print(response) @@ -1211,8 +1299,24 @@ def sample_get_build_trigger(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1230,14 +1334,13 @@ async def list_build_triggers( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_list_build_triggers(): + async def sample_list_build_triggers(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.ListBuildTriggersRequest( @@ -1248,7 +1351,7 @@ def sample_list_build_triggers(): page_result = client.list_build_triggers(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -1311,13 +1414,29 @@ def sample_list_build_triggers(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListBuildTriggersAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1337,14 +1456,13 @@ async def delete_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_delete_build_trigger(): + async def sample_delete_build_trigger(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.DeleteBuildTriggerRequest( @@ -1353,7 +1471,7 @@ def sample_delete_build_trigger(): ) # Make the request - client.delete_build_trigger(request=request) + await client.delete_build_trigger(request=request) Args: request (Union[google.cloud.devtools.cloudbuild_v1.types.DeleteBuildTriggerRequest, dict]): @@ -1413,9 +1531,23 @@ def sample_delete_build_trigger(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. await rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) async def update_build_trigger( @@ -1433,14 +1565,13 @@ async def update_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_update_build_trigger(): + async def sample_update_build_trigger(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) trigger = cloudbuild_v1.BuildTrigger() @@ -1453,7 +1584,7 @@ def sample_update_build_trigger(): ) # Make the request - response = client.update_build_trigger(request=request) + response = await client.update_build_trigger(request=request) # Handle the response print(response) @@ -1521,8 +1652,24 @@ def sample_update_build_trigger(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1544,9 +1691,9 @@ async def run_build_trigger( from google.cloud.devtools import cloudbuild_v1 - def sample_run_build_trigger(): + async def sample_run_build_trigger(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.RunBuildTriggerRequest( @@ -1559,7 +1706,7 @@ def sample_run_build_trigger(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1649,8 +1796,24 @@ def sample_run_build_trigger(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1674,21 +1837,20 @@ async def receive_trigger_webhook( r"""ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 - def sample_receive_trigger_webhook(): + async def sample_receive_trigger_webhook(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.ReceiveTriggerWebhookRequest( ) # Make the request - response = client.receive_trigger_webhook(request=request) + response = await client.receive_trigger_webhook(request=request) # Handle the response print(response) @@ -1721,8 +1883,24 @@ def sample_receive_trigger_webhook(): client_info=DEFAULT_CLIENT_INFO, ) + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger", request.trigger), + ) + ), + ) + # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1744,9 +1922,9 @@ async def create_worker_pool( from google.cloud.devtools import cloudbuild_v1 - def sample_create_worker_pool(): + async def sample_create_worker_pool(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.CreateWorkerPoolRequest( @@ -1759,7 +1937,7 @@ def sample_create_worker_pool(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -1857,7 +2035,12 @@ def sample_create_worker_pool(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -1885,9 +2068,9 @@ async def get_worker_pool( from google.cloud.devtools import cloudbuild_v1 - def sample_get_worker_pool(): + async def sample_get_worker_pool(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.GetWorkerPoolRequest( @@ -1895,7 +2078,7 @@ def sample_get_worker_pool(): ) # Make the request - response = client.get_worker_pool(request=request) + response = await client.get_worker_pool(request=request) # Handle the response print(response) @@ -1979,7 +2162,12 @@ def sample_get_worker_pool(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1999,9 +2187,9 @@ async def delete_worker_pool( from google.cloud.devtools import cloudbuild_v1 - def sample_delete_worker_pool(): + async def sample_delete_worker_pool(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.DeleteWorkerPoolRequest( @@ -2013,7 +2201,7 @@ def sample_delete_worker_pool(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -2086,7 +2274,12 @@ def sample_delete_worker_pool(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -2115,9 +2308,9 @@ async def update_worker_pool( from google.cloud.devtools import cloudbuild_v1 - def sample_update_worker_pool(): + async def sample_update_worker_pool(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.UpdateWorkerPoolRequest( @@ -2128,7 +2321,7 @@ def sample_update_worker_pool(): print("Waiting for operation to complete...") - response = operation.result() + response = await operation.result() # Handle the response print(response) @@ -2218,7 +2411,12 @@ def sample_update_worker_pool(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation_async.from_gapic( @@ -2246,9 +2444,9 @@ async def list_worker_pools( from google.cloud.devtools import cloudbuild_v1 - def sample_list_worker_pools(): + async def sample_list_worker_pools(): # Create a client - client = cloudbuild_v1.CloudBuildClient() + client = cloudbuild_v1.CloudBuildAsyncClient() # Initialize request argument(s) request = cloudbuild_v1.ListWorkerPoolsRequest( @@ -2259,7 +2457,7 @@ def sample_list_worker_pools(): page_result = client.list_worker_pools(request=request) # Handle the response - for response in page_result: + async for response in page_result: print(response) Args: @@ -2329,12 +2527,20 @@ def sample_list_worker_pools(): ) # Send the request. - response = await rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = await rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__aiter__` convenience method. response = pagers.ListWorkerPoolsAsyncPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2349,7 +2555,9 @@ async def __aexit__(self, exc_type, exc, tb): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-build",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-build", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() 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 620496b9..94b0fc3a 100644 --- a/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py +++ b/google/cloud/devtools/cloudbuild_v1/services/cloud_build/client.py @@ -16,7 +16,7 @@ from collections import OrderedDict import os import re -from typing import Dict, Optional, Sequence, Tuple, Type, Union +from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union import pkg_resources from google.api_core import client_options as client_options_lib @@ -59,7 +59,10 @@ class CloudBuildClientMeta(type): _transport_registry["grpc"] = CloudBuildGrpcTransport _transport_registry["grpc_asyncio"] = CloudBuildGrpcAsyncIOTransport - def get_transport_class(cls, label: str = None,) -> Type[CloudBuildTransport]: + def get_transport_class( + cls, + label: str = None, + ) -> Type[CloudBuildTransport]: """Returns an appropriate transport class. Args: @@ -172,9 +175,15 @@ def transport(self) -> CloudBuildTransport: return self._transport @staticmethod - def build_path(project: str, build: str,) -> str: + def build_path( + project: str, + build: str, + ) -> str: """Returns a fully-qualified build string.""" - return "projects/{project}/builds/{build}".format(project=project, build=build,) + return "projects/{project}/builds/{build}".format( + project=project, + build=build, + ) @staticmethod def parse_build_path(path: str) -> Dict[str, str]: @@ -183,10 +192,14 @@ def parse_build_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def build_trigger_path(project: str, trigger: str,) -> str: + def build_trigger_path( + project: str, + trigger: str, + ) -> str: """Returns a fully-qualified build_trigger string.""" return "projects/{project}/triggers/{trigger}".format( - project=project, trigger=trigger, + project=project, + trigger=trigger, ) @staticmethod @@ -196,10 +209,18 @@ def parse_build_trigger_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def crypto_key_path(project: str, location: str, keyring: str, key: str,) -> str: + def crypto_key_path( + project: str, + location: str, + keyring: str, + key: str, + ) -> str: """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, + project=project, + location=location, + keyring=keyring, + key=key, ) @staticmethod @@ -212,10 +233,14 @@ def parse_crypto_key_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def network_path(project: str, network: str,) -> str: + def network_path( + project: str, + network: str, + ) -> str: """Returns a fully-qualified network string.""" return "projects/{project}/global/networks/{network}".format( - project=project, network=network, + project=project, + network=network, ) @staticmethod @@ -227,10 +252,16 @@ def parse_network_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def secret_version_path(project: str, secret: str, version: str,) -> str: + def secret_version_path( + project: str, + secret: str, + version: str, + ) -> str: """Returns a fully-qualified secret_version string.""" return "projects/{project}/secrets/{secret}/versions/{version}".format( - project=project, secret=secret, version=version, + project=project, + secret=secret, + version=version, ) @staticmethod @@ -243,10 +274,14 @@ def parse_secret_version_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def service_account_path(project: str, service_account: str,) -> str: + def service_account_path( + project: str, + service_account: str, + ) -> str: """Returns a fully-qualified service_account string.""" return "projects/{project}/serviceAccounts/{service_account}".format( - project=project, service_account=service_account, + project=project, + service_account=service_account, ) @staticmethod @@ -259,10 +294,14 @@ def parse_service_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def subscription_path(project: str, subscription: str,) -> str: + def subscription_path( + project: str, + subscription: str, + ) -> str: """Returns a fully-qualified subscription string.""" return "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) @staticmethod @@ -274,9 +313,15 @@ def parse_subscription_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def topic_path(project: str, topic: str,) -> str: + def topic_path( + project: str, + topic: str, + ) -> str: """Returns a fully-qualified topic string.""" - return "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + return "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) @staticmethod def parse_topic_path(path: str) -> Dict[str, str]: @@ -285,10 +330,18 @@ def parse_topic_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def worker_pool_path(project: str, location: str, worker_pool: str,) -> str: + def worker_pool_path( + project: str, + location: str, + worker_pool: str, + ) -> str: """Returns a fully-qualified worker_pool string.""" - return "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( - project=project, location=location, worker_pool=worker_pool, + return ( + "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( + project=project, + location=location, + worker_pool=worker_pool, + ) ) @staticmethod @@ -301,7 +354,9 @@ def parse_worker_pool_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_billing_account_path(billing_account: str,) -> str: + def common_billing_account_path( + billing_account: str, + ) -> str: """Returns a fully-qualified billing_account string.""" return "billingAccounts/{billing_account}".format( billing_account=billing_account, @@ -314,9 +369,13 @@ def parse_common_billing_account_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_folder_path(folder: str,) -> str: + def common_folder_path( + folder: str, + ) -> str: """Returns a fully-qualified folder string.""" - return "folders/{folder}".format(folder=folder,) + return "folders/{folder}".format( + folder=folder, + ) @staticmethod def parse_common_folder_path(path: str) -> Dict[str, str]: @@ -325,9 +384,13 @@ def parse_common_folder_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_organization_path(organization: str,) -> str: + def common_organization_path( + organization: str, + ) -> str: """Returns a fully-qualified organization string.""" - return "organizations/{organization}".format(organization=organization,) + return "organizations/{organization}".format( + organization=organization, + ) @staticmethod def parse_common_organization_path(path: str) -> Dict[str, str]: @@ -336,9 +399,13 @@ def parse_common_organization_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_project_path(project: str,) -> str: + def common_project_path( + project: str, + ) -> str: """Returns a fully-qualified project string.""" - return "projects/{project}".format(project=project,) + return "projects/{project}".format( + project=project, + ) @staticmethod def parse_common_project_path(path: str) -> Dict[str, str]: @@ -347,10 +414,14 @@ def parse_common_project_path(path: str) -> Dict[str, str]: return m.groupdict() if m else {} @staticmethod - def common_location_path(project: str, location: str,) -> str: + def common_location_path( + project: str, + location: str, + ) -> str: """Returns a fully-qualified location string.""" return "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) @staticmethod @@ -540,7 +611,6 @@ def create_build( the build ID. Pass the build ID to ``GetBuild`` to determine the build status (such as ``SUCCESS`` or ``FAILURE``). - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -641,8 +711,21 @@ def sample_create_build(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_build] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -671,7 +754,6 @@ def get_build( ``SUCCESS``, ``FAILURE``, or ``WORKING``), and timing information. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -765,8 +847,24 @@ def sample_get_build(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_build] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -785,7 +883,6 @@ def list_builds( Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -862,13 +959,29 @@ def sample_list_builds(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_builds] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListBuildsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -979,8 +1092,24 @@ def sample_cancel_build(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.cancel_build] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1026,7 +1155,6 @@ def retry_build( available depending on the bucket's lifecycle management settings. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1130,8 +1258,24 @@ def sample_retry_build(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.retry_build] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("id", request.id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1160,7 +1304,6 @@ def approve_build( If rejected, the returned LRO will be immediately done. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1271,7 +1414,12 @@ def sample_approve_build(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1298,7 +1446,6 @@ def create_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1378,8 +1525,21 @@ def sample_create_build_trigger(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.create_build_trigger] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1398,7 +1558,6 @@ def get_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1477,8 +1636,24 @@ def sample_get_build_trigger(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.get_build_trigger] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1496,7 +1671,6 @@ def list_build_triggers( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1567,13 +1741,29 @@ def sample_list_build_triggers(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.list_build_triggers] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + (("project_id", request.project_id),) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListBuildTriggersPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -1593,7 +1783,6 @@ def delete_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1659,9 +1848,23 @@ def sample_delete_build_trigger(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.delete_build_trigger] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. rpc( - request, retry=retry, timeout=timeout, metadata=metadata, + request, + retry=retry, + timeout=timeout, + metadata=metadata, ) def update_build_trigger( @@ -1679,7 +1882,6 @@ def update_build_trigger( This API is experimental. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1767,8 +1969,24 @@ def sample_update_build_trigger(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.update_build_trigger] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -1895,8 +2113,24 @@ def sample_run_build_trigger(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.run_build_trigger] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger_id", request.trigger_id), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -1920,7 +2154,6 @@ def receive_trigger_webhook( r"""ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger. - .. code-block:: python from google.cloud.devtools import cloudbuild_v1 @@ -1968,8 +2201,24 @@ def sample_receive_trigger_webhook(): # and friendly error handling. rpc = self._transport._wrapped_methods[self._transport.receive_trigger_webhook] + # Certain fields should be provided within the metadata header; + # add these here. + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata( + ( + ("project_id", request.project_id), + ("trigger", request.trigger), + ) + ), + ) + # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2104,7 +2353,12 @@ def sample_create_worker_pool(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -2216,7 +2470,12 @@ def sample_get_worker_pool(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Done; return the response. return response @@ -2323,7 +2582,12 @@ def sample_delete_worker_pool(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -2455,7 +2719,12 @@ def sample_update_worker_pool(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # Wrap the response in an operation future. response = operation.from_gapic( @@ -2556,12 +2825,20 @@ def sample_list_worker_pools(): ) # Send the request. - response = rpc(request, retry=retry, timeout=timeout, metadata=metadata,) + response = rpc( + request, + retry=retry, + timeout=timeout, + metadata=metadata, + ) # This method is paged; wrap the response in a pager, which provides # an `__iter__` convenience method. response = pagers.ListWorkerPoolsPager( - method=rpc, request=request, response=response, metadata=metadata, + method=rpc, + request=request, + response=response, + metadata=metadata, ) # Done; return the response. @@ -2583,7 +2860,9 @@ def __exit__(self, type, value, traceback): try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-build",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-build", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() 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 08c66b5d..855dabbd 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 @@ -32,7 +32,9 @@ try: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo( - gapic_version=pkg_resources.get_distribution("google-cloud-build",).version, + gapic_version=pkg_resources.get_distribution( + "google-cloud-build", + ).version, ) except pkg_resources.DistributionNotFound: DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo() @@ -81,6 +83,7 @@ def __init__( always_use_jwt_access (Optional[bool]): Whether self signed JWT should be used for service account credentials. """ + # Save the hostname. Default to port 443 (HTTPS) if none is specified. if ":" not in host: host += ":443" @@ -122,7 +125,9 @@ def _prep_wrapped_messages(self, client_info): # Precompute the wrapped methods. self._wrapped_methods = { self.create_build: gapic_v1.method.wrap_method( - self.create_build, default_timeout=600.0, client_info=client_info, + self.create_build, + default_timeout=600.0, + client_info=client_info, ), self.get_build: gapic_v1.method.wrap_method( self.get_build, @@ -155,13 +160,19 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.cancel_build: gapic_v1.method.wrap_method( - self.cancel_build, default_timeout=600.0, client_info=client_info, + self.cancel_build, + default_timeout=600.0, + client_info=client_info, ), self.retry_build: gapic_v1.method.wrap_method( - self.retry_build, default_timeout=600.0, client_info=client_info, + self.retry_build, + default_timeout=600.0, + client_info=client_info, ), self.approve_build: gapic_v1.method.wrap_method( - self.approve_build, default_timeout=None, client_info=client_info, + self.approve_build, + default_timeout=None, + client_info=client_info, ), self.create_build_trigger: gapic_v1.method.wrap_method( self.create_build_trigger, @@ -219,7 +230,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.run_build_trigger: gapic_v1.method.wrap_method( - self.run_build_trigger, default_timeout=600.0, client_info=client_info, + self.run_build_trigger, + default_timeout=600.0, + client_info=client_info, ), self.receive_trigger_webhook: gapic_v1.method.wrap_method( self.receive_trigger_webhook, @@ -227,7 +240,9 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.create_worker_pool: gapic_v1.method.wrap_method( - self.create_worker_pool, default_timeout=600.0, client_info=client_info, + self.create_worker_pool, + default_timeout=600.0, + client_info=client_info, ), self.get_worker_pool: gapic_v1.method.wrap_method( self.get_worker_pool, @@ -245,10 +260,14 @@ def _prep_wrapped_messages(self, client_info): client_info=client_info, ), self.delete_worker_pool: gapic_v1.method.wrap_method( - self.delete_worker_pool, default_timeout=600.0, client_info=client_info, + self.delete_worker_pool, + default_timeout=600.0, + client_info=client_info, ), self.update_worker_pool: gapic_v1.method.wrap_method( - self.update_worker_pool, default_timeout=600.0, client_info=client_info, + self.update_worker_pool, + default_timeout=600.0, + client_info=client_info, ), self.list_worker_pools: gapic_v1.method.wrap_method( self.list_worker_pools, @@ -270,9 +289,9 @@ def _prep_wrapped_messages(self, client_info): def close(self): """Closes resources associated with the transport. - .. warning:: - Only call this method if the transport is NOT shared - with other clients - this may cause errors in other clients! + .. warning:: + Only call this method if the transport is NOT shared + with other clients - this may cause errors in other clients! """ raise NotImplementedError() @@ -452,5 +471,9 @@ def list_worker_pools( ]: raise NotImplementedError() + @property + def kind(self) -> str: + raise NotImplementedError() + __all__ = ("CloudBuildTransport",) 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 beaa74bf..55564d45 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 @@ -235,8 +235,7 @@ def create_channel( @property def grpc_channel(self) -> grpc.Channel: - """Return the channel designed to connect to this service. - """ + """Return the channel designed to connect to this service.""" return self._grpc_channel @property @@ -783,5 +782,9 @@ def list_worker_pools( def close(self): self.grpc_channel.close() + @property + def kind(self) -> str: + return "grpc" + __all__ = ("CloudBuildGrpcTransport",) diff --git a/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py b/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py index 08ca9dc6..bb02940f 100644 --- a/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py +++ b/google/cloud/devtools/cloudbuild_v1/types/cloudbuild.py @@ -98,9 +98,18 @@ 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): @@ -118,10 +127,23 @@ class RunBuildTriggerRequest(proto.Message): Source to build against this trigger. """ - name = proto.Field(proto.STRING, number=4,) - 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",) + name = proto.Field( + proto.STRING, + number=4, + ) + 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", + ) class StorageSource(proto.Message): @@ -144,9 +166,18 @@ 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): @@ -194,19 +225,47 @@ class RepoSource(proto.Message): invert_regex (bool): Only trigger a build if the revision regex does NOT match the revision regex. - substitutions (Sequence[google.cloud.devtools.cloudbuild_v1.types.RepoSource.SubstitutionsEntry]): + substitutions (Mapping[str, str]): Substitutions to use in a triggered build. Should only be used with RunBuildTrigger """ - 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,) + 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, + ) class StorageSourceManifest(proto.Message): @@ -229,9 +288,18 @@ class StorageSourceManifest(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 Source(proto.Message): @@ -264,13 +332,22 @@ class Source(proto.Message): """ storage_source = proto.Field( - proto.MESSAGE, number=2, oneof="source", message="StorageSource", + proto.MESSAGE, + number=2, + oneof="source", + message="StorageSource", ) repo_source = proto.Field( - proto.MESSAGE, number=3, oneof="source", message="RepoSource", + proto.MESSAGE, + number=3, + oneof="source", + message="RepoSource", ) storage_source_manifest = proto.Field( - proto.MESSAGE, number=8, oneof="source", message="StorageSourceManifest", + proto.MESSAGE, + number=8, + oneof="source", + message="StorageSourceManifest", ) @@ -288,9 +365,19 @@ class BuiltImage(proto.Message): pushing the specified image. """ - name = proto.Field(proto.STRING, number=1,) - digest = proto.Field(proto.STRING, number=3,) - push_timing = proto.Field(proto.MESSAGE, number=4, message="TimeSpan",) + 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): @@ -393,20 +480,67 @@ class BuildStep(proto.Message): the entrypoint or args. """ - 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_pb2.Duration,) - status = proto.Field(proto.ENUM, number=12, enum="Build.Status",) - script = proto.Field(proto.STRING, number=19,) + 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_pb2.Duration, + ) + status = proto.Field( + proto.ENUM, + number=12, + enum="Build.Status", + ) + script = proto.Field( + proto.STRING, + number=19, + ) class Volume(proto.Message): @@ -428,8 +562,14 @@ 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): @@ -461,12 +601,32 @@ class Results(proto.Message): Time to push all non-container artifacts. """ - 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,) - artifact_timing = proto.Field(proto.MESSAGE, number=7, message="TimeSpan",) + 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, + ) + artifact_timing = proto.Field( + proto.MESSAGE, + number=7, + message="TimeSpan", + ) class ArtifactResult(proto.Message): @@ -482,8 +642,15 @@ class ArtifactResult(proto.Message): The file hash of the artifact. """ - location = proto.Field(proto.STRING, number=1,) - file_hash = proto.RepeatedField(proto.MESSAGE, number=2, message="FileHashes",) + location = proto.Field( + proto.STRING, + number=1, + ) + file_hash = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="FileHashes", + ) class Build(proto.Message): @@ -588,7 +755,7 @@ class Build(proto.Message): log_url (str): Output only. URL to logs for this build in Google Cloud Console. - substitutions (Sequence[google.cloud.devtools.cloudbuild_v1.types.Build.SubstitutionsEntry]): + substitutions (Mapping[str, str]): Substitutions data for ``Build`` resource. tags (Sequence[str]): Tags for annotation of a ``Build``. These are not docker @@ -600,7 +767,7 @@ class Build(proto.Message): to configure builds to access secrets from Secret Manager. For instructions, see: https://cloud.google.com/cloud-build/docs/securing-builds/use-secrets - timing (Sequence[google.cloud.devtools.cloudbuild_v1.types.Build.TimingEntry]): + timing (Mapping[str, google.cloud.devtools.cloudbuild_v1.types.TimeSpan]): Output only. Stores timing information for phases of the build. Valid keys are: @@ -660,8 +827,15 @@ class Priority(proto.Enum): WARNING = 2 ALERT = 3 - text = proto.Field(proto.STRING, number=1,) - priority = proto.Field(proto.ENUM, number=2, enum="Build.Warning.Priority",) + text = proto.Field( + proto.STRING, + number=1, + ) + priority = proto.Field( + proto.ENUM, + number=2, + enum="Build.Warning.Priority", + ) class FailureInfo(proto.Message): r"""A fatal problem encountered during the execution of the @@ -687,40 +861,152 @@ class FailureType(proto.Enum): USER_BUILD_STEP = 5 FETCH_SOURCE_FAILED = 6 - type_ = proto.Field(proto.ENUM, number=1, enum="Build.FailureInfo.FailureType",) - detail = proto.Field(proto.STRING, number=2,) - - 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,) - 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_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,) + type_ = proto.Field( + proto.ENUM, + number=1, + enum="Build.FailureInfo.FailureType", + ) + detail = proto.Field( + proto.STRING, + number=2, + ) + + 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, + ) + 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_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, + ) source_provenance = proto.Field( - proto.MESSAGE, number=21, message="SourceProvenance", - ) - 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,) - secrets = proto.RepeatedField(proto.MESSAGE, number=32, message="Secret",) - timing = proto.MapField(proto.STRING, proto.MESSAGE, number=33, message="TimeSpan",) - approval = proto.Field(proto.MESSAGE, number=44, message="BuildApproval",) - service_account = proto.Field(proto.STRING, number=42,) - available_secrets = proto.Field(proto.MESSAGE, number=47, message="Secrets",) - warnings = proto.RepeatedField(proto.MESSAGE, number=49, message=Warning,) - failure_info = proto.Field(proto.MESSAGE, number=51, message=FailureInfo,) + proto.MESSAGE, + number=21, + message="SourceProvenance", + ) + 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, + ) + secrets = proto.RepeatedField( + proto.MESSAGE, + number=32, + message="Secret", + ) + timing = proto.MapField( + proto.STRING, + proto.MESSAGE, + number=33, + message="TimeSpan", + ) + approval = proto.Field( + proto.MESSAGE, + number=44, + message="BuildApproval", + ) + service_account = proto.Field( + proto.STRING, + number=42, + ) + available_secrets = proto.Field( + proto.MESSAGE, + number=47, + message="Secrets", + ) + warnings = proto.RepeatedField( + proto.MESSAGE, + number=49, + message=Warning, + ) + failure_info = proto.Field( + proto.MESSAGE, + number=51, + message=FailureInfo, + ) class Artifacts(proto.Message): @@ -776,12 +1062,29 @@ class ArtifactObjects(proto.Message): pushing all artifact objects. """ - location = proto.Field(proto.STRING, number=1,) - paths = proto.RepeatedField(proto.STRING, number=2,) - timing = proto.Field(proto.MESSAGE, number=3, message="TimeSpan",) + 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,) - objects = proto.Field(proto.MESSAGE, number=2, message=ArtifactObjects,) + images = proto.RepeatedField( + proto.STRING, + number=1, + ) + objects = proto.Field( + proto.MESSAGE, + number=2, + message=ArtifactObjects, + ) class TimeSpan(proto.Message): @@ -794,8 +1097,16 @@ class TimeSpan(proto.Message): End of time span. """ - start_time = proto.Field(proto.MESSAGE, number=1, message=timestamp_pb2.Timestamp,) - end_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.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): @@ -806,7 +1117,11 @@ class BuildOperationMetadata(proto.Message): The build that the operation is tracking. """ - build = proto.Field(proto.MESSAGE, number=1, message="Build",) + build = proto.Field( + proto.MESSAGE, + number=1, + message="Build", + ) class SourceProvenance(proto.Message): @@ -824,7 +1139,7 @@ class SourceProvenance(proto.Message): 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]): + file_hashes (Mapping[str, google.cloud.devtools.cloudbuild_v1.types.FileHashes]): Output only. Hash(es) of the build source, which can be used to verify that the original source integrity was maintained in the build. Note that ``FileHashes`` will only be @@ -840,14 +1155,25 @@ class SourceProvenance(proto.Message): """ resolved_storage_source = proto.Field( - proto.MESSAGE, number=3, message="StorageSource", + proto.MESSAGE, + number=3, + message="StorageSource", + ) + resolved_repo_source = proto.Field( + proto.MESSAGE, + number=6, + message="RepoSource", ) - resolved_repo_source = proto.Field(proto.MESSAGE, number=6, message="RepoSource",) resolved_storage_source_manifest = proto.Field( - proto.MESSAGE, number=9, message="StorageSourceManifest", + proto.MESSAGE, + number=9, + message="StorageSourceManifest", ) file_hashes = proto.MapField( - proto.STRING, proto.MESSAGE, number=4, message="FileHashes", + proto.STRING, + proto.MESSAGE, + number=4, + message="FileHashes", ) @@ -861,7 +1187,11 @@ class FileHashes(proto.Message): Collection of file hashes. """ - file_hash = proto.RepeatedField(proto.MESSAGE, number=1, message="Hash",) + file_hash = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Hash", + ) class Hash(proto.Message): @@ -880,8 +1210,15 @@ class HashType(proto.Enum): SHA256 = 1 MD5 = 2 - type_ = proto.Field(proto.ENUM, number=1, enum=HashType,) - value = proto.Field(proto.BYTES, number=2,) + type_ = proto.Field( + proto.ENUM, + number=1, + enum=HashType, + ) + value = proto.Field( + proto.BYTES, + number=2, + ) class Secrets(proto.Message): @@ -897,9 +1234,15 @@ class Secrets(proto.Message): """ secret_manager = proto.RepeatedField( - proto.MESSAGE, number=1, message="SecretManagerSecret", + proto.MESSAGE, + number=1, + message="SecretManagerSecret", + ) + inline = proto.RepeatedField( + proto.MESSAGE, + number=2, + message="InlineSecret", ) - inline = proto.RepeatedField(proto.MESSAGE, number=2, message="InlineSecret",) class InlineSecret(proto.Message): @@ -912,7 +1255,7 @@ class InlineSecret(proto.Message): Resource name of Cloud KMS crypto key to decrypt the encrypted value. In format: projects/\ */locations/*/keyRings/*/cryptoKeys/* - env_map (Sequence[google.cloud.devtools.cloudbuild_v1.types.InlineSecret.EnvMapEntry]): + env_map (Mapping[str, bytes]): Map of environment variable name to its encrypted value. Secret environment variables must be unique @@ -922,8 +1265,15 @@ 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): @@ -941,8 +1291,14 @@ 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): @@ -956,7 +1312,7 @@ class Secret(proto.Message): kms_key_name (str): Cloud KMS key name to use to decrypt these envs. - secret_env (Sequence[google.cloud.devtools.cloudbuild_v1.types.Secret.SecretEnvEntry]): + secret_env (Mapping[str, bytes]): Map of environment variable name to its encrypted value. Secret environment variables must be unique @@ -966,8 +1322,15 @@ 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): @@ -983,9 +1346,19 @@ class CreateBuildRequest(proto.Message): Required. Build resource to create. """ - parent = proto.Field(proto.STRING, number=4,) - project_id = proto.Field(proto.STRING, number=1,) - build = proto.Field(proto.MESSAGE, number=2, message="Build",) + 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): @@ -1001,9 +1374,18 @@ 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): @@ -1032,11 +1414,26 @@ 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): @@ -1055,8 +1452,15 @@ class ListBuildsResponse(proto.Message): def raw_page(self): return self - builds = proto.RepeatedField(proto.MESSAGE, number=1, message="Build",) - next_page_token = proto.Field(proto.STRING, number=2,) + builds = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="Build", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class CancelBuildRequest(proto.Message): @@ -1072,9 +1476,18 @@ 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 ApproveBuildRequest(proto.Message): @@ -1088,8 +1501,15 @@ class ApproveBuildRequest(proto.Message): Approval decision and metadata. """ - name = proto.Field(proto.STRING, number=1,) - approval_result = proto.Field(proto.MESSAGE, number=2, message="ApprovalResult",) + name = proto.Field( + proto.STRING, + number=1, + ) + approval_result = proto.Field( + proto.MESSAGE, + number=2, + message="ApprovalResult", + ) class BuildApproval(proto.Message): @@ -1116,9 +1536,21 @@ class State(proto.Enum): REJECTED = 3 CANCELLED = 5 - state = proto.Field(proto.ENUM, number=1, enum=State,) - config = proto.Field(proto.MESSAGE, number=2, message="ApprovalConfig",) - result = proto.Field(proto.MESSAGE, number=3, message="ApprovalResult",) + state = proto.Field( + proto.ENUM, + number=1, + enum=State, + ) + config = proto.Field( + proto.MESSAGE, + number=2, + message="ApprovalConfig", + ) + result = proto.Field( + proto.MESSAGE, + number=3, + message="ApprovalResult", + ) class ApprovalConfig(proto.Message): @@ -1133,7 +1565,10 @@ class ApprovalConfig(proto.Message): to start. """ - approval_required = proto.Field(proto.BOOL, number=1,) + approval_required = proto.Field( + proto.BOOL, + number=1, + ) class ApprovalResult(proto.Message): @@ -1171,13 +1606,28 @@ class Decision(proto.Enum): APPROVED = 1 REJECTED = 2 - approver_account = proto.Field(proto.STRING, number=2,) + approver_account = proto.Field( + proto.STRING, + number=2, + ) approval_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, + ) + decision = proto.Field( + proto.ENUM, + number=4, + enum=Decision, + ) + comment = proto.Field( + proto.STRING, + number=5, + ) + url = proto.Field( + proto.STRING, + number=6, ) - decision = proto.Field(proto.ENUM, number=4, enum=Decision,) - comment = proto.Field(proto.STRING, number=5,) - url = proto.Field(proto.STRING, number=6,) class BuildTrigger(proto.Message): @@ -1261,7 +1711,7 @@ class BuildTrigger(proto.Message): disabled (bool): If true, the trigger will never automatically execute a build. - substitutions (Sequence[google.cloud.devtools.cloudbuild_v1.types.BuildTrigger.SubstitutionsEntry]): + substitutions (Mapping[str, str]): Substitutions for Build resource. The keys must match the following regular expression: ``^_[A-Z0-9_]+$``. ignored_files (Sequence[str]): @@ -1299,27 +1749,92 @@ class BuildTrigger(proto.Message): ``projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT_ID_OR_EMAIL}`` """ - resource_name = proto.Field(proto.STRING, number=34,) - 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",) - webhook_config = proto.Field(proto.MESSAGE, number=31, message="WebhookConfig",) - autodetect = proto.Field(proto.BOOL, number=18, oneof="build_template",) + resource_name = proto.Field( + proto.STRING, + number=34, + ) + 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", + ) + webhook_config = proto.Field( + proto.MESSAGE, + number=31, + message="WebhookConfig", + ) + autodetect = proto.Field( + proto.BOOL, + number=18, + oneof="build_template", + ) build = proto.Field( - proto.MESSAGE, number=4, oneof="build_template", message="Build", + 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_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, + ) + service_account = proto.Field( + proto.STRING, + number=33, ) - 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,) - service_account = proto.Field(proto.STRING, number=33,) class GitHubEventsConfig(proto.Message): @@ -1359,13 +1874,30 @@ class GitHubEventsConfig(proto.Message): This field is a member of `oneof`_ ``event``. """ - 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", + proto.MESSAGE, + number=4, + oneof="event", + message="PullRequestFilter", + ) + push = proto.Field( + proto.MESSAGE, + number=5, + oneof="event", + message="PushFilter", ) - push = proto.Field(proto.MESSAGE, number=5, oneof="event", message="PushFilter",) class PubsubConfig(proto.Message): @@ -1399,10 +1931,23 @@ class State(proto.Enum): 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,) + 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 WebhookConfig(proto.Message): @@ -1433,8 +1978,16 @@ class State(proto.Enum): OK = 1 SECRET_DELETED = 2 - secret = proto.Field(proto.STRING, number=3, oneof="auth_method",) - state = proto.Field(proto.ENUM, number=4, enum=State,) + secret = proto.Field( + proto.STRING, + number=3, + oneof="auth_method", + ) + state = proto.Field( + proto.ENUM, + number=4, + enum=State, + ) class PullRequestFilter(proto.Message): @@ -1466,9 +2019,20 @@ class CommentControl(proto.Enum): COMMENTS_ENABLED = 1 COMMENTS_ENABLED_FOR_EXTERNAL_CONTRIBUTORS_ONLY = 2 - 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,) + 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, + ) class PushFilter(proto.Message): @@ -1502,9 +2066,20 @@ 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): @@ -1521,9 +2096,19 @@ class CreateBuildTriggerRequest(proto.Message): Required. ``BuildTrigger`` to create. """ - parent = proto.Field(proto.STRING, number=3,) - project_id = proto.Field(proto.STRING, number=1,) - trigger = proto.Field(proto.MESSAGE, number=2, message="BuildTrigger",) + parent = proto.Field( + proto.STRING, + number=3, + ) + project_id = proto.Field( + proto.STRING, + number=1, + ) + trigger = proto.Field( + proto.MESSAGE, + number=2, + message="BuildTrigger", + ) class GetBuildTriggerRequest(proto.Message): @@ -1541,9 +2126,18 @@ class GetBuildTriggerRequest(proto.Message): ``BuildTrigger`` to get. """ - name = proto.Field(proto.STRING, number=3,) - project_id = proto.Field(proto.STRING, number=1,) - trigger_id = proto.Field(proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=3, + ) + project_id = proto.Field( + proto.STRING, + number=1, + ) + trigger_id = proto.Field( + proto.STRING, + number=2, + ) class ListBuildTriggersRequest(proto.Message): @@ -1563,10 +2157,22 @@ class ListBuildTriggersRequest(proto.Message): in the list. """ - parent = proto.Field(proto.STRING, number=4,) - project_id = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=4, + ) + 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): @@ -1584,8 +2190,15 @@ class ListBuildTriggersResponse(proto.Message): def raw_page(self): return self - triggers = proto.RepeatedField(proto.MESSAGE, number=1, message="BuildTrigger",) - next_page_token = proto.Field(proto.STRING, number=2,) + triggers = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="BuildTrigger", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class DeleteBuildTriggerRequest(proto.Message): @@ -1602,9 +2215,18 @@ class DeleteBuildTriggerRequest(proto.Message): Required. ID of the ``BuildTrigger`` to delete. """ - name = proto.Field(proto.STRING, number=3,) - project_id = proto.Field(proto.STRING, number=1,) - trigger_id = proto.Field(proto.STRING, number=2,) + name = proto.Field( + proto.STRING, + number=3, + ) + project_id = proto.Field( + proto.STRING, + number=1, + ) + trigger_id = proto.Field( + proto.STRING, + number=2, + ) class UpdateBuildTriggerRequest(proto.Message): @@ -1620,9 +2242,19 @@ class UpdateBuildTriggerRequest(proto.Message): Required. ``BuildTrigger`` to update. """ - 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",) + 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): @@ -1760,23 +2392,71 @@ class PoolOption(proto.Message): projects/{project}/locations/{location}/workerPools/{workerPoolId} """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) 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,) - substitution_option = proto.Field(proto.ENUM, number=4, enum=SubstitutionOption,) - 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,) - pool = proto.Field(proto.MESSAGE, number=19, message=PoolOption,) - logging = proto.Field(proto.ENUM, number=11, enum=LoggingMode,) - env = proto.RepeatedField(proto.STRING, number=12,) - secret_env = proto.RepeatedField(proto.STRING, number=13,) - volumes = proto.RepeatedField(proto.MESSAGE, number=14, message="Volume",) + 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, + ) + substitution_option = proto.Field( + proto.ENUM, + number=4, + enum=SubstitutionOption, + ) + 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, + ) + pool = proto.Field( + proto.MESSAGE, + number=19, + message=PoolOption, + ) + logging = proto.Field( + proto.ENUM, + number=11, + enum=LoggingMode, + ) + env = proto.RepeatedField( + proto.STRING, + number=12, + ) + secret_env = proto.RepeatedField( + proto.STRING, + number=13, + ) + volumes = proto.RepeatedField( + proto.MESSAGE, + number=14, + message="Volume", + ) class ReceiveTriggerWebhookRequest(proto.Message): @@ -1800,11 +2480,27 @@ class ReceiveTriggerWebhookRequest(proto.Message): OAuth token isn't provided. """ - name = proto.Field(proto.STRING, number=5,) - 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,) + name = proto.Field( + proto.STRING, + number=5, + ) + 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): @@ -1847,7 +2543,7 @@ class WorkerPool(proto.Message): characters. uid (str): Output only. A unique identifier for the ``WorkerPool``. - annotations (Sequence[google.cloud.devtools.cloudbuild_v1.types.WorkerPool.AnnotationsEntry]): + annotations (Mapping[str, str]): User specified annotations. See https://google.aip.dev/128#annotations for more details such as format and size limitations. @@ -1881,18 +2577,53 @@ class State(proto.Enum): DELETING = 3 DELETED = 4 - name = proto.Field(proto.STRING, number=1,) - display_name = proto.Field(proto.STRING, number=2,) - uid = proto.Field(proto.STRING, number=3,) - annotations = proto.MapField(proto.STRING, proto.STRING, number=4,) - create_time = proto.Field(proto.MESSAGE, number=5, message=timestamp_pb2.Timestamp,) - update_time = proto.Field(proto.MESSAGE, number=6, message=timestamp_pb2.Timestamp,) - delete_time = proto.Field(proto.MESSAGE, number=7, message=timestamp_pb2.Timestamp,) - state = proto.Field(proto.ENUM, number=8, enum=State,) + name = proto.Field( + proto.STRING, + number=1, + ) + display_name = proto.Field( + proto.STRING, + number=2, + ) + uid = proto.Field( + proto.STRING, + number=3, + ) + annotations = proto.MapField( + proto.STRING, + proto.STRING, + number=4, + ) + create_time = proto.Field( + proto.MESSAGE, + number=5, + message=timestamp_pb2.Timestamp, + ) + update_time = proto.Field( + proto.MESSAGE, + number=6, + message=timestamp_pb2.Timestamp, + ) + delete_time = proto.Field( + proto.MESSAGE, + number=7, + message=timestamp_pb2.Timestamp, + ) + state = proto.Field( + proto.ENUM, + number=8, + enum=State, + ) private_pool_v1_config = proto.Field( - proto.MESSAGE, number=12, oneof="config", message="PrivatePoolV1Config", + proto.MESSAGE, + number=12, + oneof="config", + message="PrivatePoolV1Config", + ) + etag = proto.Field( + proto.STRING, + number=11, ) - etag = proto.Field(proto.STRING, number=11,) class PrivatePoolV1Config(proto.Message): @@ -1924,8 +2655,14 @@ class WorkerConfig(proto.Message): Build will use a standard disk size. """ - 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, + ) class NetworkConfig(proto.Message): r"""Defines the network configuration for the pool. @@ -1952,13 +2689,26 @@ class EgressOption(proto.Enum): NO_PUBLIC_EGRESS = 1 PUBLIC_EGRESS = 2 - peered_network = proto.Field(proto.STRING, number=1,) + peered_network = proto.Field( + proto.STRING, + number=1, + ) egress_option = proto.Field( - proto.ENUM, number=2, enum="PrivatePoolV1Config.NetworkConfig.EgressOption", + proto.ENUM, + number=2, + enum="PrivatePoolV1Config.NetworkConfig.EgressOption", ) - worker_config = proto.Field(proto.MESSAGE, number=1, message=WorkerConfig,) - network_config = proto.Field(proto.MESSAGE, number=2, message=NetworkConfig,) + worker_config = proto.Field( + proto.MESSAGE, + number=1, + message=WorkerConfig, + ) + network_config = proto.Field( + proto.MESSAGE, + number=2, + message=NetworkConfig, + ) class CreateWorkerPoolRequest(proto.Message): @@ -1982,10 +2732,23 @@ class CreateWorkerPoolRequest(proto.Message): response, but do not actually post it. """ - parent = proto.Field(proto.STRING, number=1,) - worker_pool = proto.Field(proto.MESSAGE, number=2, message="WorkerPool",) - worker_pool_id = proto.Field(proto.STRING, number=3,) - validate_only = proto.Field(proto.BOOL, number=4,) + parent = proto.Field( + proto.STRING, + number=1, + ) + worker_pool = proto.Field( + proto.MESSAGE, + number=2, + message="WorkerPool", + ) + worker_pool_id = proto.Field( + proto.STRING, + number=3, + ) + validate_only = proto.Field( + proto.BOOL, + number=4, + ) class GetWorkerPoolRequest(proto.Message): @@ -1998,7 +2761,10 @@ class GetWorkerPoolRequest(proto.Message): ``projects/{project}/locations/{location}/workerPools/{workerPool}``. """ - name = proto.Field(proto.STRING, number=1,) + name = proto.Field( + proto.STRING, + number=1, + ) class DeleteWorkerPoolRequest(proto.Message): @@ -2021,10 +2787,22 @@ class DeleteWorkerPoolRequest(proto.Message): response, but do not actually post it. """ - name = proto.Field(proto.STRING, number=1,) - etag = proto.Field(proto.STRING, number=2,) - allow_missing = proto.Field(proto.BOOL, number=3,) - validate_only = proto.Field(proto.BOOL, number=4,) + name = proto.Field( + proto.STRING, + number=1, + ) + etag = proto.Field( + proto.STRING, + number=2, + ) + allow_missing = proto.Field( + proto.BOOL, + number=3, + ) + validate_only = proto.Field( + proto.BOOL, + number=4, + ) class UpdateWorkerPoolRequest(proto.Message): @@ -2044,11 +2822,20 @@ class UpdateWorkerPoolRequest(proto.Message): response, but do not actually post it. """ - worker_pool = proto.Field(proto.MESSAGE, number=1, message="WorkerPool",) + worker_pool = proto.Field( + proto.MESSAGE, + number=1, + message="WorkerPool", + ) update_mask = proto.Field( - proto.MESSAGE, number=2, message=field_mask_pb2.FieldMask, + proto.MESSAGE, + number=2, + message=field_mask_pb2.FieldMask, + ) + validate_only = proto.Field( + proto.BOOL, + number=4, ) - validate_only = proto.Field(proto.BOOL, number=4,) class ListWorkerPoolsRequest(proto.Message): @@ -2067,9 +2854,18 @@ class ListWorkerPoolsRequest(proto.Message): call. Provide this to retrieve the subsequent page. """ - parent = proto.Field(proto.STRING, number=1,) - page_size = proto.Field(proto.INT32, number=2,) - page_token = proto.Field(proto.STRING, number=3,) + parent = proto.Field( + proto.STRING, + number=1, + ) + page_size = proto.Field( + proto.INT32, + number=2, + ) + page_token = proto.Field( + proto.STRING, + number=3, + ) class ListWorkerPoolsResponse(proto.Message): @@ -2089,8 +2885,15 @@ class ListWorkerPoolsResponse(proto.Message): def raw_page(self): return self - worker_pools = proto.RepeatedField(proto.MESSAGE, number=1, message="WorkerPool",) - next_page_token = proto.Field(proto.STRING, number=2,) + worker_pools = proto.RepeatedField( + proto.MESSAGE, + number=1, + message="WorkerPool", + ) + next_page_token = proto.Field( + proto.STRING, + number=2, + ) class CreateWorkerPoolOperationMetadata(proto.Message): @@ -2106,10 +2909,19 @@ class CreateWorkerPoolOperationMetadata(proto.Message): Time the operation was completed. """ - worker_pool = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + worker_pool = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) complete_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) @@ -2127,10 +2939,19 @@ class UpdateWorkerPoolOperationMetadata(proto.Message): Time the operation was completed. """ - worker_pool = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + worker_pool = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) complete_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) @@ -2148,10 +2969,19 @@ class DeleteWorkerPoolOperationMetadata(proto.Message): Time the operation was completed. """ - worker_pool = proto.Field(proto.STRING, number=1,) - create_time = proto.Field(proto.MESSAGE, number=2, message=timestamp_pb2.Timestamp,) + worker_pool = proto.Field( + proto.STRING, + number=1, + ) + create_time = proto.Field( + proto.MESSAGE, + number=2, + message=timestamp_pb2.Timestamp, + ) complete_time = proto.Field( - proto.MESSAGE, number=3, message=timestamp_pb2.Timestamp, + proto.MESSAGE, + number=3, + message=timestamp_pb2.Timestamp, ) diff --git a/noxfile.py b/noxfile.py index 2a2001c4..92da31f8 100644 --- a/noxfile.py +++ b/noxfile.py @@ -20,16 +20,41 @@ import os import pathlib import shutil +import warnings import nox - -BLACK_VERSION = "black==19.10b0" -BLACK_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" +LINT_PATHS = ["docs", "google", "tests", "noxfile.py", "setup.py"] DEFAULT_PYTHON_VERSION = "3.8" -SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] + UNIT_TEST_PYTHON_VERSIONS = ["3.6", "3.7", "3.8", "3.9", "3.10"] +UNIT_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "asyncmock", + "pytest", + "pytest-cov", + "pytest-asyncio", +] +UNIT_TEST_EXTERNAL_DEPENDENCIES = [] +UNIT_TEST_LOCAL_DEPENDENCIES = [] +UNIT_TEST_DEPENDENCIES = [] +UNIT_TEST_EXTRAS = [] +UNIT_TEST_EXTRAS_BY_PYTHON = {} + +SYSTEM_TEST_PYTHON_VERSIONS = ["3.8"] +SYSTEM_TEST_STANDARD_DEPENDENCIES = [ + "mock", + "pytest", + "google-cloud-testutils", +] +SYSTEM_TEST_EXTERNAL_DEPENDENCIES = [] +SYSTEM_TEST_LOCAL_DEPENDENCIES = [] +SYSTEM_TEST_DEPENDENCIES = [] +SYSTEM_TEST_EXTRAS = [] +SYSTEM_TEST_EXTRAS_BY_PYTHON = {} CURRENT_DIRECTORY = pathlib.Path(__file__).parent.absolute() @@ -57,7 +82,9 @@ def lint(session): """ session.install("flake8", BLACK_VERSION) session.run( - "black", "--check", *BLACK_PATHS, + "black", + "--check", + *LINT_PATHS, ) session.run("flake8", "google", "tests") @@ -67,7 +94,28 @@ def blacken(session): """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) session.run( - "black", *BLACK_PATHS, + "black", + *LINT_PATHS, + ) + + +@nox.session(python=DEFAULT_PYTHON_VERSION) +def format(session): + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run( + "isort", + "--fss", + *LINT_PATHS, + ) + session.run( + "black", + *LINT_PATHS, ) @@ -78,23 +126,41 @@ def lint_setup_py(session): session.run("python", "setup.py", "check", "--restructuredtext", "--strict") +def install_unittest_dependencies(session, *constraints): + standard_deps = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_DEPENDENCIES + session.install(*standard_deps, *constraints) + + if UNIT_TEST_EXTERNAL_DEPENDENCIES: + warnings.warn( + "'unit_test_external_dependencies' is deprecated. Instead, please " + "use 'unit_test_dependencies' or 'unit_test_local_dependencies'.", + DeprecationWarning, + ) + session.install(*UNIT_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_LOCAL_DEPENDENCIES: + session.install(*UNIT_TEST_LOCAL_DEPENDENCIES, *constraints) + + if UNIT_TEST_EXTRAS_BY_PYTHON: + extras = UNIT_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif UNIT_TEST_EXTRAS: + extras = UNIT_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + def default(session): # Install all test dependencies, then install this package in-place. constraints_path = str( CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt" ) - session.install( - "mock", - "asyncmock", - "pytest", - "pytest-cov", - "pytest-asyncio", - "-c", - constraints_path, - ) - - session.install("-e", ".", "-c", constraints_path) + install_unittest_dependencies(session, "-c", constraints_path) # Run py.test against the unit tests. session.run( @@ -118,6 +184,35 @@ def unit(session): default(session) +def install_systemtest_dependencies(session, *constraints): + + # Use pre-release gRPC for system tests. + session.install("--pre", "grpcio") + + session.install(*SYSTEM_TEST_STANDARD_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTERNAL_DEPENDENCIES: + session.install(*SYSTEM_TEST_EXTERNAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_LOCAL_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_LOCAL_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_DEPENDENCIES: + session.install("-e", *SYSTEM_TEST_DEPENDENCIES, *constraints) + + if SYSTEM_TEST_EXTRAS_BY_PYTHON: + extras = SYSTEM_TEST_EXTRAS_BY_PYTHON.get(session.python, []) + elif SYSTEM_TEST_EXTRAS: + extras = SYSTEM_TEST_EXTRAS + else: + extras = [] + + if extras: + session.install("-e", f".[{','.join(extras)}]", *constraints) + else: + session.install("-e", ".", *constraints) + + @nox.session(python=SYSTEM_TEST_PYTHON_VERSIONS) def system(session): """Run the system test suite.""" @@ -140,13 +235,7 @@ def system(session): if not system_test_exists and not system_test_folder_exists: session.skip("System tests were not found") - # Use pre-release gRPC for system tests. - session.install("--pre", "grpcio") - - # Install all test dependencies, then install this package into the - # virtualenv's dist-packages. - session.install("mock", "pytest", "google-cloud-testutils", "-c", constraints_path) - session.install("-e", ".", "-c", constraints_path) + install_systemtest_dependencies(session, "-c", constraints_path) # Run py.test against the system tests. if system_test_exists: diff --git a/owlbot.py b/owlbot.py index 8a14a8ef..790b4b10 100644 --- a/owlbot.py +++ b/owlbot.py @@ -42,6 +42,7 @@ ) s.move(templated_files, excludes=[".coveragerc"]) # microgenerator has a good .coveragerc file +python.configure_previous_major_version_branches() python.py_samples(skip_readmes=True) diff --git a/samples/generated_samples/snippet_metadata_cloudbuild_v1.json b/samples/generated_samples/snippet_metadata_cloudbuild_v1.json index 1435e8d2..7234c281 100644 --- a/samples/generated_samples/snippet_metadata_cloudbuild_v1.json +++ b/samples/generated_samples/snippet_metadata_cloudbuild_v1.json @@ -1,16 +1,65 @@ { + "clientLibrary": { + "apis": [ + { + "id": "google.devtools.cloudbuild.v1", + "version": "v1" + } + ], + "language": "PYTHON", + "name": "google-cloud-build" + }, "snippets": [ { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.approve_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ApproveBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ApproveBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ApproveBuildRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "approval_result", + "type": "google.cloud.devtools.cloudbuild_v1.types.ApprovalResult" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "approve_build" }, + "description": "Sample for ApproveBuild", "file": "cloudbuild_v1_generated_cloud_build_approve_build_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ApproveBuild_async", "segments": [ { @@ -43,18 +92,58 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_approve_build_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.approve_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ApproveBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ApproveBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ApproveBuildRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "approval_result", + "type": "google.cloud.devtools.cloudbuild_v1.types.ApprovalResult" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "approve_build" }, + "description": "Sample for ApproveBuild", "file": "cloudbuild_v1_generated_cloud_build_approve_build_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ApproveBuild_sync", "segments": [ { @@ -87,19 +176,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_approve_build_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.cancel_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CancelBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CancelBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CancelBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", + "shortName": "cancel_build" }, + "description": "Sample for CancelBuild", "file": "cloudbuild_v1_generated_cloud_build_cancel_build_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CancelBuild_async", "segments": [ { @@ -132,18 +261,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_cancel_build_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.cancel_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CancelBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CancelBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CancelBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", + "shortName": "cancel_build" }, + "description": "Sample for CancelBuild", "file": "cloudbuild_v1_generated_cloud_build_cancel_build_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CancelBuild_sync", "segments": [ { @@ -176,19 +345,59 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_cancel_build_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.create_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger", + "type": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "create_build_trigger" }, + "description": "Sample for CreateBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_create_build_trigger_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateBuildTrigger_async", "segments": [ { @@ -221,18 +430,58 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_build_trigger_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.create_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger", + "type": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "create_build_trigger" }, + "description": "Sample for CreateBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_create_build_trigger_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateBuildTrigger_sync", "segments": [ { @@ -265,19 +514,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_build_trigger_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.create_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "build", + "type": "google.cloud.devtools.cloudbuild_v1.types.Build" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_build" }, + "description": "Sample for CreateBuild", "file": "cloudbuild_v1_generated_cloud_build_create_build_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateBuild_async", "segments": [ { @@ -310,18 +599,58 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_build_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.create_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "build", + "type": "google.cloud.devtools.cloudbuild_v1.types.Build" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_build" }, + "description": "Sample for CreateBuild", "file": "cloudbuild_v1_generated_cloud_build_create_build_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateBuild_sync", "segments": [ { @@ -354,19 +683,63 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_build_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.create_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateWorkerPoolRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "worker_pool", + "type": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool" + }, + { + "name": "worker_pool_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "create_worker_pool" }, + "description": "Sample for CreateWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_create_worker_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateWorkerPool_async", "segments": [ { @@ -399,18 +772,62 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_worker_pool_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.create_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.CreateWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "CreateWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.CreateWorkerPoolRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "worker_pool", + "type": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool" + }, + { + "name": "worker_pool_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "create_worker_pool" }, + "description": "Sample for CreateWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_create_worker_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_CreateWorkerPool_sync", "segments": [ { @@ -443,19 +860,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_create_worker_pool_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.delete_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.DeleteBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "DeleteBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.DeleteBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_build_trigger" }, + "description": "Sample for DeleteBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_delete_build_trigger_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_DeleteBuildTrigger_async", "segments": [ { @@ -486,18 +942,57 @@ "end": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_delete_build_trigger_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.delete_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.DeleteBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "DeleteBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.DeleteBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "shortName": "delete_build_trigger" }, + "description": "Sample for DeleteBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_delete_build_trigger_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_DeleteBuildTrigger_sync", "segments": [ { @@ -528,19 +1023,55 @@ "end": 44, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_delete_build_trigger_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.delete_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.DeleteWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "DeleteWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.DeleteWorkerPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "delete_worker_pool" }, + "description": "Sample for DeleteWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_delete_worker_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_DeleteWorkerPool_async", "segments": [ { @@ -573,18 +1104,54 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_delete_worker_pool_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.delete_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.DeleteWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "DeleteWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.DeleteWorkerPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "delete_worker_pool" }, + "description": "Sample for DeleteWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_delete_worker_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_DeleteWorkerPool_sync", "segments": [ { @@ -617,19 +1184,59 @@ "start": 46, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_delete_worker_pool_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.get_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "get_build_trigger" }, + "description": "Sample for GetBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_get_build_trigger_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetBuildTrigger_async", "segments": [ { @@ -662,18 +1269,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_build_trigger_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.get_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "get_build_trigger" }, + "description": "Sample for GetBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_get_build_trigger_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetBuildTrigger_sync", "segments": [ { @@ -706,19 +1353,59 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_build_trigger_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.get_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", + "shortName": "get_build" }, + "description": "Sample for GetBuild", "file": "cloudbuild_v1_generated_cloud_build_get_build_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetBuild_async", "segments": [ { @@ -751,18 +1438,58 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_build_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.get_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.Build", + "shortName": "get_build" }, + "description": "Sample for GetBuild", "file": "cloudbuild_v1_generated_cloud_build_get_build_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetBuild_sync", "segments": [ { @@ -795,19 +1522,55 @@ "start": 43, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_build_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.get_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetWorkerPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool", + "shortName": "get_worker_pool" }, + "description": "Sample for GetWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_get_worker_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetWorkerPool_async", "segments": [ { @@ -840,18 +1603,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_worker_pool_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.get_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.GetWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "GetWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.GetWorkerPoolRequest" + }, + { + "name": "name", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool", + "shortName": "get_worker_pool" }, + "description": "Sample for GetWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_get_worker_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_GetWorkerPool_sync", "segments": [ { @@ -884,19 +1683,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_get_worker_pool_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.list_build_triggers", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListBuildTriggers", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListBuildTriggers" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersAsyncPager", + "shortName": "list_build_triggers" }, + "description": "Sample for ListBuildTriggers", "file": "cloudbuild_v1_generated_cloud_build_list_build_triggers_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListBuildTriggers_async", "segments": [ { @@ -929,18 +1764,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_build_triggers_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.list_build_triggers", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListBuildTriggers", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListBuildTriggers" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListBuildTriggersRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildTriggersPager", + "shortName": "list_build_triggers" }, + "description": "Sample for ListBuildTriggers", "file": "cloudbuild_v1_generated_cloud_build_list_build_triggers_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListBuildTriggers_sync", "segments": [ { @@ -973,19 +1844,59 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_build_triggers_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.list_builds", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListBuilds", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListBuilds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListBuildsRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsAsyncPager", + "shortName": "list_builds" }, + "description": "Sample for ListBuilds", "file": "cloudbuild_v1_generated_cloud_build_list_builds_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListBuilds_async", "segments": [ { @@ -1018,18 +1929,58 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_builds_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.list_builds", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListBuilds", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListBuilds" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListBuildsRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "filter", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListBuildsPager", + "shortName": "list_builds" }, + "description": "Sample for ListBuilds", "file": "cloudbuild_v1_generated_cloud_build_list_builds_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListBuilds_sync", "segments": [ { @@ -1062,19 +2013,55 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_builds_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.list_worker_pools", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListWorkerPools", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListWorkerPools" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListWorkerPoolsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsAsyncPager", + "shortName": "list_worker_pools" }, + "description": "Sample for ListWorkerPools", "file": "cloudbuild_v1_generated_cloud_build_list_worker_pools_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListWorkerPools_async", "segments": [ { @@ -1107,18 +2094,54 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_worker_pools_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.list_worker_pools", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ListWorkerPools", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ListWorkerPools" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ListWorkerPoolsRequest" + }, + { + "name": "parent", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.services.cloud_build.pagers.ListWorkerPoolsPager", + "shortName": "list_worker_pools" }, + "description": "Sample for ListWorkerPools", "file": "cloudbuild_v1_generated_cloud_build_list_worker_pools_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ListWorkerPools_sync", "segments": [ { @@ -1151,19 +2174,51 @@ "start": 42, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_list_worker_pools_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.receive_trigger_webhook", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ReceiveTriggerWebhook", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ReceiveTriggerWebhook" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse", + "shortName": "receive_trigger_webhook" }, + "description": "Sample for ReceiveTriggerWebhook", "file": "cloudbuild_v1_generated_cloud_build_receive_trigger_webhook_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ReceiveTriggerWebhook_async", "segments": [ { @@ -1196,18 +2251,50 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_receive_trigger_webhook_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.receive_trigger_webhook", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.ReceiveTriggerWebhook", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "ReceiveTriggerWebhook" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookRequest" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.ReceiveTriggerWebhookResponse", + "shortName": "receive_trigger_webhook" }, + "description": "Sample for ReceiveTriggerWebhook", "file": "cloudbuild_v1_generated_cloud_build_receive_trigger_webhook_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_ReceiveTriggerWebhook_sync", "segments": [ { @@ -1240,19 +2327,59 @@ "start": 41, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_receive_trigger_webhook_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.retry_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.RetryBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "RetryBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.RetryBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "retry_build" }, + "description": "Sample for RetryBuild", "file": "cloudbuild_v1_generated_cloud_build_retry_build_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_RetryBuild_async", "segments": [ { @@ -1285,18 +2412,58 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_retry_build_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.retry_build", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.RetryBuild", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "RetryBuild" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.RetryBuildRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "id", + "type": "str" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "retry_build" }, + "description": "Sample for RetryBuild", "file": "cloudbuild_v1_generated_cloud_build_retry_build_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_RetryBuild_sync", "segments": [ { @@ -1329,19 +2496,63 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_retry_build_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.run_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.RunBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "RunBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.RunBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "source", + "type": "google.cloud.devtools.cloudbuild_v1.types.RepoSource" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "run_build_trigger" }, + "description": "Sample for RunBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_run_build_trigger_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_RunBuildTrigger_async", "segments": [ { @@ -1374,18 +2585,62 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_run_build_trigger_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.run_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.RunBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "RunBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.RunBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "source", + "type": "google.cloud.devtools.cloudbuild_v1.types.RepoSource" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "run_build_trigger" }, + "description": "Sample for RunBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_run_build_trigger_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_RunBuildTrigger_sync", "segments": [ { @@ -1418,19 +2673,63 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_run_build_trigger_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.update_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.UpdateBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "UpdateBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.UpdateBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "trigger", + "type": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "update_build_trigger" }, + "description": "Sample for UpdateBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_update_build_trigger_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_UpdateBuildTrigger_async", "segments": [ { @@ -1463,18 +2762,62 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_update_build_trigger_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.update_build_trigger", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.UpdateBuildTrigger", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "UpdateBuildTrigger" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.UpdateBuildTriggerRequest" + }, + { + "name": "project_id", + "type": "str" + }, + { + "name": "trigger_id", + "type": "str" + }, + { + "name": "trigger", + "type": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.cloud.devtools.cloudbuild_v1.types.BuildTrigger", + "shortName": "update_build_trigger" }, + "description": "Sample for UpdateBuildTrigger", "file": "cloudbuild_v1_generated_cloud_build_update_build_trigger_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_UpdateBuildTrigger_sync", "segments": [ { @@ -1507,19 +2850,59 @@ "start": 47, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_update_build_trigger_sync.py" }, { + "canonical": true, "clientMethod": { "async": true, + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient", + "shortName": "CloudBuildAsyncClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildAsyncClient.update_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.UpdateWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "UpdateWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.UpdateWorkerPoolRequest" + }, + { + "name": "worker_pool", + "type": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation_async.AsyncOperation", + "shortName": "update_worker_pool" }, + "description": "Sample for UpdateWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_update_worker_pool_async.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_UpdateWorkerPool_async", "segments": [ { @@ -1552,18 +2935,58 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_update_worker_pool_async.py" }, { + "canonical": true, "clientMethod": { + "client": { + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient", + "shortName": "CloudBuildClient" + }, + "fullName": "google.cloud.devtools.cloudbuild_v1.CloudBuildClient.update_worker_pool", "method": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild.UpdateWorkerPool", "service": { + "fullName": "google.devtools.cloudbuild.v1.CloudBuild", "shortName": "CloudBuild" }, "shortName": "UpdateWorkerPool" - } + }, + "parameters": [ + { + "name": "request", + "type": "google.cloud.devtools.cloudbuild_v1.types.UpdateWorkerPoolRequest" + }, + { + "name": "worker_pool", + "type": "google.cloud.devtools.cloudbuild_v1.types.WorkerPool" + }, + { + "name": "update_mask", + "type": "google.protobuf.field_mask_pb2.FieldMask" + }, + { + "name": "retry", + "type": "google.api_core.retry.Retry" + }, + { + "name": "timeout", + "type": "float" + }, + { + "name": "metadata", + "type": "Sequence[Tuple[str, str]" + } + ], + "resultType": "google.api_core.operation.Operation", + "shortName": "update_worker_pool" }, + "description": "Sample for UpdateWorkerPool", "file": "cloudbuild_v1_generated_cloud_build_update_worker_pool_sync.py", + "language": "PYTHON", + "origin": "API_DEFINITION", "regionTag": "cloudbuild_v1_generated_CloudBuild_UpdateWorkerPool_sync", "segments": [ { @@ -1596,7 +3019,8 @@ "start": 45, "type": "RESPONSE_HANDLING" } - ] + ], + "title": "cloudbuild_v1_generated_cloud_build_update_worker_pool_sync.py" } ] } diff --git a/samples/snippets/noxfile.py b/samples/snippets/noxfile.py index 4c808af7..38bb0a57 100644 --- a/samples/snippets/noxfile.py +++ b/samples/snippets/noxfile.py @@ -29,7 +29,8 @@ # WARNING - WARNING - WARNING - WARNING - WARNING # WARNING - WARNING - WARNING - WARNING - WARNING -BLACK_VERSION = "black==19.10b0" +BLACK_VERSION = "black==22.3.0" +ISORT_VERSION = "isort==5.10.1" # Copy `noxfile_config.py` to your directory and modify it instead. @@ -168,12 +169,32 @@ def lint(session: nox.sessions.Session) -> None: @nox.session def blacken(session: nox.sessions.Session) -> None: + """Run black. Format code to uniform standard.""" session.install(BLACK_VERSION) python_files = [path for path in os.listdir(".") if path.endswith(".py")] session.run("black", *python_files) +# +# format = isort + black +# + +@nox.session +def format(session: nox.sessions.Session) -> None: + """ + Run isort to sort imports. Then run black + to format code to uniform standard. + """ + session.install(BLACK_VERSION, ISORT_VERSION) + python_files = [path for path in os.listdir(".") if path.endswith(".py")] + + # Use the --fss option to sort imports using strict alphabetical order. + # See https://pycqa.github.io/isort/docs/configuration/options.html#force-sort-within-sections + session.run("isort", "--fss", *python_files) + session.run("black", *python_files) + + # # Sample Tests # diff --git a/samples/snippets/quickstart.py b/samples/snippets/quickstart.py index db5130f0..39064e49 100644 --- a/samples/snippets/quickstart.py +++ b/samples/snippets/quickstart.py @@ -23,6 +23,8 @@ def quickstart(): print the in-progress status and print the completed status.""" # Authorize the client with Google defaults + # If you're using Private Pools, add a regional `api_endpoint` to `CloudBuildClient()` + # For example, '-cloudbuild.googleapis.com' credentials, project_id = google.auth.default() client = cloudbuild_v1.services.cloud_build.CloudBuildClient() diff --git a/samples/snippets/requirements-test.txt b/samples/snippets/requirements-test.txt index 76593bb6..6a3d7bca 100644 --- a/samples/snippets/requirements-test.txt +++ b/samples/snippets/requirements-test.txt @@ -1 +1 @@ -pytest==7.0.1 \ No newline at end of file +pytest==7.1.2 \ No newline at end of file diff --git a/samples/snippets/requirements.txt b/samples/snippets/requirements.txt index 0c28ff19..8b233415 100644 --- a/samples/snippets/requirements.txt +++ b/samples/snippets/requirements.txt @@ -1,2 +1,2 @@ -google-cloud-build==3.8.0 -google-auth==2.6.0 \ No newline at end of file +google-cloud-build==3.8.1 +google-auth==2.6.6 \ No newline at end of file diff --git a/scripts/readme-gen/readme_gen.py b/scripts/readme-gen/readme_gen.py index d309d6e9..91b59676 100644 --- a/scripts/readme-gen/readme_gen.py +++ b/scripts/readme-gen/readme_gen.py @@ -28,7 +28,10 @@ jinja_env = jinja2.Environment( trim_blocks=True, loader=jinja2.FileSystemLoader( - os.path.abspath(os.path.join(os.path.dirname(__file__), 'templates')))) + os.path.abspath(os.path.join(os.path.dirname(__file__), "templates")) + ), + autoescape=True, +) README_TMPL = jinja_env.get_template('README.tmpl.rst') diff --git a/setup.py b/setup.py index b1a4b38c..ed1e6c3a 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ name = "google-cloud-build" description = "Google Cloud Build API client library" -version = "3.8.1" +version = "3.8.2" # Should be one of: # 'Development Status :: 3 - Alpha' # 'Development Status :: 4 - Beta' diff --git a/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py b/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py index c3c0f87e..1f28163e 100644 --- a/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py +++ b/tests/unit/gapic/cloudbuild_v1/test_cloud_build.py @@ -93,19 +93,25 @@ def test__get_default_mtls_endpoint(): assert CloudBuildClient._get_default_mtls_endpoint(non_googleapi) == non_googleapi -@pytest.mark.parametrize("client_class", [CloudBuildClient, CloudBuildAsyncClient,]) -def test_cloud_build_client_from_service_account_info(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudBuildClient, "grpc"), + (CloudBuildAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_build_client_from_service_account_info(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_info" ) as factory: factory.return_value = creds info = {"valid": True} - client = client_class.from_service_account_info(info) + client = client_class.from_service_account_info(info, transport=transport_name) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudbuild.googleapis.com:443" + assert client.transport._host == ("cloudbuild.googleapis.com:443") @pytest.mark.parametrize( @@ -133,22 +139,32 @@ def test_cloud_build_client_service_account_always_use_jwt( use_jwt.assert_not_called() -@pytest.mark.parametrize("client_class", [CloudBuildClient, CloudBuildAsyncClient,]) -def test_cloud_build_client_from_service_account_file(client_class): +@pytest.mark.parametrize( + "client_class,transport_name", + [ + (CloudBuildClient, "grpc"), + (CloudBuildAsyncClient, "grpc_asyncio"), + ], +) +def test_cloud_build_client_from_service_account_file(client_class, transport_name): creds = ga_credentials.AnonymousCredentials() with mock.patch.object( service_account.Credentials, "from_service_account_file" ) as factory: factory.return_value = creds - client = client_class.from_service_account_file("dummy/file/path.json") + client = client_class.from_service_account_file( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - client = client_class.from_service_account_json("dummy/file/path.json") + client = client_class.from_service_account_json( + "dummy/file/path.json", transport=transport_name + ) assert client.transport._credentials == creds assert isinstance(client, client_class) - assert client.transport._host == "cloudbuild.googleapis.com:443" + assert client.transport._host == ("cloudbuild.googleapis.com:443") def test_cloud_build_client_get_transport_class(): @@ -488,7 +504,9 @@ def test_cloud_build_client_client_options_scopes( client_class, transport_class, transport_name ): # Check the case scopes are provided. - options = client_options.ClientOptions(scopes=["1", "2"],) + options = client_options.ClientOptions( + scopes=["1", "2"], + ) with mock.patch.object(transport_class, "__init__") as patched: patched.return_value = None client = client_class(client_options=options, transport=transport_name) @@ -616,10 +634,17 @@ def test_cloud_build_client_create_channel_credentials_file( ) -@pytest.mark.parametrize("request_type", [cloudbuild.CreateBuildRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.CreateBuildRequest, + dict, + ], +) def test_create_build(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -645,7 +670,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -661,7 +687,8 @@ async def test_create_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateBuildRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -690,8 +717,71 @@ async def test_create_build_async_from_dict(): await test_create_build_async(request_type=dict) +def test_create_build_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CreateBuildRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_build), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_build_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CreateBuildRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.create_build), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + def test_create_build_flattened(): - client = CloudBuildClient(credentials=ga_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: @@ -700,7 +790,8 @@ def test_create_build_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.create_build( - project_id="project_id_value", build=cloudbuild.Build(name="name_value"), + project_id="project_id_value", + build=cloudbuild.Build(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -716,7 +807,9 @@ def test_create_build_flattened(): def test_create_build_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -730,7 +823,9 @@ def test_create_build_flattened_error(): @pytest.mark.asyncio async def test_create_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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: @@ -743,7 +838,8 @@ async def test_create_build_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.create_build( - project_id="project_id_value", build=cloudbuild.Build(name="name_value"), + project_id="project_id_value", + build=cloudbuild.Build(name="name_value"), ) # Establish that the underlying call was made with the expected @@ -760,7 +856,9 @@ async def test_create_build_flattened_async(): @pytest.mark.asyncio async def test_create_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -772,10 +870,17 @@ async def test_create_build_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.GetBuildRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.GetBuildRequest, + dict, + ], +) def test_get_build(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -824,7 +929,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -840,7 +946,8 @@ async def test_get_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetBuildRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -892,8 +999,71 @@ async def test_get_build_async_from_dict(): await test_get_build_async(request_type=dict) +def test_get_build_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.GetBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_build), "__call__") as call: + call.return_value = cloudbuild.Build() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_build_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.GetBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.get_build), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloudbuild.Build()) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + def test_get_build_flattened(): - client = CloudBuildClient(credentials=ga_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: @@ -902,7 +1072,8 @@ def test_get_build_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.get_build( - project_id="project_id_value", id="id_value", + project_id="project_id_value", + id="id_value", ) # Establish that the underlying call was made with the expected @@ -918,19 +1089,25 @@ def test_get_build_flattened(): def test_get_build_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_build( - cloudbuild.GetBuildRequest(), project_id="project_id_value", id="id_value", + cloudbuild.GetBuildRequest(), + project_id="project_id_value", + id="id_value", ) @pytest.mark.asyncio async def test_get_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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: @@ -940,7 +1117,10 @@ async def test_get_build_flattened_async(): call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloudbuild.Build()) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_build(project_id="project_id_value", id="id_value",) + response = await client.get_build( + project_id="project_id_value", + id="id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -956,20 +1136,31 @@ async def test_get_build_flattened_async(): @pytest.mark.asyncio async def test_get_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_build( - cloudbuild.GetBuildRequest(), project_id="project_id_value", id="id_value", + cloudbuild.GetBuildRequest(), + project_id="project_id_value", + id="id_value", ) -@pytest.mark.parametrize("request_type", [cloudbuild.ListBuildsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.ListBuildsRequest, + dict, + ], +) def test_list_builds(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -998,7 +1189,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1014,7 +1206,8 @@ async def test_list_builds_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListBuildsRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1025,7 +1218,9 @@ async def test_list_builds_async( with mock.patch.object(type(client.transport.list_builds), "__call__") as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudbuild.ListBuildsResponse(next_page_token="next_page_token_value",) + cloudbuild.ListBuildsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_builds(request) @@ -1044,8 +1239,71 @@ async def test_list_builds_async_from_dict(): await test_list_builds_async(request_type=dict) +def test_list_builds_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ListBuildsRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_builds), "__call__") as call: + call.return_value = cloudbuild.ListBuildsResponse() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_builds_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ListBuildsRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.list_builds), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.ListBuildsResponse() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + def test_list_builds_flattened(): - client = CloudBuildClient(credentials=ga_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: @@ -1054,7 +1312,8 @@ def test_list_builds_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.list_builds( - project_id="project_id_value", filter="filter_value", + project_id="project_id_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1070,7 +1329,9 @@ def test_list_builds_flattened(): def test_list_builds_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1084,7 +1345,9 @@ def test_list_builds_flattened_error(): @pytest.mark.asyncio async def test_list_builds_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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: @@ -1097,7 +1360,8 @@ async def test_list_builds_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.list_builds( - project_id="project_id_value", filter="filter_value", + project_id="project_id_value", + filter="filter_value", ) # Establish that the underlying call was made with the expected @@ -1114,7 +1378,9 @@ async def test_list_builds_flattened_async(): @pytest.mark.asyncio async def test_list_builds_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1128,7 +1394,8 @@ async def test_list_builds_flattened_error_async(): def test_list_builds_pager(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1136,32 +1403,49 @@ def test_list_builds_pager(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + cloudbuild.Build(), + ], next_page_token="abc", ), - cloudbuild.ListBuildsResponse(builds=[], next_page_token="def",), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(),], next_page_token="ghi", + builds=[], + next_page_token="def", ), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + ], + next_page_token="ghi", + ), + cloudbuild.ListBuildsResponse( + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + ], ), RuntimeError, ) metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("project_id", ""),)), + ) pager = client.list_builds(request={}) assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, cloudbuild.Build) for i in results) def test_list_builds_pages(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1169,15 +1453,28 @@ def test_list_builds_pages(transport_name: str = "grpc"): # Set the response to a series of pages. call.side_effect = ( cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + cloudbuild.Build(), + ], next_page_token="abc", ), - cloudbuild.ListBuildsResponse(builds=[], next_page_token="def",), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(),], next_page_token="ghi", + builds=[], + next_page_token="def", + ), + cloudbuild.ListBuildsResponse( + builds=[ + cloudbuild.Build(), + ], + next_page_token="ghi", ), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + ], ), RuntimeError, ) @@ -1188,7 +1485,9 @@ def test_list_builds_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_builds_async_pager(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1197,22 +1496,37 @@ async def test_list_builds_async_pager(): # Set the response to a series of pages. call.side_effect = ( cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + cloudbuild.Build(), + ], next_page_token="abc", ), - cloudbuild.ListBuildsResponse(builds=[], next_page_token="def",), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(),], next_page_token="ghi", + builds=[], + next_page_token="def", + ), + cloudbuild.ListBuildsResponse( + builds=[ + cloudbuild.Build(), + ], + next_page_token="ghi", ), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + ], ), RuntimeError, ) - async_pager = await client.list_builds(request={},) + async_pager = await client.list_builds( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -1221,7 +1535,9 @@ async def test_list_builds_async_pager(): @pytest.mark.asyncio async def test_list_builds_async_pages(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1230,29 +1546,51 @@ async def test_list_builds_async_pages(): # Set the response to a series of pages. call.side_effect = ( cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + cloudbuild.Build(), + ], next_page_token="abc", ), - cloudbuild.ListBuildsResponse(builds=[], next_page_token="def",), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(),], next_page_token="ghi", + builds=[], + next_page_token="def", + ), + cloudbuild.ListBuildsResponse( + builds=[ + cloudbuild.Build(), + ], + next_page_token="ghi", ), cloudbuild.ListBuildsResponse( - builds=[cloudbuild.Build(), cloudbuild.Build(),], + builds=[ + cloudbuild.Build(), + cloudbuild.Build(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_builds(request={})).pages: + async for page_ in ( + await client.list_builds(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudbuild.CancelBuildRequest, dict,]) -def test_cancel_build(request_type, transport: str = "grpc"): - client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.CancelBuildRequest, + dict, + ], +) +def test_cancel_build(request_type, transport: str = "grpc"): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1301,7 +1639,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1317,7 +1656,8 @@ async def test_cancel_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CancelBuildRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1369,8 +1709,71 @@ async def test_cancel_build_async_from_dict(): await test_cancel_build_async(request_type=dict) +def test_cancel_build_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CancelBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_build), "__call__") as call: + call.return_value = cloudbuild.Build() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_cancel_build_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CancelBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.cancel_build), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(cloudbuild.Build()) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + def test_cancel_build_flattened(): - client = CloudBuildClient(credentials=ga_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: @@ -1379,7 +1782,8 @@ def test_cancel_build_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.cancel_build( - project_id="project_id_value", id="id_value", + project_id="project_id_value", + id="id_value", ) # Establish that the underlying call was made with the expected @@ -1395,7 +1799,9 @@ def test_cancel_build_flattened(): def test_cancel_build_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1409,7 +1815,9 @@ def test_cancel_build_flattened_error(): @pytest.mark.asyncio async def test_cancel_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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: @@ -1420,7 +1828,8 @@ async def test_cancel_build_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.cancel_build( - project_id="project_id_value", id="id_value", + project_id="project_id_value", + id="id_value", ) # Establish that the underlying call was made with the expected @@ -1437,7 +1846,9 @@ async def test_cancel_build_flattened_async(): @pytest.mark.asyncio async def test_cancel_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1449,10 +1860,17 @@ async def test_cancel_build_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.RetryBuildRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.RetryBuildRequest, + dict, + ], +) def test_retry_build(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1478,7 +1896,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1494,7 +1913,8 @@ async def test_retry_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.RetryBuildRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1523,8 +1943,73 @@ async def test_retry_build_async_from_dict(): await test_retry_build_async(request_type=dict) +def test_retry_build_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.RetryBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.retry_build), "__call__") as call: + call.return_value = operations_pb2.Operation(name="operations/op") + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_retry_build_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.RetryBuildRequest() + + request.project_id = "project_id_value" + request.id = "id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object(type(client.transport.retry_build), "__call__") as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&id=id_value", + ) in kw["metadata"] + + def test_retry_build_flattened(): - client = CloudBuildClient(credentials=ga_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: @@ -1533,7 +2018,8 @@ def test_retry_build_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.retry_build( - project_id="project_id_value", id="id_value", + project_id="project_id_value", + id="id_value", ) # Establish that the underlying call was made with the expected @@ -1549,7 +2035,9 @@ def test_retry_build_flattened(): def test_retry_build_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1563,7 +2051,9 @@ def test_retry_build_flattened_error(): @pytest.mark.asyncio async def test_retry_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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: @@ -1576,7 +2066,8 @@ async def test_retry_build_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.retry_build( - project_id="project_id_value", id="id_value", + project_id="project_id_value", + id="id_value", ) # Establish that the underlying call was made with the expected @@ -1593,7 +2084,9 @@ async def test_retry_build_flattened_async(): @pytest.mark.asyncio async def test_retry_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1605,10 +2098,17 @@ async def test_retry_build_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.ApproveBuildRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.ApproveBuildRequest, + dict, + ], +) def test_approve_build(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1634,7 +2134,8 @@ def test_approve_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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1650,7 +2151,8 @@ async def test_approve_build_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ApproveBuildRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1680,13 +2182,15 @@ async def test_approve_build_async_from_dict(): def test_approve_build_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.ApproveBuildRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.approve_build), "__call__") as call: @@ -1700,18 +2204,23 @@ def test_approve_build_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_approve_build_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.ApproveBuildRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.approve_build), "__call__") as call: @@ -1727,11 +2236,16 @@ async def test_approve_build_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_approve_build_flattened(): - client = CloudBuildClient(credentials=ga_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.approve_build), "__call__") as call: @@ -1759,7 +2273,9 @@ def test_approve_build_flattened(): def test_approve_build_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1775,7 +2291,9 @@ def test_approve_build_flattened_error(): @pytest.mark.asyncio async def test_approve_build_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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.approve_build), "__call__") as call: @@ -1808,7 +2326,9 @@ async def test_approve_build_flattened_async(): @pytest.mark.asyncio async def test_approve_build_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1822,10 +2342,17 @@ async def test_approve_build_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.CreateBuildTriggerRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.CreateBuildTriggerRequest, + dict, + ], +) def test_create_build_trigger(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1875,7 +2402,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -1893,7 +2421,8 @@ async def test_create_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -1945,8 +2474,75 @@ async def test_create_build_trigger_async_from_dict(): await test_create_build_trigger_async(request_type=dict) +def test_create_build_trigger_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CreateBuildTriggerRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_build_trigger), "__call__" + ) as call: + call.return_value = cloudbuild.BuildTrigger() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_create_build_trigger_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.CreateBuildTriggerRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.create_build_trigger), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.BuildTrigger() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + def test_create_build_trigger_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -1974,7 +2570,9 @@ def test_create_build_trigger_flattened(): def test_create_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -1988,7 +2586,9 @@ def test_create_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_create_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2021,7 +2621,9 @@ async def test_create_build_trigger_flattened_async(): @pytest.mark.asyncio async def test_create_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2033,10 +2635,17 @@ async def test_create_build_trigger_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.GetBuildTriggerRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.GetBuildTriggerRequest, + dict, + ], +) def test_get_build_trigger(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2086,7 +2695,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2104,7 +2714,8 @@ async def test_get_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2156,19 +2767,89 @@ async def test_get_build_trigger_async_from_dict(): await test_get_build_trigger_async(request_type=dict) -def test_get_build_trigger_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) +def test_get_build_trigger_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.GetBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( type(client.transport.get_build_trigger), "__call__" ) 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( - project_id="project_id_value", trigger_id="trigger_id_value", + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_get_build_trigger_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.GetBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.get_build_trigger), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.BuildTrigger() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + +def test_get_build_trigger_flattened(): + 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_trigger), "__call__" + ) 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( + project_id="project_id_value", + trigger_id="trigger_id_value", ) # Establish that the underlying call was made with the expected @@ -2184,7 +2865,9 @@ def test_get_build_trigger_flattened(): def test_get_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2198,7 +2881,9 @@ def test_get_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_get_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2213,7 +2898,8 @@ async def test_get_build_trigger_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.get_build_trigger( - project_id="project_id_value", trigger_id="trigger_id_value", + project_id="project_id_value", + trigger_id="trigger_id_value", ) # Establish that the underlying call was made with the expected @@ -2230,7 +2916,9 @@ async def test_get_build_trigger_flattened_async(): @pytest.mark.asyncio async def test_get_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2242,10 +2930,17 @@ async def test_get_build_trigger_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.ListBuildTriggersRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.ListBuildTriggersRequest, + dict, + ], +) def test_list_build_triggers(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2276,7 +2971,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2294,7 +2990,8 @@ async def test_list_build_triggers_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListBuildTriggersRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2328,8 +3025,75 @@ async def test_list_build_triggers_async_from_dict(): await test_list_build_triggers_async(request_type=dict) +def test_list_build_triggers_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ListBuildTriggersRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_build_triggers), "__call__" + ) as call: + call.return_value = cloudbuild.ListBuildTriggersResponse() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_list_build_triggers_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ListBuildTriggersRequest() + + request.project_id = "project_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.list_build_triggers), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.ListBuildTriggersResponse() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value", + ) in kw["metadata"] + + def test_list_build_triggers_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2339,7 +3103,9 @@ def test_list_build_triggers_flattened(): 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",) + client.list_build_triggers( + project_id="project_id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2351,19 +3117,24 @@ def test_list_build_triggers_flattened(): def test_list_build_triggers_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_build_triggers( - cloudbuild.ListBuildTriggersRequest(), project_id="project_id_value", + cloudbuild.ListBuildTriggersRequest(), + project_id="project_id_value", ) @pytest.mark.asyncio async def test_list_build_triggers_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2377,7 +3148,9 @@ async def test_list_build_triggers_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_build_triggers(project_id="project_id_value",) + response = await client.list_build_triggers( + project_id="project_id_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -2390,19 +3163,23 @@ async def test_list_build_triggers_flattened_async(): @pytest.mark.asyncio async def test_list_build_triggers_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_build_triggers( - cloudbuild.ListBuildTriggersRequest(), project_id="project_id_value", + cloudbuild.ListBuildTriggersRequest(), + project_id="project_id_value", ) def test_list_build_triggers_pager(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2419,29 +3196,42 @@ def test_list_build_triggers_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloudbuild.ListBuildTriggersResponse(triggers=[], next_page_token="def",), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(),], next_page_token="ghi", + triggers=[], + next_page_token="def", ), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(), cloudbuild.BuildTrigger(),], + triggers=[ + cloudbuild.BuildTrigger(), + ], + next_page_token="ghi", + ), + cloudbuild.ListBuildTriggersResponse( + triggers=[ + cloudbuild.BuildTrigger(), + cloudbuild.BuildTrigger(), + ], ), RuntimeError, ) metadata = () + metadata = tuple(metadata) + ( + gapic_v1.routing_header.to_grpc_metadata((("project_id", ""),)), + ) pager = client.list_build_triggers(request={}) assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, cloudbuild.BuildTrigger) for i in results) def test_list_build_triggers_pages(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2458,12 +3248,21 @@ def test_list_build_triggers_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloudbuild.ListBuildTriggersResponse(triggers=[], next_page_token="def",), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(),], next_page_token="ghi", + triggers=[], + next_page_token="def", + ), + cloudbuild.ListBuildTriggersResponse( + triggers=[ + cloudbuild.BuildTrigger(), + ], + next_page_token="ghi", ), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(), cloudbuild.BuildTrigger(),], + triggers=[ + cloudbuild.BuildTrigger(), + cloudbuild.BuildTrigger(), + ], ), RuntimeError, ) @@ -2474,7 +3273,9 @@ def test_list_build_triggers_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_build_triggers_async_pager(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2492,19 +3293,30 @@ async def test_list_build_triggers_async_pager(): ], next_page_token="abc", ), - cloudbuild.ListBuildTriggersResponse(triggers=[], next_page_token="def",), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(),], next_page_token="ghi", + triggers=[], + next_page_token="def", ), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(), cloudbuild.BuildTrigger(),], + triggers=[ + cloudbuild.BuildTrigger(), + ], + next_page_token="ghi", + ), + cloudbuild.ListBuildTriggersResponse( + triggers=[ + cloudbuild.BuildTrigger(), + cloudbuild.BuildTrigger(), + ], ), RuntimeError, ) - async_pager = await client.list_build_triggers(request={},) + async_pager = await client.list_build_triggers( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -2513,7 +3325,9 @@ async def test_list_build_triggers_async_pager(): @pytest.mark.asyncio async def test_list_build_triggers_async_pages(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2531,26 +3345,44 @@ async def test_list_build_triggers_async_pages(): ], next_page_token="abc", ), - cloudbuild.ListBuildTriggersResponse(triggers=[], next_page_token="def",), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(),], next_page_token="ghi", + triggers=[], + next_page_token="def", + ), + cloudbuild.ListBuildTriggersResponse( + triggers=[ + cloudbuild.BuildTrigger(), + ], + next_page_token="ghi", ), cloudbuild.ListBuildTriggersResponse( - triggers=[cloudbuild.BuildTrigger(), cloudbuild.BuildTrigger(),], + triggers=[ + cloudbuild.BuildTrigger(), + cloudbuild.BuildTrigger(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_build_triggers(request={})).pages: + async for page_ in ( + await client.list_build_triggers(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token -@pytest.mark.parametrize("request_type", [cloudbuild.DeleteBuildTriggerRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.DeleteBuildTriggerRequest, + dict, + ], +) def test_delete_build_trigger(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2578,7 +3410,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2596,7 +3429,8 @@ async def test_delete_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.DeleteBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2625,8 +3459,75 @@ async def test_delete_build_trigger_async_from_dict(): await test_delete_build_trigger_async(request_type=dict) +def test_delete_build_trigger_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.DeleteBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_build_trigger), "__call__" + ) as call: + call.return_value = None + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_delete_build_trigger_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.DeleteBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.delete_build_trigger), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall(None) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + def test_delete_build_trigger_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2637,7 +3538,8 @@ def test_delete_build_trigger_flattened(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. client.delete_build_trigger( - project_id="project_id_value", trigger_id="trigger_id_value", + project_id="project_id_value", + trigger_id="trigger_id_value", ) # Establish that the underlying call was made with the expected @@ -2653,7 +3555,9 @@ def test_delete_build_trigger_flattened(): def test_delete_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2667,7 +3571,9 @@ def test_delete_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_delete_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2680,7 +3586,8 @@ async def test_delete_build_trigger_flattened_async(): # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. response = await client.delete_build_trigger( - project_id="project_id_value", trigger_id="trigger_id_value", + project_id="project_id_value", + trigger_id="trigger_id_value", ) # Establish that the underlying call was made with the expected @@ -2697,7 +3604,9 @@ async def test_delete_build_trigger_flattened_async(): @pytest.mark.asyncio async def test_delete_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2709,10 +3618,17 @@ async def test_delete_build_trigger_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.UpdateBuildTriggerRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.UpdateBuildTriggerRequest, + dict, + ], +) def test_update_build_trigger(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2762,7 +3678,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2780,7 +3697,8 @@ async def test_update_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.UpdateBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2832,8 +3750,77 @@ async def test_update_build_trigger_async_from_dict(): await test_update_build_trigger_async(request_type=dict) +def test_update_build_trigger_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.UpdateBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_build_trigger), "__call__" + ) as call: + call.return_value = cloudbuild.BuildTrigger() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_update_build_trigger_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.UpdateBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.update_build_trigger), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.BuildTrigger() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + def test_update_build_trigger_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2865,7 +3852,9 @@ def test_update_build_trigger_flattened(): def test_update_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2880,7 +3869,9 @@ def test_update_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_update_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -2917,7 +3908,9 @@ async def test_update_build_trigger_flattened_async(): @pytest.mark.asyncio async def test_update_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -2930,10 +3923,17 @@ async def test_update_build_trigger_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.RunBuildTriggerRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.RunBuildTriggerRequest, + dict, + ], +) def test_run_build_trigger(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -2961,7 +3961,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -2979,7 +3980,8 @@ async def test_run_build_trigger_async( transport: str = "grpc_asyncio", request_type=cloudbuild.RunBuildTriggerRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3010,8 +4012,77 @@ async def test_run_build_trigger_async_from_dict(): await test_run_build_trigger_async(request_type=dict) +def test_run_build_trigger_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.RunBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.run_build_trigger), "__call__" + ) as call: + call.return_value = operations_pb2.Operation(name="operations/op") + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_run_build_trigger_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.RunBuildTriggerRequest() + + request.project_id = "project_id_value" + request.trigger_id = "trigger_id_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.run_build_trigger), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + operations_pb2.Operation(name="operations/op") + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger_id=trigger_id_value", + ) in kw["metadata"] + + def test_run_build_trigger_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3043,7 +4114,9 @@ def test_run_build_trigger_flattened(): def test_run_build_trigger_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3058,7 +4131,9 @@ def test_run_build_trigger_flattened_error(): @pytest.mark.asyncio async def test_run_build_trigger_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3095,7 +4170,9 @@ async def test_run_build_trigger_flattened_async(): @pytest.mark.asyncio async def test_run_build_trigger_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3109,11 +4186,16 @@ async def test_run_build_trigger_flattened_error_async(): @pytest.mark.parametrize( - "request_type", [cloudbuild.ReceiveTriggerWebhookRequest, dict,] + "request_type", + [ + cloudbuild.ReceiveTriggerWebhookRequest, + dict, + ], ) def test_receive_trigger_webhook(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3141,7 +4223,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3160,7 +4243,8 @@ async def test_receive_trigger_webhook_async( request_type=cloudbuild.ReceiveTriggerWebhookRequest, ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3191,10 +4275,84 @@ async def test_receive_trigger_webhook_async_from_dict(): await test_receive_trigger_webhook_async(request_type=dict) -@pytest.mark.parametrize("request_type", [cloudbuild.CreateWorkerPoolRequest, dict,]) +def test_receive_trigger_webhook_field_headers(): + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ReceiveTriggerWebhookRequest() + + request.project_id = "project_id_value" + request.trigger = "trigger_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.receive_trigger_webhook), "__call__" + ) as call: + call.return_value = cloudbuild.ReceiveTriggerWebhookResponse() + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger=trigger_value", + ) in kw["metadata"] + + +@pytest.mark.asyncio +async def test_receive_trigger_webhook_field_headers_async(): + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + + # Any value that is part of the HTTP/1.1 URI should be sent as + # a field header. Set these to a non-empty value. + request = cloudbuild.ReceiveTriggerWebhookRequest() + + request.project_id = "project_id_value" + request.trigger = "trigger_value" + + # Mock the actual call within the gRPC stub, and fake the request. + with mock.patch.object( + type(client.transport.receive_trigger_webhook), "__call__" + ) as call: + call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( + cloudbuild.ReceiveTriggerWebhookResponse() + ) + 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] == request + + # Establish that the field header was sent. + _, _, kw = call.mock_calls[0] + assert ( + "x-goog-request-params", + "project_id=project_id_value&trigger=trigger_value", + ) in kw["metadata"] + + +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.CreateWorkerPoolRequest, + dict, + ], +) def test_create_worker_pool(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3222,7 +4380,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3240,7 +4399,8 @@ async def test_create_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.CreateWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3272,13 +4432,15 @@ async def test_create_worker_pool_async_from_dict(): def test_create_worker_pool_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.CreateWorkerPoolRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3294,18 +4456,23 @@ def test_create_worker_pool_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_create_worker_pool_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.CreateWorkerPoolRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3323,11 +4490,16 @@ async def test_create_worker_pool_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_create_worker_pool_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3359,7 +4531,9 @@ def test_create_worker_pool_flattened(): def test_create_worker_pool_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3374,7 +4548,9 @@ def test_create_worker_pool_flattened_error(): @pytest.mark.asyncio async def test_create_worker_pool_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3411,7 +4587,9 @@ async def test_create_worker_pool_flattened_async(): @pytest.mark.asyncio async def test_create_worker_pool_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -3424,10 +4602,17 @@ async def test_create_worker_pool_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.GetWorkerPoolRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.GetWorkerPoolRequest, + dict, + ], +) def test_get_worker_pool(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3469,7 +4654,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3485,7 +4671,8 @@ async def test_get_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.GetWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3526,13 +4713,15 @@ async def test_get_worker_pool_async_from_dict(): def test_get_worker_pool_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.GetWorkerPoolRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_worker_pool), "__call__") as call: @@ -3546,18 +4735,23 @@ def test_get_worker_pool_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_get_worker_pool_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.GetWorkerPoolRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object(type(client.transport.get_worker_pool), "__call__") as call: @@ -3573,11 +4767,16 @@ async def test_get_worker_pool_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_get_worker_pool_flattened(): - client = CloudBuildClient(credentials=ga_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_worker_pool), "__call__") as call: @@ -3585,7 +4784,9 @@ def test_get_worker_pool_flattened(): call.return_value = cloudbuild.WorkerPool() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.get_worker_pool(name="name_value",) + client.get_worker_pool( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3597,19 +4798,24 @@ def test_get_worker_pool_flattened(): def test_get_worker_pool_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.get_worker_pool( - cloudbuild.GetWorkerPoolRequest(), name="name_value", + cloudbuild.GetWorkerPoolRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_get_worker_pool_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_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_worker_pool), "__call__") as call: @@ -3621,7 +4827,9 @@ async def test_get_worker_pool_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.get_worker_pool(name="name_value",) + response = await client.get_worker_pool( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3634,20 +4842,30 @@ async def test_get_worker_pool_flattened_async(): @pytest.mark.asyncio async def test_get_worker_pool_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.get_worker_pool( - cloudbuild.GetWorkerPoolRequest(), name="name_value", + cloudbuild.GetWorkerPoolRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudbuild.DeleteWorkerPoolRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.DeleteWorkerPoolRequest, + dict, + ], +) def test_delete_worker_pool(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3675,7 +4893,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3693,7 +4912,8 @@ async def test_delete_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.DeleteWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3725,13 +4945,15 @@ async def test_delete_worker_pool_async_from_dict(): def test_delete_worker_pool_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.DeleteWorkerPoolRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3747,18 +4969,23 @@ def test_delete_worker_pool_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_delete_worker_pool_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.DeleteWorkerPoolRequest() - request.name = "name/value" + request.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3776,11 +5003,16 @@ async def test_delete_worker_pool_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "name=name/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "name=name_value", + ) in kw["metadata"] def test_delete_worker_pool_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3790,7 +5022,9 @@ def test_delete_worker_pool_flattened(): 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.delete_worker_pool(name="name_value",) + client.delete_worker_pool( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3802,19 +5036,24 @@ def test_delete_worker_pool_flattened(): def test_delete_worker_pool_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.delete_worker_pool( - cloudbuild.DeleteWorkerPoolRequest(), name="name_value", + cloudbuild.DeleteWorkerPoolRequest(), + name="name_value", ) @pytest.mark.asyncio async def test_delete_worker_pool_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3828,7 +5067,9 @@ async def test_delete_worker_pool_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.delete_worker_pool(name="name_value",) + response = await client.delete_worker_pool( + name="name_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -3841,20 +5082,30 @@ async def test_delete_worker_pool_flattened_async(): @pytest.mark.asyncio async def test_delete_worker_pool_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.delete_worker_pool( - cloudbuild.DeleteWorkerPoolRequest(), name="name_value", + cloudbuild.DeleteWorkerPoolRequest(), + name="name_value", ) -@pytest.mark.parametrize("request_type", [cloudbuild.UpdateWorkerPoolRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.UpdateWorkerPoolRequest, + dict, + ], +) def test_update_worker_pool(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3882,7 +5133,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -3900,7 +5152,8 @@ async def test_update_worker_pool_async( transport: str = "grpc_asyncio", request_type=cloudbuild.UpdateWorkerPoolRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -3932,13 +5185,15 @@ async def test_update_worker_pool_async_from_dict(): def test_update_worker_pool_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.UpdateWorkerPoolRequest() - request.worker_pool.name = "worker_pool.name/value" + request.worker_pool.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3954,20 +5209,23 @@ def test_update_worker_pool_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "worker_pool.name=worker_pool.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "worker_pool.name=name_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_update_worker_pool_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.UpdateWorkerPoolRequest() - request.worker_pool.name = "worker_pool.name/value" + request.worker_pool.name = "name_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -3985,13 +5243,16 @@ async def test_update_worker_pool_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "worker_pool.name=worker_pool.name/value",) in kw[ - "metadata" - ] + assert ( + "x-goog-request-params", + "worker_pool.name=name_value", + ) in kw["metadata"] def test_update_worker_pool_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4019,7 +5280,9 @@ def test_update_worker_pool_flattened(): def test_update_worker_pool_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4033,7 +5296,9 @@ def test_update_worker_pool_flattened_error(): @pytest.mark.asyncio async def test_update_worker_pool_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4066,7 +5331,9 @@ async def test_update_worker_pool_flattened_async(): @pytest.mark.asyncio async def test_update_worker_pool_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. @@ -4078,10 +5345,17 @@ async def test_update_worker_pool_flattened_error_async(): ) -@pytest.mark.parametrize("request_type", [cloudbuild.ListWorkerPoolsRequest, dict,]) +@pytest.mark.parametrize( + "request_type", + [ + cloudbuild.ListWorkerPoolsRequest, + dict, + ], +) def test_list_worker_pools(request_type, transport: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4112,7 +5386,8 @@ 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=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4130,7 +5405,8 @@ async def test_list_worker_pools_async( transport: str = "grpc_asyncio", request_type=cloudbuild.ListWorkerPoolsRequest ): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # Everything is optional in proto3 as far as the runtime is concerned, @@ -4143,7 +5419,9 @@ async def test_list_worker_pools_async( ) as call: # Designate an appropriate return value for the call. call.return_value = grpc_helpers_async.FakeUnaryUnaryCall( - cloudbuild.ListWorkerPoolsResponse(next_page_token="next_page_token_value",) + cloudbuild.ListWorkerPoolsResponse( + next_page_token="next_page_token_value", + ) ) response = await client.list_worker_pools(request) @@ -4163,13 +5441,15 @@ async def test_list_worker_pools_async_from_dict(): def test_list_worker_pools_field_headers(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.ListWorkerPoolsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4185,18 +5465,23 @@ def test_list_worker_pools_field_headers(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] @pytest.mark.asyncio async def test_list_worker_pools_field_headers_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Any value that is part of the HTTP/1.1 URI should be sent as # a field header. Set these to a non-empty value. request = cloudbuild.ListWorkerPoolsRequest() - request.parent = "parent/value" + request.parent = "parent_value" # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4214,11 +5499,16 @@ async def test_list_worker_pools_field_headers_async(): # Establish that the field header was sent. _, _, kw = call.mock_calls[0] - assert ("x-goog-request-params", "parent=parent/value",) in kw["metadata"] + assert ( + "x-goog-request-params", + "parent=parent_value", + ) in kw["metadata"] def test_list_worker_pools_flattened(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4228,7 +5518,9 @@ def test_list_worker_pools_flattened(): call.return_value = cloudbuild.ListWorkerPoolsResponse() # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - client.list_worker_pools(parent="parent_value",) + client.list_worker_pools( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4240,19 +5532,24 @@ def test_list_worker_pools_flattened(): def test_list_worker_pools_flattened_error(): - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): client.list_worker_pools( - cloudbuild.ListWorkerPoolsRequest(), parent="parent_value", + cloudbuild.ListWorkerPoolsRequest(), + parent="parent_value", ) @pytest.mark.asyncio async def test_list_worker_pools_flattened_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4266,7 +5563,9 @@ async def test_list_worker_pools_flattened_async(): ) # Call the method with a truthy value for each flattened field, # using the keyword arguments to the method. - response = await client.list_worker_pools(parent="parent_value",) + response = await client.list_worker_pools( + parent="parent_value", + ) # Establish that the underlying call was made with the expected # request object values. @@ -4279,19 +5578,23 @@ async def test_list_worker_pools_flattened_async(): @pytest.mark.asyncio async def test_list_worker_pools_flattened_error_async(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials(),) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials(), + ) # Attempting to call a method with both a request object and flattened # fields is an error. with pytest.raises(ValueError): await client.list_worker_pools( - cloudbuild.ListWorkerPoolsRequest(), parent="parent_value", + cloudbuild.ListWorkerPoolsRequest(), + parent="parent_value", ) def test_list_worker_pools_pager(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4308,12 +5611,21 @@ def test_list_worker_pools_pager(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloudbuild.ListWorkerPoolsResponse(worker_pools=[], next_page_token="def",), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(),], next_page_token="ghi", + worker_pools=[], + next_page_token="def", + ), + cloudbuild.ListWorkerPoolsResponse( + worker_pools=[ + cloudbuild.WorkerPool(), + ], + next_page_token="ghi", ), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(), cloudbuild.WorkerPool(),], + worker_pools=[ + cloudbuild.WorkerPool(), + cloudbuild.WorkerPool(), + ], ), RuntimeError, ) @@ -4326,14 +5638,15 @@ def test_list_worker_pools_pager(transport_name: str = "grpc"): assert pager._metadata == metadata - results = [i for i in pager] + results = list(pager) assert len(results) == 6 assert all(isinstance(i, cloudbuild.WorkerPool) for i in results) def test_list_worker_pools_pages(transport_name: str = "grpc"): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials, transport=transport_name, + credentials=ga_credentials.AnonymousCredentials, + transport=transport_name, ) # Mock the actual call within the gRPC stub, and fake the request. @@ -4350,12 +5663,21 @@ def test_list_worker_pools_pages(transport_name: str = "grpc"): ], next_page_token="abc", ), - cloudbuild.ListWorkerPoolsResponse(worker_pools=[], next_page_token="def",), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(),], next_page_token="ghi", + worker_pools=[], + next_page_token="def", + ), + cloudbuild.ListWorkerPoolsResponse( + worker_pools=[ + cloudbuild.WorkerPool(), + ], + next_page_token="ghi", ), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(), cloudbuild.WorkerPool(),], + worker_pools=[ + cloudbuild.WorkerPool(), + cloudbuild.WorkerPool(), + ], ), RuntimeError, ) @@ -4366,7 +5688,9 @@ def test_list_worker_pools_pages(transport_name: str = "grpc"): @pytest.mark.asyncio async def test_list_worker_pools_async_pager(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4384,19 +5708,30 @@ async def test_list_worker_pools_async_pager(): ], next_page_token="abc", ), - cloudbuild.ListWorkerPoolsResponse(worker_pools=[], next_page_token="def",), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(),], next_page_token="ghi", + worker_pools=[], + next_page_token="def", + ), + cloudbuild.ListWorkerPoolsResponse( + worker_pools=[ + cloudbuild.WorkerPool(), + ], + next_page_token="ghi", ), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(), cloudbuild.WorkerPool(),], + worker_pools=[ + cloudbuild.WorkerPool(), + cloudbuild.WorkerPool(), + ], ), RuntimeError, ) - async_pager = await client.list_worker_pools(request={},) + async_pager = await client.list_worker_pools( + request={}, + ) assert async_pager.next_page_token == "abc" responses = [] - async for response in async_pager: + async for response in async_pager: # pragma: no branch responses.append(response) assert len(responses) == 6 @@ -4405,7 +5740,9 @@ async def test_list_worker_pools_async_pager(): @pytest.mark.asyncio async def test_list_worker_pools_async_pages(): - client = CloudBuildAsyncClient(credentials=ga_credentials.AnonymousCredentials,) + client = CloudBuildAsyncClient( + credentials=ga_credentials.AnonymousCredentials, + ) # Mock the actual call within the gRPC stub, and fake the request. with mock.patch.object( @@ -4423,17 +5760,28 @@ async def test_list_worker_pools_async_pages(): ], next_page_token="abc", ), - cloudbuild.ListWorkerPoolsResponse(worker_pools=[], next_page_token="def",), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(),], next_page_token="ghi", + worker_pools=[], + next_page_token="def", + ), + cloudbuild.ListWorkerPoolsResponse( + worker_pools=[ + cloudbuild.WorkerPool(), + ], + next_page_token="ghi", ), cloudbuild.ListWorkerPoolsResponse( - worker_pools=[cloudbuild.WorkerPool(), cloudbuild.WorkerPool(),], + worker_pools=[ + cloudbuild.WorkerPool(), + cloudbuild.WorkerPool(), + ], ), RuntimeError, ) pages = [] - async for page_ in (await client.list_worker_pools(request={})).pages: + async for page_ in ( + await client.list_worker_pools(request={}) + ).pages: # pragma: no branch pages.append(page_) for page_, token in zip(pages, ["abc", "def", "ghi", ""]): assert page_.raw_page.next_page_token == token @@ -4446,7 +5794,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport=transport, + credentials=ga_credentials.AnonymousCredentials(), + transport=transport, ) # It is an error to provide a credentials file and a transport instance. @@ -4466,7 +5815,10 @@ def test_credentials_transport_error(): options = client_options.ClientOptions() options.api_key = "api_key" with pytest.raises(ValueError): - client = CloudBuildClient(client_options=options, transport=transport,) + client = CloudBuildClient( + client_options=options, + transport=transport, + ) # It is an error to provide an api_key and a credential. options = mock.Mock() @@ -4482,7 +5834,8 @@ def test_credentials_transport_error(): ) with pytest.raises(ValueError): client = CloudBuildClient( - client_options={"scopes": ["1", "2"]}, transport=transport, + client_options={"scopes": ["1", "2"]}, + transport=transport, ) @@ -4512,7 +5865,10 @@ def test_transport_get_channel(): @pytest.mark.parametrize( "transport_class", - [transports.CloudBuildGrpcTransport, transports.CloudBuildGrpcAsyncIOTransport,], + [ + transports.CloudBuildGrpcTransport, + transports.CloudBuildGrpcAsyncIOTransport, + ], ) def test_transport_adc(transport_class): # Test default credentials are used if not provided. @@ -4522,10 +5878,28 @@ def test_transport_adc(transport_class): adc.assert_called_once() +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + ], +) +def test_transport_kind(transport_name): + transport = CloudBuildClient.get_transport_class(transport_name)( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert transport.kind == transport_name + + def test_transport_grpc_default(): # A client should use the gRPC transport by default. - client = CloudBuildClient(credentials=ga_credentials.AnonymousCredentials(),) - assert isinstance(client.transport, transports.CloudBuildGrpcTransport,) + client = CloudBuildClient( + credentials=ga_credentials.AnonymousCredentials(), + ) + assert isinstance( + client.transport, + transports.CloudBuildGrpcTransport, + ) def test_cloud_build_base_transport_error(): @@ -4581,6 +5955,14 @@ def test_cloud_build_base_transport(): with pytest.raises(NotImplementedError): transport.operations_client + # Catch all for all remaining methods and properties + remainder = [ + "kind", + ] + for r in remainder: + with pytest.raises(NotImplementedError): + getattr(transport, r)() + def test_cloud_build_base_transport_with_credentials_file(): # Instantiate the base transport with a credentials file @@ -4592,7 +5974,8 @@ def test_cloud_build_base_transport_with_credentials_file(): Transport.return_value = None load_creds.return_value = (ga_credentials.AnonymousCredentials(), None) transport = transports.CloudBuildTransport( - credentials_file="credentials.json", quota_project_id="octopus", + credentials_file="credentials.json", + quota_project_id="octopus", ) load_creds.assert_called_once_with( "credentials.json", @@ -4627,7 +6010,10 @@ def test_cloud_build_auth_adc(): @pytest.mark.parametrize( "transport_class", - [transports.CloudBuildGrpcTransport, transports.CloudBuildGrpcAsyncIOTransport,], + [ + transports.CloudBuildGrpcTransport, + transports.CloudBuildGrpcAsyncIOTransport, + ], ) def test_cloud_build_transport_auth_adc(transport_class): # If credentials and host are not provided, the transport class should use @@ -4719,24 +6105,40 @@ def test_cloud_build_grpc_transport_client_cert_source_for_mtls(transport_class) ) -def test_cloud_build_host_no_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_build_host_no_port(transport_name): client = CloudBuildClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudbuild.googleapis.com" ), + transport=transport_name, ) - assert client.transport._host == "cloudbuild.googleapis.com:443" + assert client.transport._host == ("cloudbuild.googleapis.com:443") -def test_cloud_build_host_with_port(): +@pytest.mark.parametrize( + "transport_name", + [ + "grpc", + "grpc_asyncio", + ], +) +def test_cloud_build_host_with_port(transport_name): client = CloudBuildClient( credentials=ga_credentials.AnonymousCredentials(), client_options=client_options.ClientOptions( api_endpoint="cloudbuild.googleapis.com:8000" ), + transport=transport_name, ) - assert client.transport._host == "cloudbuild.googleapis.com:8000" + assert client.transport._host == ("cloudbuild.googleapis.com:8000") def test_cloud_build_grpc_transport_channel(): @@ -4744,7 +6146,8 @@ def test_cloud_build_grpc_transport_channel(): # Check that channel is used if provided. transport = transports.CloudBuildGrpcTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4756,7 +6159,8 @@ def test_cloud_build_grpc_asyncio_transport_channel(): # Check that channel is used if provided. transport = transports.CloudBuildGrpcAsyncIOTransport( - host="squid.clam.whelk", channel=channel, + host="squid.clam.whelk", + channel=channel, ) assert transport.grpc_channel == channel assert transport._host == "squid.clam.whelk:443" @@ -4857,12 +6261,16 @@ def test_cloud_build_transport_channel_mtls_with_adc(transport_class): def test_cloud_build_grpc_lro_client(): client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -4870,12 +6278,16 @@ def test_cloud_build_grpc_lro_client(): def test_cloud_build_grpc_lro_async_client(): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) transport = client.transport # Ensure that we have a api-core operations client. - assert isinstance(transport.operations_client, operations_v1.OperationsAsyncClient,) + assert isinstance( + transport.operations_client, + operations_v1.OperationsAsyncClient, + ) # Ensure that subsequent calls to the property send the exact same object. assert transport.operations_client is transport.operations_client @@ -4884,7 +6296,10 @@ 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,) + expected = "projects/{project}/builds/{build}".format( + project=project, + build=build, + ) actual = CloudBuildClient.build_path(project, build) assert expected == actual @@ -4905,7 +6320,8 @@ def test_build_trigger_path(): project = "oyster" trigger = "nudibranch" expected = "projects/{project}/triggers/{trigger}".format( - project=project, trigger=trigger, + project=project, + trigger=trigger, ) actual = CloudBuildClient.build_trigger_path(project, trigger) assert expected == actual @@ -4929,7 +6345,10 @@ def test_crypto_key_path(): keyring = "scallop" key = "abalone" expected = "projects/{project}/locations/{location}/keyRings/{keyring}/cryptoKeys/{key}".format( - project=project, location=location, keyring=keyring, key=key, + project=project, + location=location, + keyring=keyring, + key=key, ) actual = CloudBuildClient.crypto_key_path(project, location, keyring, key) assert expected == actual @@ -4953,7 +6372,8 @@ def test_network_path(): project = "oyster" network = "nudibranch" expected = "projects/{project}/global/networks/{network}".format( - project=project, network=network, + project=project, + network=network, ) actual = CloudBuildClient.network_path(project, network) assert expected == actual @@ -4976,7 +6396,9 @@ def test_secret_version_path(): secret = "nautilus" version = "scallop" expected = "projects/{project}/secrets/{secret}/versions/{version}".format( - project=project, secret=secret, version=version, + project=project, + secret=secret, + version=version, ) actual = CloudBuildClient.secret_version_path(project, secret, version) assert expected == actual @@ -4999,7 +6421,8 @@ def test_service_account_path(): project = "whelk" service_account = "octopus" expected = "projects/{project}/serviceAccounts/{service_account}".format( - project=project, service_account=service_account, + project=project, + service_account=service_account, ) actual = CloudBuildClient.service_account_path(project, service_account) assert expected == actual @@ -5021,7 +6444,8 @@ def test_subscription_path(): project = "cuttlefish" subscription = "mussel" expected = "projects/{project}/subscriptions/{subscription}".format( - project=project, subscription=subscription, + project=project, + subscription=subscription, ) actual = CloudBuildClient.subscription_path(project, subscription) assert expected == actual @@ -5042,7 +6466,10 @@ def test_parse_subscription_path(): def test_topic_path(): project = "scallop" topic = "abalone" - expected = "projects/{project}/topics/{topic}".format(project=project, topic=topic,) + expected = "projects/{project}/topics/{topic}".format( + project=project, + topic=topic, + ) actual = CloudBuildClient.topic_path(project, topic) assert expected == actual @@ -5063,8 +6490,12 @@ def test_worker_pool_path(): project = "whelk" location = "octopus" worker_pool = "oyster" - expected = "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( - project=project, location=location, worker_pool=worker_pool, + expected = ( + "projects/{project}/locations/{location}/workerPools/{worker_pool}".format( + project=project, + location=location, + worker_pool=worker_pool, + ) ) actual = CloudBuildClient.worker_pool_path(project, location, worker_pool) assert expected == actual @@ -5105,7 +6536,9 @@ def test_parse_common_billing_account_path(): def test_common_folder_path(): folder = "scallop" - expected = "folders/{folder}".format(folder=folder,) + expected = "folders/{folder}".format( + folder=folder, + ) actual = CloudBuildClient.common_folder_path(folder) assert expected == actual @@ -5123,7 +6556,9 @@ def test_parse_common_folder_path(): def test_common_organization_path(): organization = "squid" - expected = "organizations/{organization}".format(organization=organization,) + expected = "organizations/{organization}".format( + organization=organization, + ) actual = CloudBuildClient.common_organization_path(organization) assert expected == actual @@ -5141,7 +6576,9 @@ def test_parse_common_organization_path(): def test_common_project_path(): project = "whelk" - expected = "projects/{project}".format(project=project,) + expected = "projects/{project}".format( + project=project, + ) actual = CloudBuildClient.common_project_path(project) assert expected == actual @@ -5161,7 +6598,8 @@ def test_common_location_path(): project = "oyster" location = "nudibranch" expected = "projects/{project}/locations/{location}".format( - project=project, location=location, + project=project, + location=location, ) actual = CloudBuildClient.common_location_path(project, location) assert expected == actual @@ -5186,7 +6624,8 @@ def test_client_with_default_client_info(): transports.CloudBuildTransport, "_prep_wrapped_messages" ) as prep: client = CloudBuildClient( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5195,7 +6634,8 @@ def test_client_with_default_client_info(): ) as prep: transport_class = CloudBuildClient.get_transport_class() transport = transport_class( - credentials=ga_credentials.AnonymousCredentials(), client_info=client_info, + credentials=ga_credentials.AnonymousCredentials(), + client_info=client_info, ) prep.assert_called_once_with(client_info) @@ -5203,7 +6643,8 @@ def test_client_with_default_client_info(): @pytest.mark.asyncio async def test_transport_close_async(): client = CloudBuildAsyncClient( - credentials=ga_credentials.AnonymousCredentials(), transport="grpc_asyncio", + credentials=ga_credentials.AnonymousCredentials(), + transport="grpc_asyncio", ) with mock.patch.object( type(getattr(client.transport, "grpc_channel")), "close"